diff options
| author | Jubilee <workingjubilee@gmail.com> | 2025-02-13 21:37:52 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-13 21:37:52 -0800 |
| commit | 3957eaa4595d6f3e984bd77ea48bb593795c1216 (patch) | |
| tree | cf0771be1482a7740d3e7355a050efab26344dec | |
| parent | 6c1768e66cc08b1f1df53ee2ac1436359df5dc9d (diff) | |
| parent | 88193aad724279c938efd2d17332e08a751de106 (diff) | |
| download | rust-3957eaa4595d6f3e984bd77ea48bb593795c1216.tar.gz rust-3957eaa4595d6f3e984bd77ea48bb593795c1216.zip | |
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.
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/util.rs | 4 | ||||
| -rw-r--r-- | tests/ui/traits/alias/expand-higher-ranked-alias.rs | 18 |
2 files changed, 20 insertions, 2 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/util.rs b/compiler/rustc_trait_selection/src/traits/util.rs index d30363ec158..15f5cf916a4 100644 --- a/compiler/rustc_trait_selection/src/traits/util.rs +++ b/compiler/rustc_trait_selection/src/traits/util.rs @@ -47,11 +47,11 @@ pub fn expand_trait_aliases<'tcx>( queue.extend( tcx.explicit_super_predicates_of(trait_pred.def_id()) .iter_identity_copied() - .map(|(clause, span)| { + .map(|(super_clause, span)| { let mut spans = spans.clone(); spans.push(span); ( - clause.instantiate_supertrait( + super_clause.instantiate_supertrait( tcx, clause.kind().rebind(trait_pred.trait_ref), ), diff --git a/tests/ui/traits/alias/expand-higher-ranked-alias.rs b/tests/ui/traits/alias/expand-higher-ranked-alias.rs new file mode 100644 index 00000000000..8a301d39f4c --- /dev/null +++ b/tests/ui/traits/alias/expand-higher-ranked-alias.rs @@ -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() {} |
