Rollup merge of #109277 - spastorino:new-rpitit-14, r=compiler-errors
Fix generics_of for impl's RPITIT synthesized associated type The only useful commit is the last one. This makes `generics_of` for the impl side RPITIT copy from the trait's associated type and avoid the fn on the impl side which was previously wrongly used. This solution is better but we still need to fix resolution of the generated generics. r? ``@compiler-errors``
This commit is contained in:
commit
d86fd83ef6
13 changed files with 60 additions and 12 deletions
|
@ -3152,8 +3152,12 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
|
||||
debug!("impl_trait_ty_to_ty: generics={:?}", generics);
|
||||
let substs = InternalSubsts::for_item(tcx, def_id, |param, _| {
|
||||
if let Some(i) = (param.index as usize).checked_sub(generics.parent_count) {
|
||||
// Our own parameters are the resolved lifetimes.
|
||||
// We use `generics.count() - lifetimes.len()` here instead of `generics.parent_count`
|
||||
// since return-position impl trait in trait squashes all of the generics from its source fn
|
||||
// into its own generics, so the opaque's "own" params isn't always just lifetimes.
|
||||
if let Some(i) = (param.index as usize).checked_sub(generics.count() - lifetimes.len())
|
||||
{
|
||||
// Resolve our own lifetime parameters.
|
||||
let GenericParamDefKind::Lifetime { .. } = param.kind else { bug!() };
|
||||
let hir::GenericArg::Lifetime(lifetime) = &lifetimes[i] else { bug!() };
|
||||
self.ast_region_to_region(lifetime, None).into()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue