Skip to content

Commit bb48688

Browse files
committed
Add early-return when checking if a path is local
1 parent 6a3b092 commit bb48688

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
@@ -219,7 +219,9 @@ fn path_has_local_parent(
219219
impl_parent_parent: Option<DefId>,
220220
) -> bool {
221221
path.res.opt_def_id().is_some_and(|did| {
222-
let res_parent = cx.tcx.parent(did);
223-
res_parent == impl_parent || Some(res_parent) == impl_parent_parent
222+
did.is_local() && {
223+
let res_parent = cx.tcx.parent(did);
224+
res_parent == impl_parent || Some(res_parent) == impl_parent_parent
225+
}
224226
})
225227
}

0 commit comments

Comments
 (0)