1
Fork 0

Rollup merge of #115624 - compiler-errors:rtn-path, r=WaffleLapkin

Print the path of a return-position impl trait in trait when `return_type_notation` is enabled

When we're printing a return-position impl trait in trait, we usually just print it like an opaque. This is *usually* fine, but can be confusing when using `return_type_notation`. Print the path of the method from where the RPITIT originates when this feature gate is enabled.
This commit is contained in:
Matthias Krüger 2023-09-08 08:23:03 +02:00 committed by GitHub
commit bef5187e8b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 75 additions and 2 deletions

View file

@ -1123,6 +1123,17 @@ pub trait PrettyPrinter<'tcx>:
}
}
if self.tcx().features().return_type_notation
&& let Some(ty::ImplTraitInTraitData::Trait { fn_def_id, .. }) = self.tcx().opt_rpitit_info(def_id)
&& let ty::Alias(_, alias_ty) = self.tcx().fn_sig(fn_def_id).skip_binder().output().skip_binder().kind()
&& alias_ty.def_id == def_id
{
let num_args = self.tcx().generics_of(fn_def_id).count();
write!(self, " {{ ")?;
self = self.print_def_path(fn_def_id, &args[..num_args])?;
write!(self, "() }}")?;
}
Ok(self)
}