Skip to content

Commit 0a48547

Browse files
committed
Return a LocalDefId in get_parent_item.
1 parent d7024ac commit 0a48547

19 files changed

+39
-39
lines changed

clippy_lints/src/escape.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl<'tcx> LateLintPass<'tcx> for BoxedLocal {
7777
}
7878

7979
let parent_id = cx.tcx.hir().get_parent_item(hir_id);
80-
let parent_node = cx.tcx.hir().find(parent_id);
80+
let parent_node = cx.tcx.hir().find_by_def_id(parent_id);
8181

8282
let mut trait_self_ty = None;
8383
if let Some(Node::Item(item)) = parent_node {

clippy_lints/src/exit.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,10 @@ impl<'tcx> LateLintPass<'tcx> for Exit {
3434
if let Some(def_id) = cx.qpath_res(path, path_expr.hir_id).opt_def_id();
3535
if match_def_path(cx, def_id, &paths::EXIT);
3636
let parent = cx.tcx.hir().get_parent_item(e.hir_id);
37-
if let Some(Node::Item(Item{kind: ItemKind::Fn(..), ..})) = cx.tcx.hir().find(parent);
37+
if let Some(Node::Item(Item{kind: ItemKind::Fn(..), ..})) = cx.tcx.hir().find_by_def_id(parent);
3838
// If the next item up is a function we check if it is an entry point
3939
// and only then emit a linter warning
40-
let def_id = cx.tcx.hir().local_def_id(parent);
41-
if !is_entrypoint_fn(cx, def_id.to_def_id());
40+
if !is_entrypoint_fn(cx, parent.to_def_id());
4241
then {
4342
span_lint(cx, EXIT, e.span, "usage of `process::exit`");
4443
}

clippy_lints/src/functions/must_use.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub(super) fn check_impl_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Imp
4848
let attr = must_use_attr(attrs);
4949
if let Some(attr) = attr {
5050
check_needless_must_use(cx, sig.decl, item.hir_id(), item.span, fn_header_span, attr);
51-
} else if is_public && !is_proc_macro(cx.sess(), attrs) && trait_ref_of_method(cx, item.hir_id()).is_none() {
51+
} else if is_public && !is_proc_macro(cx.sess(), attrs) && trait_ref_of_method(cx, item.def_id).is_none() {
5252
check_must_use_candidate(
5353
cx,
5454
sig.decl,

clippy_lints/src/functions/result_unit_err.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub(super) fn check_impl_item(cx: &LateContext<'_>, item: &hir::ImplItem<'_>) {
2727
if let hir::ImplItemKind::Fn(ref sig, _) = item.kind {
2828
let is_public = cx.access_levels.is_exported(item.def_id);
2929
let fn_header_span = item.span.with_hi(sig.decl.output.span().hi());
30-
if is_public && trait_ref_of_method(cx, item.hir_id()).is_none() {
30+
if is_public && trait_ref_of_method(cx, item.def_id).is_none() {
3131
check_result_unit_err(cx, sig.decl, item.span, fn_header_span);
3232
}
3333
}

clippy_lints/src/inherent_to_string.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ impl<'tcx> LateLintPass<'tcx> for InherentToString {
116116
if is_type_diagnostic_item(cx, return_ty(cx, impl_item.hir_id()), sym::String);
117117

118118
// Filters instances of to_string which are required by a trait
119-
if trait_ref_of_method(cx, impl_item.hir_id()).is_none();
119+
if trait_ref_of_method(cx, impl_item.def_id).is_none();
120120

121121
then {
122122
show_lint(cx, impl_item);

clippy_lints/src/lifetimes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl<'tcx> LateLintPass<'tcx> for Lifetimes {
9191

9292
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx ImplItem<'_>) {
9393
if let ImplItemKind::Fn(ref sig, id) = item.kind {
94-
let report_extra_lifetimes = trait_ref_of_method(cx, item.hir_id()).is_none();
94+
let report_extra_lifetimes = trait_ref_of_method(cx, item.def_id).is_none();
9595
check_fn_inner(
9696
cx,
9797
sig.decl,

clippy_lints/src/loops/needless_range_loop.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ pub(super) fn check<'tcx>(
5858

5959
// ensure that the indexed variable was declared before the loop, see #601
6060
if let Some(indexed_extent) = indexed_extent {
61-
let parent_id = cx.tcx.hir().get_parent_item(expr.hir_id);
62-
let parent_def_id = cx.tcx.hir().local_def_id(parent_id);
61+
let parent_def_id = cx.tcx.hir().get_parent_item(expr.hir_id);
6362
let region_scope_tree = cx.tcx.region_scope_tree(parent_def_id);
6463
let pat_extent = region_scope_tree.var_scope(pat.hir_id.local_id);
6564
if region_scope_tree.is_subscope_of(indexed_extent, pat_extent) {
@@ -263,8 +262,7 @@ impl<'a, 'tcx> VarVisitor<'a, 'tcx> {
263262
let res = self.cx.qpath_res(seqpath, seqexpr.hir_id);
264263
match res {
265264
Res::Local(hir_id) => {
266-
let parent_id = self.cx.tcx.hir().get_parent_item(expr.hir_id);
267-
let parent_def_id = self.cx.tcx.hir().local_def_id(parent_id);
265+
let parent_def_id = self.cx.tcx.hir().get_parent_item(expr.hir_id);
268266
let extent = self.cx.tcx.region_scope_tree(parent_def_id).var_scope(hir_id.local_id);
269267
if index_used_directly {
270268
self.indexed_directly.insert(

clippy_lints/src/methods/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2053,7 +2053,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
20532053
return;
20542054
}
20552055
let name = impl_item.ident.name.as_str();
2056-
let parent = cx.tcx.hir().get_parent_did(impl_item.hir_id());
2056+
let parent = cx.tcx.hir().get_parent_item(impl_item.hir_id());
20572057
let item = cx.tcx.hir().expect_item(parent);
20582058
let self_ty = cx.tcx.type_of(item.def_id);
20592059

clippy_lints/src/missing_const_for_fn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingConstForFn {
121121
}
122122
},
123123
FnKind::Method(_, sig, ..) => {
124-
if trait_ref_of_method(cx, hir_id).is_some()
124+
if trait_ref_of_method(cx, def_id).is_some()
125125
|| already_const(sig.header)
126126
|| method_accepts_dropable(cx, sig.decl.inputs)
127127
{

clippy_lints/src/mut_key.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl<'tcx> LateLintPass<'tcx> for MutableKeyType {
8989

9090
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::ImplItem<'tcx>) {
9191
if let hir::ImplItemKind::Fn(ref sig, ..) = item.kind {
92-
if trait_ref_of_method(cx, item.hir_id()).is_none() {
92+
if trait_ref_of_method(cx, item.def_id).is_none() {
9393
check_sig(cx, item.hir_id(), sig.decl);
9494
}
9595
}

0 commit comments

Comments
 (0)