File tree 3 files changed +41
-2
lines changed
3 files changed +41
-2
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,15 @@ pub fn main() {
6
6
let _ = || 0 == 0; //~ ERROR unnecessary parentheses around closure body
7
7
let _ = (0..).find(|n| n % 2 == 0); //~ ERROR unnecessary parentheses around closure body
8
8
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
+
9
18
let _ = || {
10
19
_ = 0;
11
20
0 == 0 //~ ERROR unnecessary parentheses around block return value
Original file line number Diff line number Diff line change @@ -6,6 +6,17 @@ pub fn main() {
6
6
let _ = || ( 0 == 0 ) ; //~ ERROR unnecessary parentheses around closure body
7
7
let _ = ( 0 ..) . find ( |n| ( n % 2 == 0 ) ) ; //~ ERROR unnecessary parentheses around closure body
8
8
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
+
9
20
let _ = || {
10
21
_ = 0 ;
11
22
( 0 == 0 ) //~ ERROR unnecessary parentheses around block return value
Original file line number Diff line number Diff line change @@ -56,8 +56,27 @@ LL - let _ = (0..).find(|n| {n % 2 == 0});
56
56
LL + let _ = (0..).find(|n| n % 2 == 0);
57
57
|
58
58
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
+
59
78
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
61
80
|
62
81
LL | (0 == 0)
63
82
| ^ ^
@@ -68,5 +87,5 @@ LL - (0 == 0)
68
87
LL + 0 == 0
69
88
|
70
89
71
- error: aborting due to 5 previous errors
90
+ error: aborting due to 6 previous errors
72
91
You can’t perform that action at this time.
0 commit comments