Skip to content
/ rust Public
forked from rust-lang/rust

Commit 6c4eadd

Browse files
committed
Add early-return when checking if a path is local
1 parent 20200f6 commit 6c4eadd

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

compiler/rustc_lint/src/non_local_def.rs

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

0 commit comments

Comments
 (0)