rustfmt
rustfmt copied to clipboard
Don't merge crates when `imports_granularity="Module"`
When merging imports using imports_granularity="Module", individual crate imports should get their own use statement on a new line.
// Before this commit:
use {library1, library2 as lib2, library3};
// After this commit:
use library1;
use library2 as lib2;
use library3;
Fixes: #6191
I haven't really reviewed this, but I quickly tested out this branch on this input:
use library1;
use library1::one;
use library1::two;
use library2 as lib2;
use library3;
which produced this output:
use library1;
use library1::{one, two};
use library2 as lib2;
use library3;
It seems reasonable to me, but I'm wondering if it would be expected to produce the following instead:
use library1::{self, one, two};
use library2 as lib2;
use library3;
Thanks for trying it out!
but I'm wondering if it would be expected to produce the following instead
I personally would also prefer the second output rather than the first, but I think this is out of scope for this PR because I think aliasing module to module::self is a separate issue -- there's some discussion in https://github.com/rust-lang/rustfmt/pull/6028#issuecomment-1894143286 which suggests that use library1 and use library1::{self} are semantically different, and that we shouldn't convert between the two forms
Hi, hoping we could bump this.