Skip to content

feat: Allow crate authors to declare that their trait prefers to be imported as _#21740

Merged
ChayimFriedman2 merged 1 commit intorust-lang:masterfrom
ChayimFriedman2:prefer-underscore-import
Apr 19, 2026
Merged

feat: Allow crate authors to declare that their trait prefers to be imported as _#21740
ChayimFriedman2 merged 1 commit intorust-lang:masterfrom
ChayimFriedman2:prefer-underscore-import

Conversation

@ChayimFriedman2
Copy link
Copy Markdown
Contributor

@ChayimFriedman2 ChayimFriedman2 commented Mar 4, 2026

For example for extension traits.

Provide an attribute for that. It'll affect flyimport and the autoimport quickfix, as explained in the code.

The origin of this is me being angry at the next solver traits that have names identical to the types and make autoimport a nightmare, especially in completion. Then in general we don't do a good job for traits that would be better of imported as _, I at least leave them imported normally because it's more convenient for flyimport. So this fixes that.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 4, 2026
@@ -1,5 +1,5 @@
<!---
lsp/ext.rs hash: 235f56089da3dbb5
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This file didn't contain info about CompletionImport at all, so I just updated the hash.

@ChayimFriedman2
Copy link
Copy Markdown
Contributor Author

Can this be reviewed please? I'd like to use this for the solver's trait.

@rustbot

This comment has been minimized.

@ChayimFriedman2 ChayimFriedman2 force-pushed the prefer-underscore-import branch from 484e8b2 to beda061 Compare April 9, 2026 09:08
@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

…d `as _`

For example for extension traits.

Provide an attribute for that. It'll affect flyimport and the autoimport quickfix, as explained in the code.
@ChayimFriedman2 ChayimFriedman2 force-pushed the prefer-underscore-import branch from beda061 to f42e02a Compare April 19, 2026 02:52
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 19, 2026

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

Copy link
Copy Markdown
Member

@ShoyuVanilla ShoyuVanilla left a comment

Choose a reason for hiding this comment

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

I think this feature is good to have

View changes since this review

@ChayimFriedman2 ChayimFriedman2 added this pull request to the merge queue Apr 19, 2026
Merged via the queue into rust-lang:master with commit d7a8bb0 Apr 19, 2026
18 checks passed
@ChayimFriedman2 ChayimFriedman2 deleted the prefer-underscore-import branch April 19, 2026 13:37
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 19, 2026
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.

3 participants