Auto merge of #102334 - compiler-errors:rpitit-substs-issue, r=cjgillot

Fix subst issues with return-position `impl Trait` in trait

1. Fix an issue where we were rebase impl substs onto trait method substs, instead of trait substs
2. Fix an issue where early-bound regions aren't being mapped correctly for RPITIT hidden types

Fixes #102301
Fixes #102310
Fixes #102334
Fixes #102918
This commit is contained in:
bors 2022-10-16 10:10:44 +00:00
commit 8be3ce9056
5 changed files with 117 additions and 23 deletions

View file

@ -2254,7 +2254,10 @@ fn confirm_impl_trait_in_trait_candidate<'tcx>(
}
let impl_fn_def_id = leaf_def.item.def_id;
let impl_fn_substs = obligation.predicate.substs.rebase_onto(tcx, trait_fn_def_id, data.substs);
// Rebase from {trait}::{fn}::{opaque} to {impl}::{fn}::{opaque},
// since `data.substs` are the impl substs.
let impl_fn_substs =
obligation.predicate.substs.rebase_onto(tcx, tcx.parent(trait_fn_def_id), data.substs);
let cause = ObligationCause::new(
obligation.cause.span,