`group_imports` does not differentiate between a local import and an external crate
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
Describe the bug
rustfmt does not differentiate between local imports not prefixed by self:: and external crates. The behavior is as expected when prefixed by self::.
To Reproduce
Using group_imports = "StdExternalCrate" in rustfmt.toml, the following code is considered formatted.
mod foo {
struct Foo;
}
use foo::Foo;
use rand::random;
Expected behavior
rustfmt recognizes that foo is a local module, not an external crate.
mod foo {
struct Foo;
}
use rand::random;
use foo::Foo;
Meta
- rustfmt version: rustfmt 1.4.30-stable (8c6769d 2021-01-18)
- From where did you install rustfmt?: rustup
- How do you run rustfmt:
cargo fmt
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
No source file or test is named. Reproduce the behavior with group_imports = "StdExternalCrate" and the provided module and imports, then trace rustfmt's import-grouping logic. Done means local imports without self:: are separated from external-crate imports, with coverage for the shown example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100