Deduplication of module/enum self on imports
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
mod foo {
mod bar {}
}
enum Foo {
Bar,
}
use Foo;
use Foo::{self};
use foo;
use foo::{self};
use foo::{
bar,
bar::{self},
};
The compiler doesn't like the above for obvious reasons ("foo", "foo::bar", and "Foo" are each imported twice). But the formatter doesn't recognize them as being the same import.
I ran into this using my usual merge conflict resolution process for imports: accept all that let the compiler tell me which ones aren't needed any more. That process normally leads to warnings, not errors, but this is an error condition.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running rustfmt on the Rust snippet in the issue and confirm that self imports are not treated as duplicates. Trace the formatter's import-handling entry point, then add a regression case covering Foo, foo, and foo::bar self imports. Done means the formatter handles these equivalent imports without producing output that leaves duplicate imports.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100