Skip to content

Commit 9549c3b

Browse files
authored
fixed => () to => {} (#4226)
1 parent 5f536d6 commit 9549c3b

File tree

24 files changed

+90
-70
lines changed

24 files changed

+90
-70
lines changed

src/formatting/matches.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,12 +377,14 @@ fn rewrite_match_body(
377377
let comma = arm_comma(context.config, body, is_last);
378378
let alt_block_sep = &shape.indent.to_string_with_newline(context.config);
379379

380-
let combine_orig_body = |body_str: &str| {
380+
let combine_orig_body = |mut body_str: &str| {
381381
let block_sep = match context.config.control_brace_style() {
382382
ControlBraceStyle::AlwaysNextLine if is_block => alt_block_sep,
383383
_ => " ",
384384
};
385-
385+
if body_str == "()" {
386+
body_str = "{}";
387+
}
386388
Some(format!("{} =>{}{}{}", pats_str, block_sep, body_str, comma))
387389
};
388390

tests/source/catch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn main() {
1515
let y = match (try {
1616
foo()?
1717
}) {
18-
_ => (),
18+
_ => {},
1919
};
2020

2121
try {

tests/source/cfg_if/detect/os/linux/auxvec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ fn auxv_from_buf(buf: &[usize; 64]) -> Result<AuxVec, ()> {
159159
for el in buf.chunks(2) {
160160
match el[0] {
161161
AT_HWCAP => return Ok(AuxVec { hwcap: el[1] }),
162-
_ => (),
162+
_ => {}
163163
}
164164
}
165165
}
@@ -172,7 +172,7 @@ fn auxv_from_buf(buf: &[usize; 64]) -> Result<AuxVec, ()> {
172172
match el[0] {
173173
AT_HWCAP => hwcap = Some(el[1]),
174174
AT_HWCAP2 => hwcap2 = Some(el[1]),
175-
_ => (),
175+
_ => {}
176176
}
177177
}
178178

tests/source/chains-visual.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn main() {
1515
// Test case where first chain element isn't a path, but is shorter than
1616
// the size of a tab.
1717
x()
18-
.y(|| match cond() { true => (), false => () });
18+
.y(|| match cond() { true => {}, false => {}, });
1919

2020
loong_func()
2121
.quux(move || if true {

tests/source/chains.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fn main() {
1616
// Test case where first chain element isn't a path, but is shorter than
1717
// the size of a tab.
1818
x()
19-
.y(|| match cond() { true => (), false => () });
19+
.y(|| match cond() { true => {} false => {} });
2020

2121
loong_func()
2222
.quux(move || if true {

tests/source/hard-tabs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ fn generic<T>(arg: T) -> &SomeType
6666

6767
x().y(|| {
6868
match cond() {
69-
true => (),
70-
false => (),
69+
true => {},
70+
false => {},
7171
}
7272
});
7373
}

tests/source/issue-1021.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
// rustfmt-normalize_comments: true
22
fn main() {
33
match x {
4-
S(true , .., true ) => (),
5-
S(true , .. ) => (),
6-
S(.., true ) => (),
7-
S( .. ) => (),
8-
S(_) => (),
9-
S(/* .. */ .. ) => (),
10-
S(/* .. */ .., true ) => (),
4+
S(true , .., true ) => {},
5+
S(true , .. ) => {},
6+
S(.., true ) => {},
7+
S( .. ) => {},
8+
S(_) => {},
9+
S(/* .. */ .. ) => {},
10+
S(/* .. */ .., true ) => {},
1111
}
1212

1313
match y {
14-
(true , .., true ) => (),
15-
(true , .. ) => (),
16-
(.., true ) => (),
17-
( .. ) => (),
18-
(_,) => (),
19-
(/* .. */ .. ) => (),
20-
(/* .. */ .., true ) => (),
14+
(true , .., true ) => {},
15+
(true , .. ) => {},
16+
(.., true ) => {},
17+
( .. ) => {},
18+
(_,) => {},
19+
(/* .. */ .. ) => {},
20+
(/* .. */ .., true ) => {},
2121
}
2222
}

tests/source/issue-1211.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ fn main() {
66
Some(ip) => {
77
sock.send_to(&buf, (ip, 8765)).expect("foobar");
88
}
9-
_ => ()
9+
_ => {},
1010
}
1111
}
12-
_ => ()
12+
_ => {},
1313
};
1414
}
1515
}

tests/source/issue-2955.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// rustfmt-condense_wildcard_suffixes: true
22
fn main() {
33
match (1, 2, 3) {
4-
(_, _, _) => (),
4+
(_, _, _) => {},
55
}
66
}

tests/source/issue-4065.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// rustfmt-match_block_trailing_comma: true
2+
3+
fn main() {
4+
let x = 1;
5+
match x {
6+
1 => (),
7+
2 => (),
8+
}
9+
}

0 commit comments

Comments
 (0)