Improve E0603 suggestions for private grouped imports - #158445
Improve E0603 suggestions for private grouped imports#158445raushan728 wants to merge 2 commits into
E0603 suggestions for private grouped imports#158445Conversation
|
r? @jackh726 rustbot has assigned @jackh726. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
I reviewed everything except the r? @fee1-dead please review, since you wanted this. |
|
|
| use_stmt_span: if path_span != root_span { | ||
| // `root_span` spans the entire `use` tree, which is needed | ||
| // to correctly generate a multipart suggestion for a grouped import. | ||
| Some(root_span) | ||
| } else { | ||
| None | ||
| }, |
There was a problem hiding this comment.
what is the significance of using an Option here?
There was a problem hiding this comment.
Added a doc comment explaining that the span is only needed (and set) when single_nested is true, so Option avoids carrying meaningless data for non grouped imports.
There was a problem hiding this comment.
Sorry for the confusion. I've reworked this by storing root_span directly in PrivacyError and deriving the nested import check where it's used instead of carrying the extra state. I think this better matches what you were suggesting.
|
Reminder, once the PR becomes ready for a review, use |
59ad765 to
4706b08
Compare
This comment has been minimized.
This comment has been minimized.
|
@rustbot ready |
This comment has been minimized.
This comment has been minimized.
4706b08 to
12d8c86
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Suggest direct imports for private items inside grouped imports. Split grouped imports when necessary and replace single-item groups with direct imports.
12d8c86 to
567fb3a
Compare
|
This PR was rebased onto a different main 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. |
E0603 suggestions for private grouped imports
I've cleaned this up to rely on the standard string search APIs ( |
View all comments
After PR #156244 removed broken suggestions for nested imports, E0603 was left without any suggestion. This restores helpful suggestions for grouped use statements.
For
use crate::two::{One, Two}with a privateOne:Single item groups get a direct replacement. Braces are removed when one item remains. Re-export chains are handled.
Fixes #157453.
r? @petrochenkov