Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 181ca42

Browse files
committed
Use the same rule with macro and function calls with a single chain
1 parent 5df0a18 commit 181ca42

File tree

5 files changed

+69
-0
lines changed

5 files changed

+69
-0
lines changed

src/overflow.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,13 @@ impl<'a> Context<'a> {
467467
{
468468
self.context.force_one_line_chain.replace(true);
469469
}
470+
Some(OverflowableItem::MacroArg(MacroArg::Expr(expr)))
471+
if !combine_arg_with_callee
472+
&& is_method_call(expr)
473+
&& self.context.config.version() == Version::Two =>
474+
{
475+
self.context.force_one_line_chain.replace(true);
476+
}
470477
_ => (),
471478
}
472479
let result = last_item_shape(

tests/source/issue-3272/v1.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// rustfmt-version: One
2+
3+
fn main() {
4+
assert!(HAYSTACK
5+
.par_iter()
6+
.find_any(|&&x| x[0] % 1000 == 999)
7+
.is_some());
8+
9+
assert(
10+
HAYSTACK
11+
.par_iter()
12+
.find_any(|&&x| x[0] % 1000 == 999)
13+
.is_some(),
14+
);
15+
}

tests/source/issue-3272/v2.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// rustfmt-version: Two
2+
3+
fn main() {
4+
assert!(HAYSTACK
5+
.par_iter()
6+
.find_any(|&&x| x[0] % 1000 == 999)
7+
.is_some());
8+
9+
assert(
10+
HAYSTACK
11+
.par_iter()
12+
.find_any(|&&x| x[0] % 1000 == 999)
13+
.is_some(),
14+
);
15+
}

tests/target/issue-3272/v1.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// rustfmt-version: One
2+
3+
fn main() {
4+
assert!(HAYSTACK
5+
.par_iter()
6+
.find_any(|&&x| x[0] % 1000 == 999)
7+
.is_some());
8+
9+
assert(
10+
HAYSTACK
11+
.par_iter()
12+
.find_any(|&&x| x[0] % 1000 == 999)
13+
.is_some(),
14+
);
15+
}

tests/target/issue-3272/v2.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// rustfmt-version: Two
2+
3+
fn main() {
4+
assert!(
5+
HAYSTACK
6+
.par_iter()
7+
.find_any(|&&x| x[0] % 1000 == 999)
8+
.is_some()
9+
);
10+
11+
assert(
12+
HAYSTACK
13+
.par_iter()
14+
.find_any(|&&x| x[0] % 1000 == 999)
15+
.is_some(),
16+
);
17+
}

0 commit comments

Comments
 (0)