File tree Expand file tree Collapse file tree 3 files changed +41
-2
lines changed Expand file tree Collapse file tree 3 files changed +41
-2
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -56,8 +56,27 @@ LL - let _ = (0..).find(|n| {n % 2 == 0});
5656LL + 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+
5978error: 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 |
6281LL | (0 == 0)
6382 | ^ ^
@@ -68,5 +87,5 @@ LL - (0 == 0)
6887LL + 0 == 0
6988 |
7089
71- error: aborting due to 5 previous errors
90+ error: aborting due to 6 previous errors
7291
You can’t perform that action at this time.
0 commit comments