Repository navigation
Restore E0603 suggestions for private imports in grouped use - #165642
raushan728 wants to merge 6 commits into
Conversation
|
r? @davidtwco rustbot has assigned @davidtwco. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
Hi, can you please disclose LLM usage? Because from my perspective this code is slightly over commented, there is so much comments and they are all so detailed which is not a usual thing |
Yes, i used LLM. In the browser i used claude (sonnet) for my discussion. In my IDE i used free models for coding assistance. i don't have a fixed model there because the free model changed several times during the work
The PR is a bit large and has many test cases, so i added comments to explain the spans, the conditions and why some cases get no suggestion. If any of them are too detailed, i am happy to trim them In my earlier attempt (#158445), reviewers asked for explanations of the spans and conditions Also, the PR is split into small commits, so it may be easier to review commit by commit |
|
r? @mu001999 |
This comment has been minimized.
This comment has been minimized.
|
Have you found a dedicated LLM reviewer for this? |
nested is stored on ImportData rather than ImportKind::Single so that glob imports inside groups are also treated as nested.
When a private item is imported inside a group where it is the only
item of the root use-tree (e.g. `use a::{B};`, `use a::{b::{C}};`),
emit an in-place suggestion replacing the root use-tree with the
accessible path.
Single-item groups carrying renames (`use a::{B as C};`) or globs
(`use a::{m::*};`), as well as imports expanded from macros where the
root span cannot be used for suggestions, are skipped to prevent
dropping aliases, trailing glob wildcards, or proposing edits inside
macro definitions.
…in E0603
When a private item is imported inside a multi-item grouped import
statement (e.g. `use a::{B, C};` where `B` is private), emit a
multipart suggestion extracting `B` into its own standalone `use`
statement prepended before the root import and removing `B` from the
group.
Extraction is restricted to `use` items with inherited visibility and
empty attributes to avoid losing visibility or attributes, and
skipped for renames (`as Renamed`), globs (`::*`), and spans
originating from macro expansions where spans cannot be used for
suggestions.
28f35de to
102131e
Compare
|
No, I don't have a dedicated LLM reviewer. I do use LLMs as an assistant in all my PRs, including this one. I'm a student and I use them to learn the codebase and move faster. |
Fixes #157453.
For a single-item group like
use a::{B};, the wholeusetree is replaced with the path so no braces are left. for a multi item group likeuse a::{B, C};, the failing item is removed from the group and a newuse <path>is added above it. nested groups work the same way.Spans come from the AST only, with no source-text scanning. The span formula is factored out of
calc_unused_spansintonested_item_removal_span, with no behavior change.PrivacyError::single_nestedis replaced bynested Option<NestedImportRemoval>, stored onImportDataso globs inside groups are covered too.Braces are left as they are in the multi-item case (
use a::{Two};after extraction), to avoid span arithmetic. Removing them would need byte position arithmetic on the source. because it can cause ICEs with multibyte charactersrustfmtwill handle this.No suggestion is emitted for renames, globs, macro-expanded spans, or multi-item groups with
pubor attributes, since the replacement would drop them.AI assistance: Claude (browser) for discussion, free models in the IDE for coding help. I reviewed and tested all changes myself