diff --git a/clippy_lints/src/loops/needless_range_loop.rs b/clippy_lints/src/loops/needless_range_loop.rs index e2b82f9fd..4f8536496 100644 --- a/clippy_lints/src/loops/needless_range_loop.rs +++ b/clippy_lints/src/loops/needless_range_loop.rs @@ -55,11 +55,7 @@ pub(super) fn check<'tcx>( // ensure that the indexed variable was declared before the loop, see #601 if let Some(indexed_extent) = indexed_extent { let parent_def_id = cx.tcx.hir().get_parent_item(expr.hir_id); - let parent_body_id = cx - .tcx - .hir() - .body_owned_by(cx.tcx.hir().local_def_id_to_hir_id(parent_def_id)); - let region_scope_tree = &cx.tcx.typeck_body(parent_body_id).region_scope_tree; + let region_scope_tree = cx.tcx.region_scope_tree(parent_def_id); let pat_extent = region_scope_tree.var_scope(pat.hir_id.local_id).unwrap(); if region_scope_tree.is_subscope_of(indexed_extent, pat_extent) { return; @@ -282,14 +278,9 @@ impl<'a, 'tcx> VarVisitor<'a, 'tcx> { match res { Res::Local(hir_id) => { let parent_def_id = self.cx.tcx.hir().get_parent_item(expr.hir_id); - let parent_body_id = self.cx - .tcx - .hir() - .body_owned_by(self.cx.tcx.hir().local_def_id_to_hir_id(parent_def_id)); let extent = self.cx .tcx - .typeck_body(parent_body_id) - .region_scope_tree + .region_scope_tree(parent_def_id) .var_scope(hir_id.local_id) .unwrap(); if index_used_directly { diff --git a/clippy_lints/src/shadow.rs b/clippy_lints/src/shadow.rs index db32b8d74..2a80e6f91 100644 --- a/clippy_lints/src/shadow.rs +++ b/clippy_lints/src/shadow.rs @@ -162,10 +162,7 @@ fn is_shadow( first: ItemLocalId, second: ItemLocalId, ) -> bool { - let scope_tree = &cx - .tcx - .typeck_body(cx.tcx.hir().body_owned_by(cx.tcx.hir().local_def_id_to_hir_id(owner))) - .region_scope_tree; + let scope_tree = cx.tcx.region_scope_tree(owner); let first_scope = scope_tree.var_scope(first).unwrap(); let second_scope = scope_tree.var_scope(second).unwrap(); scope_tree.is_subscope_of(second_scope, first_scope)