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

fix: sort all bounds on trait object types #13192

Merged
merged 1 commit into from
Sep 5, 2022

Conversation

lowr
Copy link
Contributor

@lowr lowr commented Sep 5, 2022

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 SmallVecs so it's easier to do the same thing for other bounds when we have them.

@lowr lowr force-pushed the fix/dyn-sort-all-bounds branch from 0ecf254 to 265c75c Compare September 5, 2022 10:14
@Veykril
Copy link
Member

Veykril commented Sep 5, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Sep 5, 2022

📌 Commit 265c75c has been approved by Veykril

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Sep 5, 2022

⌛ Testing commit 265c75c with merge 6dfd8ae...

@bors
Copy link
Contributor

bors commented Sep 5, 2022

☀️ Test successful - checks-actions
Approved by: Veykril
Pushing 6dfd8ae to master...

@bors bors merged commit 6dfd8ae into rust-lang:master Sep 5, 2022
bors added a commit that referenced this pull request Oct 11, 2022
fix: reorder dyn bounds on render

Fixes #13368

#13192 changed the order of dyn bounds, violating the [contract](https://github.com/rust-lang/rust-analyzer/blob/3a69435af7a1e6273744085cb251adb2b9c30a03/crates/hir-ty/src/display.rs#L896-L901) with `write_bounds_like_dyn_trait()` on render. The projection bounds are expected to come right after the trait bound they are accompanied with.

Although the reordering procedure can be made a bit more efficient, I opted for relying only on the [invariants](https://github.com/rust-lang/rust-analyzer/blob/3a69435af7a1e6273744085cb251adb2b9c30a03/crates/hir-ty/src/lower.rs#L995-L998) currently documented in `lower_dyn_trait()`. It's not the hottest path and dyn bounds tend to be short so I believe it shouldn't hurt performance noticeably.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Type inference not working for special associated type order.
3 participants