1
Fork 0

Auto merge of #96431 - petrochenkov:parent, r=cjgillot

rustc: Panic by default in `DefIdTree::parent`

Only crate root def-ids don't have a parent, and in majority of cases the argument of `DefIdTree::parent` cannot be a crate root.
So we now panic by default in `parent` and introduce a new non-panicing function `opt_parent` for cases where the argument can be a crate root.

Same applies to `local_parent`/`opt_local_parent`.
This commit is contained in:
bors 2022-05-02 14:03:20 +00:00
commit 879fb42596
50 changed files with 162 additions and 176 deletions

View file

@ -1390,7 +1390,7 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> {
&& self
.r
.trait_impl_items
.contains(&ty::DefIdTree::parent(&*self.r, def_id).unwrap().expect_local()))
.contains(&ty::DefIdTree::local_parent(&*self.r, local_def_id)))
{
// Trait impl item visibility is inherited from its trait when not specified
// explicitly. In that case we cannot determine it here in early resolve,