Skip to content

Commit 3957eaa

Browse files
Rollup merge of rust-lang#136951 - compiler-errors:clause-binder, r=lqd
Use the right binder for rebinding `PolyTraitRef` Fixes rust-lang#136940 I committed a slightly different test which still demonstrates the issue.
2 parents 6c1768e + 88193aa commit 3957eaa

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

Diff for: compiler/rustc_trait_selection/src/traits/util.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ pub fn expand_trait_aliases<'tcx>(
4747
queue.extend(
4848
tcx.explicit_super_predicates_of(trait_pred.def_id())
4949
.iter_identity_copied()
50-
.map(|(clause, span)| {
50+
.map(|(super_clause, span)| {
5151
let mut spans = spans.clone();
5252
spans.push(span);
5353
(
54-
clause.instantiate_supertrait(
54+
super_clause.instantiate_supertrait(
5555
tcx,
5656
clause.kind().rebind(trait_pred.trait_ref),
5757
),

Diff for: tests/ui/traits/alias/expand-higher-ranked-alias.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Make sure we are using the right binder vars when expanding
2+
// `for<'a> Foo<'a>` to `for<'a> Bar<'a>`.
3+
4+
//@ check-pass
5+
6+
#![feature(trait_alias)]
7+
8+
trait Bar<'a> {}
9+
10+
trait Foo<'a> = Bar<'a>;
11+
12+
fn test2(_: &(impl for<'a> Foo<'a> + ?Sized)) {}
13+
14+
fn test(x: &dyn for<'a> Foo<'a>) {
15+
test2(x);
16+
}
17+
18+
fn main() {}

0 commit comments

Comments
 (0)