bug: imports_granularity = "One" deletes aliases
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
I would like to open issue #5131 again with:
Modified https://github.com/rust-lang/rustfmt/blob/master/tests/source/5131_one.rs:
// rustfmt-imports_granularity: One
pub use foo::x;
pub use foo::x as x2;
pub use foo::y;
use bar::a;
use bar::b;
use bar::b::f;
use bar::b::f as f2;
use bar::b::g;
use bar::c;
use bar::d::e;
use bar::d::e as e2;
use qux::h;
use qux::i;
use qux::i as j; // added this alias
And modified https://github.com/rust-lang/rustfmt/blob/master/tests/target/5131_one.rs:
// rustfmt-imports_granularity: One
pub use foo::{x, x as x2, y};
use {
bar::{
a,
b::{self, f, g},
c,
d::{e, e as e2},
},
qux::{h, i, i as j}, // expected, but fails
};
I tested this with rev 6356fca675bd756d71f5c123cd053d17b16c573e. I assume, this (prefix == 0 && a.equal_except_alias(b)) || a == b needs some adjustment.
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 with tests/source/5131_one.rs and tests/target/5131_one.rs, using the modified reproducer in the issue to inspect imports_granularity = "One" handling. Trace the grouping logic around the reported (prefix == 0 && a.equal_except_alias(b)) || a == b condition. Done means the qux alias is preserved in the formatted output and the relevant rustfmt test passes.
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
- Clearly specified
- Newbie friendliness
- 48/100