Skip to content

Commit 11ece8c

Browse files
goffriedavidBar-On
authored andcommitted
Improve documentation for imports_merge_style
1 parent 5864cec commit 11ece8c

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

Configurations.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -1709,14 +1709,14 @@ pub enum Foo {}
17091709

17101710
Merge together related imports based on their paths.
17111711

1712-
This option requires `reorder_imports`, which is enabled by default.
1713-
17141712
- **Default value**: `Preserve`
17151713
- **Possible values**: `Preserve`, `Crate`, `Module`
1716-
- **Stable**: No (tracking issue: [#3362](https://github.com/rust-lang/rustfmt/issues/3362))
1714+
- **Stable**: No
17171715

17181716
#### `Preserve` (default):
17191717

1718+
Do not perform any merging and preserve the original structure written by the developer.
1719+
17201720
```rust
17211721
use foo::b;
17221722
use foo::b::{f, g};
@@ -1726,6 +1726,8 @@ use qux::{h, i};
17261726

17271727
#### `Crate`:
17281728

1729+
Merge imports from the same crate into a single `use` statement. Conversely, imports from different crates are split into separate statements.
1730+
17291731
```rust
17301732
use foo::{
17311733
a, b,
@@ -1738,6 +1740,8 @@ use qux::{h, i};
17381740

17391741
#### `Module`:
17401742

1743+
Merge imports from the same module into a single `use` statement. Conversely, imports from different modules are split into separate statements.
1744+
17411745
```rust
17421746
use foo::b::{f, g};
17431747
use foo::d::e;

tests/source/imports_merge_style_crate.rs

+3
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@ use g::{self, b};
3232
use h::{a};
3333
use i::a::{self};
3434
use j::{a::{self}};
35+
36+
use {k::{a, b}, l::{a, b}};
37+
use {k::{c, d}, l::{c, d}};

tests/target/imports_merge_style_crate.rs

+3
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,6 @@ use g::{self, a, b};
2323
use h::a;
2424
use i::a::{self};
2525
use j::a::{self};
26+
27+
use k::{a, b, c, d};
28+
use l::{a, b, c, d};

0 commit comments

Comments
 (0)