-fn is_shadow(
- cx: &LateContext<'_>,
- owner: LocalDefId,
- 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 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)
+fn is_shadow(cx: &LateContext<'_>, owner: LocalDefId, first: ItemLocalId, second: ItemLocalId) -> bool {
+ let scope_tree = cx.tcx.region_scope_tree(owner.to_def_id());
+ if let Some(first_scope) = scope_tree.var_scope(first) {
+ if let Some(second_scope) = scope_tree.var_scope(second) {
+ return scope_tree.is_subscope_of(second_scope, first_scope);
+ }
+ }
+
+ false