1
Fork 0

Rollup merge of #136951 - compiler-errors:clause-binder, r=lqd

Use the right binder for rebinding `PolyTraitRef`

Fixes #136940

I committed a slightly different test which still demonstrates the issue.
This commit is contained in:
Jubilee 2025-02-13 21:37:52 -08:00 committed by GitHub
commit 3957eaa459
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 2 deletions

View file

@ -47,11 +47,11 @@ pub fn expand_trait_aliases<'tcx>(
queue.extend( queue.extend(
tcx.explicit_super_predicates_of(trait_pred.def_id()) tcx.explicit_super_predicates_of(trait_pred.def_id())
.iter_identity_copied() .iter_identity_copied()
.map(|(clause, span)| { .map(|(super_clause, span)| {
let mut spans = spans.clone(); let mut spans = spans.clone();
spans.push(span); spans.push(span);
( (
clause.instantiate_supertrait( super_clause.instantiate_supertrait(
tcx, tcx,
clause.kind().rebind(trait_pred.trait_ref), clause.kind().rebind(trait_pred.trait_ref),
), ),

View file

@ -0,0 +1,18 @@
// Make sure we are using the right binder vars when expanding
// `for<'a> Foo<'a>` to `for<'a> Bar<'a>`.
//@ check-pass
#![feature(trait_alias)]
trait Bar<'a> {}
trait Foo<'a> = Bar<'a>;
fn test2(_: &(impl for<'a> Foo<'a> + ?Sized)) {}
fn test(x: &dyn for<'a> Foo<'a>) {
test2(x);
}
fn main() {}