Tracking issue for unstable option: imports_layout
What's necessary to stabilize this?
There are some steps described in https://github.com/rust-lang/rustfmt/blob/master/Processes.md#stabilising-an-option.
https://github.com/rust-lang/rustfmt/pull/3581 is an attempt at this.
Why does Horizontal have to exceed max_width?
How does this behavior interact with merge_imports = true?
I think it should be possible to try to fit all import statements into max_width, replicating the path prefix for any spill-over items into the next line(s).
One good reason to prefer the Horizontal layout (and stabilize this setting after the behavioral aspects are ironed out) is to keep the imports searchable with grep-like tools that don't easily match across multiple lines.
A counter-argument for Vertical sorting is that it makes rebases significantly easier.
I recently had to do a rebase of a fairly complicated refactoring that moved lots of types around, and git rebase tools for in-line changes is not great.
I would like to use this feature in mozilla-central once it鈥檚 stablised.
I would love independent imports:
use foo::{
aaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbb, cccccccccccccccccc, dddddddddddddddddd,
eeeeeeeeeeeeeeeeee, ffffffffffffffffff,
};
=>
use foo::aaaaaaaaaaaaaaaaaa;
use foo::bbbbbbbbbbbbbbbbbb;
use foo::cccccccccccccccccc;
use foo::dddddddddddddddddd;
use foo::eeeeeeeeeeeeeeeeee;
use foo::ffffffffffffffffff;
As a possible alternative, I find this style super-friendly to git, immediately readable to my tastes, easy to play around with commenting-uncommenting.
Is it possible to have it as an independent alternative option?
I think "independent imports" (https://github.com/rust-lang/rustfmt/issues/3361#issuecomment-632661079) is outside of what this option is for, and is a discussion for https://github.com/rust-lang/rustfmt/issues/3362 instead. It's already been brought up there in https://github.com/rust-lang/rustfmt/issues/3362#issuecomment-641125438.
AIUI the two options are orthogonal and the distinction is as follows: you can think of merge_imports as determining the tokens of our imports i.e. how/whether they should be grouped i.e. which parts of which specific paths should go inside of the same curly braces; while imports_layout determines the whitespace of each import after the point that the tokens have already been decided.
Shouldn't "mixed' be called "compressed" to match other similar options?
Most helpful comment
I would love independent imports:
=>
As a possible alternative, I find this style super-friendly to git, immediately readable to my tastes, easy to play around with commenting-uncommenting.
Is it possible to have it as an
independentalternative option?