Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the right binder for rebinding PolyTraitRef #136951

Merged
merged 1 commit into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/rustc_trait_selection/src/traits/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

variable shadowing lmao

Copy link
Member

@lqd lqd Feb 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it giveth, but sometimes it taketh away.

),
Expand Down
18 changes: 18 additions & 0 deletions tests/ui/traits/alias/expand-higher-ranked-alias.rs
Original file line number Diff line number Diff line change
@@ -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() {}
Loading