-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
fix: sort and deduplicate auto traits in trait object types #12793
Conversation
☔ The latest upstream changes (presumably #13049) made this pull request unmergeable. Please resolve the merge conflicts. |
b86387e
to
a626774
Compare
crates/hir-ty/src/lower.rs
Outdated
return None; | ||
} | ||
|
||
auto_traits.sort_by_key(|b| b.trait_id().unwrap()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't sort_unstable_by_key()
be preferred?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds right, we don't need stability here. Thanks for pointing out!
Thanks! |
☀️ Test successful - checks-actions |
fix: sort all bounds on trait object types Fixes #13181 #12793 allowed different ordering of trait bounds in trait object types but failed to account for the ordering of projection bounds. I opted for sorting all the bounds at once rather than splitting them into `SmallVec`s so it's easier to do the same thing for other bounds when we have them.
Fixes #12739
Chalk solver doesn't sort and deduplicate auto traits in trait object types, so we need to handle them ourselves in the lowering phase, just like
rustc
andchalk-integration
do.Quoting from the Chalk book:
Also, trait object types with more than one non-auto traits were previously allowed, but are now disallowed with this patch.