1
Fork 0

Rollup merge of #129395 - fmease:pp-dyn-w-gat, r=compiler-errors

Pretty-print own args of existential projections (dyn-Trait w/ GAT constraints)

Previously we would just drop them. This bug isn't that significant as it can only be triggered by user code that constrains GATs inside trait object types which is currently gated under the interim feature `generic_associated_types_extended` (whose future is questionable) or on stable if the GATs are 'disabled' in dyn-Trait via `where Self: Sized` (in which case the assoc type bindings get ignored anyway (and trigger the warn-by-default lint `unused_associated_type_bounds`)), so yeah.

Affects diagnostic output and output of `std::any::type_name{_of_val}`.
This commit is contained in:
Matthias Krüger 2024-08-22 08:17:23 +02:00 committed by GitHub
commit 9d39b59862
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 50 additions and 20 deletions

View file

@ -3119,7 +3119,10 @@ define_print! {
ty::ExistentialProjection<'tcx> {
let name = cx.tcx().associated_item(self.def_id).name;
p!(write("{} = ", name), print(self.term))
// The args don't contain the self ty (as it has been erased) but the corresp.
// generics do as the trait always has a self ty param. We need to offset.
let args = &self.args[cx.tcx().generics_of(self.def_id).parent_count - 1..];
p!(path_generic_args(|cx| write!(cx, "{name}"), args), " = ", print(self.term))
}
ty::ProjectionPredicate<'tcx> {