Skip to content

Commit 41a7534

Browse files
committed
add testcaes for multiple lines of braces
1 parent 2e2f770 commit 41a7534

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

tests/ui/lint/unused/closure-body-issue-136741.fixed

+9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ pub fn main() {
66
let _ = || 0 == 0; //~ ERROR unnecessary parentheses around closure body
77
let _ = (0..).find(|n| n % 2 == 0); //~ ERROR unnecessary parentheses around closure body
88
let _ = (0..).find(|n| n % 2 == 0); //~ ERROR unnecessary braces around closure body
9+
10+
// multiple lines of code will not lint with braces
11+
let _ = (0..).find(|n| {
12+
n % 2 == 0
13+
});
14+
15+
// multiple lines of code will lint with parentheses
16+
let _ = (0..).find(|n| n % 2 == 0);
17+
918
let _ = || {
1019
_ = 0;
1120
0 == 0 //~ ERROR unnecessary parentheses around block return value

tests/ui/lint/unused/closure-body-issue-136741.rs

+11
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ pub fn main() {
66
let _ = || (0 == 0); //~ ERROR unnecessary parentheses around closure body
77
let _ = (0..).find(|n| (n % 2 == 0)); //~ ERROR unnecessary parentheses around closure body
88
let _ = (0..).find(|n| {n % 2 == 0}); //~ ERROR unnecessary braces around closure body
9+
10+
// multiple lines of code will not lint with braces
11+
let _ = (0..).find(|n| {
12+
n % 2 == 0
13+
});
14+
15+
// multiple lines of code will lint with parentheses
16+
let _ = (0..).find(|n| ( //~ ERROR unnecessary parentheses around closure body
17+
n % 2 == 0
18+
));
19+
920
let _ = || {
1021
_ = 0;
1122
(0 == 0) //~ ERROR unnecessary parentheses around block return value

tests/ui/lint/unused/closure-body-issue-136741.stderr

+21-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,27 @@ LL - let _ = (0..).find(|n| {n % 2 == 0});
5656
LL + let _ = (0..).find(|n| n % 2 == 0);
5757
|
5858

59+
error: unnecessary parentheses around closure body
60+
--> $DIR/closure-body-issue-136741.rs:16:28
61+
|
62+
LL | let _ = (0..).find(|n| (
63+
| _____________________________^
64+
LL | | n % 2 == 0
65+
| | ________^__________^
66+
| ||________|
67+
| |
68+
LL | | ));
69+
| |_____^
70+
|
71+
help: remove these parentheses
72+
|
73+
LL - let _ = (0..).find(|n| (
74+
LL - n % 2 == 0
75+
LL + let _ = (0..).find(|n| n % 2 == 0);
76+
|
77+
5978
error: unnecessary parentheses around block return value
60-
--> $DIR/closure-body-issue-136741.rs:11:9
79+
--> $DIR/closure-body-issue-136741.rs:22:9
6180
|
6281
LL | (0 == 0)
6382
| ^ ^
@@ -68,5 +87,5 @@ LL - (0 == 0)
6887
LL + 0 == 0
6988
|
7089

71-
error: aborting due to 5 previous errors
90+
error: aborting due to 6 previous errors
7291

0 commit comments

Comments
 (0)