1
Fork 0

Rollup merge of #118715 - davidtwco:issue-117997-privacy-visit-trait-ref-and-args, r=TaKO8Ki

privacy: visit trait def id of projections

Fixes #117997.

A refactoring in #117076 changed the `DefIdVisitorSkeleton` to avoid calling `visit_projection_ty` for `ty::Projection` aliases, and instead just iterate over the args - this makes sense, as `visit_projection_ty` will indirectly visit all of the same args, but in doing so, will also create a `TraitRef` containing the trait's `DefId`, which also gets visited. The trait's `DefId` isn't visited when we only visit the arguments without separating them into `TraitRef` and own args first.

Eventually this influences the reachability set and whether a function is encoded into the metadata.
This commit is contained in:
Matthias Krüger 2023-12-08 23:15:13 +01:00 committed by GitHub
commit d2de292017
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 89 additions and 19 deletions

View file

@ -218,20 +218,21 @@ where
return ControlFlow::Continue(());
}
let kind = match kind {
ty::Inherent | ty::Projection => "associated type",
ty::Weak => "type alias",
ty::Opaque => unreachable!(),
};
self.def_id_visitor.visit_def_id(
data.def_id,
kind,
match kind {
ty::Inherent | ty::Projection => "associated type",
ty::Weak => "type alias",
ty::Opaque => unreachable!(),
},
&LazyDefPathStr { def_id: data.def_id, tcx },
)?;
// This will also visit args if necessary, so we don't need to recurse.
return if V::SHALLOW {
ControlFlow::Continue(())
} else if kind == ty::Projection {
self.visit_projection_ty(data)
} else {
data.args.iter().try_for_each(|subst| subst.visit_with(self))
};