Skip to content

Commit

Permalink
Add early-return when checking if a path is local
Browse files Browse the repository at this point in the history
  • Loading branch information
Urgau committed Mar 7, 2024
1 parent 20200f6 commit 6c4eadd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions compiler/rustc_lint/src/non_local_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,9 @@ fn path_has_local_parent(
impl_parent_parent: Option<DefId>,
) -> bool {
path.res.opt_def_id().is_some_and(|did| {
let res_parent = cx.tcx.parent(did);
res_parent == impl_parent || Some(res_parent) == impl_parent_parent
did.is_local() && {
let res_parent = cx.tcx.parent(did);
res_parent == impl_parent || Some(res_parent) == impl_parent_parent
}
})
}

0 comments on commit 6c4eadd

Please sign in to comment.