This commit is contained in:
parent
02c94352d4
commit
f9c1acbc45
@ -123,7 +123,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CognitiveComplexity {
|
||||
hir_id: HirId,
|
||||
) {
|
||||
let def_id = cx.tcx.hir().local_def_id(hir_id);
|
||||
if !cx.tcx.has_attr(def_id, sym!(test)) {
|
||||
if !cx.tcx.has_attr(def_id.to_def_id(), sym!(test)) {
|
||||
self.check(cx, kind, decl, body, span);
|
||||
}
|
||||
}
|
||||
|
@ -160,16 +160,20 @@ fn check_hash_peq<'a, 'tcx>(
|
||||
};
|
||||
|
||||
span_lint_and_then(
|
||||
cx, DERIVE_HASH_XOR_EQ, span,
|
||||
cx,
|
||||
DERIVE_HASH_XOR_EQ,
|
||||
span,
|
||||
mess,
|
||||
|diag| {
|
||||
if let Some(hir_id) = cx.tcx.hir().as_local_hir_id(impl_id) {
|
||||
diag.span_note(
|
||||
cx.tcx.hir().span(hir_id),
|
||||
"`PartialEq` implemented here"
|
||||
);
|
||||
if let Some(local_def_id) = impl_id.as_local() {
|
||||
let hir_id = cx.tcx.hir().as_local_hir_id(local_def_id);
|
||||
diag.span_note(
|
||||
cx.tcx.hir().span(hir_id),
|
||||
"`PartialEq` implemented here"
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -225,7 +229,7 @@ fn check_unsafe_derive_deserialize<'a, 'tcx>(
|
||||
ty: Ty<'tcx>,
|
||||
) {
|
||||
fn item_from_def_id<'tcx>(cx: &LateContext<'_, 'tcx>, def_id: DefId) -> &'tcx Item<'tcx> {
|
||||
let hir_id = cx.tcx.hir().as_local_hir_id(def_id).unwrap();
|
||||
let hir_id = cx.tcx.hir().as_local_hir_id(def_id.expect_local());
|
||||
cx.tcx.hir().expect_item(hir_id)
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DocMarkdown {
|
||||
let headers = check_attrs(cx, &self.valid_idents, &item.attrs);
|
||||
match item.kind {
|
||||
hir::ItemKind::Fn(ref sig, _, body_id) => {
|
||||
if !(is_entrypoint_fn(cx, cx.tcx.hir().local_def_id(item.hir_id))
|
||||
if !(is_entrypoint_fn(cx, cx.tcx.hir().local_def_id(item.hir_id).to_def_id())
|
||||
|| in_external_macro(cx.tcx.sess, item.span))
|
||||
{
|
||||
lint_for_missing_headers(cx, item.hir_id, item.span, sig, headers, Some(body_id));
|
||||
|
@ -77,7 +77,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxedLocal {
|
||||
|
||||
let fn_def_id = cx.tcx.hir().local_def_id(hir_id);
|
||||
cx.tcx.infer_ctxt().enter(|infcx| {
|
||||
ExprUseVisitor::new(&mut v, &infcx, fn_def_id, cx.param_env, cx.tables).consume_body(body);
|
||||
ExprUseVisitor::new(&mut v, &infcx, fn_def_id.to_def_id(), cx.param_env, cx.tables).consume_body(body);
|
||||
});
|
||||
|
||||
for node in v.set {
|
||||
|
@ -37,7 +37,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Exit {
|
||||
// If the next item up is a function we check if it is an entry point
|
||||
// and only then emit a linter warning
|
||||
let def_id = cx.tcx.hir().local_def_id(parent);
|
||||
if !is_entrypoint_fn(cx, def_id) {
|
||||
if !is_entrypoint_fn(cx, def_id.to_def_id()) {
|
||||
span_lint(cx, EXIT, e.span, "usage of `process::exit`");
|
||||
}
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ fn check_trait_items(cx: &LateContext<'_, '_>, visited_trait: &Item<'_>, trait_i
|
||||
if cx.access_levels.is_exported(visited_trait.hir_id) && trait_items.iter().any(|i| is_named_self(cx, i, "len")) {
|
||||
let mut current_and_super_traits = FxHashSet::default();
|
||||
let visited_trait_def_id = cx.tcx.hir().local_def_id(visited_trait.hir_id);
|
||||
fill_trait_set(visited_trait_def_id, &mut current_and_super_traits, cx);
|
||||
fill_trait_set(visited_trait_def_id.to_def_id(), &mut current_and_super_traits, cx);
|
||||
|
||||
let is_empty_method_found = current_and_super_traits
|
||||
.iter()
|
||||
|
@ -83,12 +83,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingConstForFn {
|
||||
) {
|
||||
let def_id = cx.tcx.hir().local_def_id(hir_id);
|
||||
|
||||
if in_external_macro(cx.tcx.sess, span) || is_entrypoint_fn(cx, def_id) {
|
||||
if in_external_macro(cx.tcx.sess, span) || is_entrypoint_fn(cx, def_id.to_def_id()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Building MIR for `fn`s with unsatisfiable preds results in ICE.
|
||||
if fn_has_unsatisfiable_preds(cx, def_id) {
|
||||
if fn_has_unsatisfiable_preds(cx, def_id.to_def_id()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -118,8 +118,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingConstForFn {
|
||||
|
||||
let mir = cx.tcx.optimized_mir(def_id);
|
||||
|
||||
if let Err((span, err)) = is_min_const_fn(cx.tcx, def_id, &mir) {
|
||||
if rustc_mir::const_eval::is_min_const_fn(cx.tcx, def_id) {
|
||||
if let Err((span, err)) = is_min_const_fn(cx.tcx, def_id.to_def_id(), &mir) {
|
||||
if rustc_mir::const_eval::is_min_const_fn(cx.tcx, def_id.to_def_id()) {
|
||||
cx.tcx.sess.span_err(span, &err);
|
||||
}
|
||||
} else {
|
||||
|
@ -152,7 +152,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingInline {
|
||||
};
|
||||
|
||||
if let Some(trait_def_id) = trait_def_id {
|
||||
if cx.tcx.hir().as_local_hir_id(trait_def_id).is_some() && !cx.access_levels.is_exported(impl_item.hir_id) {
|
||||
if trait_def_id.is_local() && !cx.access_levels.is_exported(impl_item.hir_id) {
|
||||
// If a trait is being implemented for an item, and the
|
||||
// trait is not exported, we don't need #[inline]
|
||||
return;
|
||||
|
@ -135,7 +135,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
|
||||
} = {
|
||||
let mut ctx = MovedVariablesCtxt::default();
|
||||
cx.tcx.infer_ctxt().enter(|infcx| {
|
||||
euv::ExprUseVisitor::new(&mut ctx, &infcx, fn_def_id, cx.param_env, cx.tables).consume_body(body);
|
||||
euv::ExprUseVisitor::new(&mut ctx, &infcx, fn_def_id.to_def_id(), cx.param_env, cx.tables)
|
||||
.consume_body(body);
|
||||
});
|
||||
ctx
|
||||
};
|
||||
|
@ -136,8 +136,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault {
|
||||
let mut impls = HirIdSet::default();
|
||||
cx.tcx.for_each_impl(default_trait_id, |d| {
|
||||
if let Some(ty_def) = cx.tcx.type_of(d).ty_adt_def() {
|
||||
if let Some(hir_id) = cx.tcx.hir().as_local_hir_id(ty_def.did) {
|
||||
impls.insert(hir_id);
|
||||
if let Some(local_def_id) = ty_def.did.as_local() {
|
||||
impls.insert(cx.tcx.hir().as_local_hir_id(local_def_id));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -378,7 +378,7 @@ fn print_item(cx: &LateContext<'_, '_>, item: &hir::Item<'_>) {
|
||||
},
|
||||
hir::ItemKind::Trait(..) => {
|
||||
println!("trait decl");
|
||||
if cx.tcx.trait_is_auto(did) {
|
||||
if cx.tcx.trait_is_auto(did.to_def_id()) {
|
||||
println!("trait is auto");
|
||||
} else {
|
||||
println!("trait is not auto");
|
||||
|
Loading…
x
Reference in New Issue
Block a user