Skip to content

Commit f80a04f

Browse files
committed
Add early-return when checking if a path is local
1 parent 8501e52 commit f80a04f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

compiler/rustc_lint/src/non_local_def.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,9 @@ fn path_has_local_parent(
222222
impl_parent_parent: Option<DefId>,
223223
) -> bool {
224224
path.res.opt_def_id().is_some_and(|did| {
225-
let res_parent = cx.tcx.parent(did);
226-
res_parent == impl_parent || Some(res_parent) == impl_parent_parent
225+
did.is_local() && {
226+
let res_parent = cx.tcx.parent(did);
227+
res_parent == impl_parent || Some(res_parent) == impl_parent_parent
228+
}
227229
})
228230
}

0 commit comments

Comments
 (0)