Skip to content

Commit 8c8676c

Browse files
committed
fix merge_mix
1 parent 36c49d7 commit 8c8676c

File tree

4 files changed

+29
-25
lines changed

4 files changed

+29
-25
lines changed

src/imports.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -693,19 +693,20 @@ fn rewrite_nested_use_tree(
693693
_ => false,
694694
})
695695
});
696-
let (tactic, remaining_width) = if has_nested_list {
697-
(DefinitiveListTactic::Vertical, 0)
696+
697+
let remaining_width = if has_nested_list {
698+
0
698699
} else {
699-
let remaining_width = shape.width.checked_sub(2).unwrap_or(0);
700-
let tactic = definitive_tactic(
701-
&list_items,
702-
context.config.imports_layout(),
703-
Separator::Comma,
704-
remaining_width,
705-
);
706-
(tactic, remaining_width)
700+
shape.width.checked_sub(2).unwrap_or(0)
707701
};
708702

703+
let tactic = definitive_tactic(
704+
&list_items,
705+
context.config.imports_layout(),
706+
Separator::Comma,
707+
remaining_width,
708+
);
709+
709710
let ends_with_newline = context.config.imports_indent() == IndentStyle::Block
710711
&& tactic != DefinitiveListTactic::Horizontal;
711712
let fmt = ListFormatting {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// rustfmt-imports_indent: Block
2+
// rustfmt-merge_imports: true
3+
// rustfmt-imports_layout: Mixed
4+
5+
use std::{fmt, io, str};
6+
use std::str::FromStr;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// rustfmt-imports_indent: Block
2+
// rustfmt-merge_imports: true
3+
// rustfmt-imports_layout: Mixed
4+
5+
use std::{
6+
fmt, io, str::{self, FromStr},
7+
};

tests/target/imports.rs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,30 +80,20 @@ use self::unix::{};
8080

8181
// nested imports
8282
use foo::{
83-
a,
84-
b,
83+
a, b,
8584
bar::{
86-
baz,
87-
foo::{a, b, cxxxxxxxxxxxxx, yyyyyyyyyyyyyy, zzzzzzzzzzzzzzzz},
88-
qux,
89-
xxxxxxxxxxx,
90-
yyyyyyyyyyyyy,
91-
zzzzzzzzzzzzzzzz,
85+
baz, foo::{a, b, cxxxxxxxxxxxxx, yyyyyyyyyyyyyy, zzzzzzzzzzzzzzzz}, qux, xxxxxxxxxxx,
86+
yyyyyyyyyyyyy, zzzzzzzzzzzzzzzz,
9287
},
93-
boo,
94-
c,
88+
boo, c,
9589
};
9690

9791
use fooo::{
9892
baar::foobar::{
9993
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy,
10094
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz,
10195
},
102-
bar,
103-
bar::*,
104-
x,
105-
y,
106-
z,
96+
bar, bar::*, x, y, z,
10797
};
10898

10999
// nested imports with a single sub-tree.

0 commit comments

Comments
 (0)