-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add checking for unnecessary delims in closure body
- Loading branch information
1 parent
3a34ad7
commit 9ec13a6
Showing
16 changed files
with
124 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,3 @@ | |
//@ pp-exact | ||
|
||
fn main() { let _a = (async { }); } | ||
//~^ WARNING unnecessary parentheses around assigned value |
15 changes: 0 additions & 15 deletions
15
tests/ui/async-await/issues/issue-54752-async-block.stderr
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//@ run-rustfix | ||
#![deny(unused_parens)] | ||
#![deny(unused_braces)] | ||
pub fn main() { | ||
let _closure = |x: i32, y: i32| x * (x + (y * 2)); //~ ERROR unnecessary braces around closure body | ||
let _ = || 0 == 0; //~ ERROR unnecessary parentheses around closure body | ||
let _ = (0..).find(|n| n % 2 == 0); //~ ERROR unnecessary parentheses around closure body | ||
let _ = (0..).find(|n| n % 2 == 0); //~ ERROR unnecessary braces around closure body | ||
let _ = || { | ||
_ = 0; | ||
0 == 0 //~ ERROR unnecessary parentheses around block return value | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//@ run-rustfix | ||
#![deny(unused_parens)] | ||
#![deny(unused_braces)] | ||
pub fn main() { | ||
let _closure = |x: i32, y: i32| { x * (x + (y * 2)) }; //~ ERROR unnecessary braces around closure body | ||
let _ = || (0 == 0); //~ ERROR unnecessary parentheses around closure body | ||
let _ = (0..).find(|n| (n % 2 == 0)); //~ ERROR unnecessary parentheses around closure body | ||
let _ = (0..).find(|n| {n % 2 == 0}); //~ ERROR unnecessary braces around closure body | ||
let _ = || { | ||
_ = 0; | ||
(0 == 0) //~ ERROR unnecessary parentheses around block return value | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
error: unnecessary braces around closure body | ||
--> $DIR/closure-body-issue-136741.rs:5:37 | ||
| | ||
LL | let _closure = |x: i32, y: i32| { x * (x + (y * 2)) }; | ||
| ^^ ^^ | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/closure-body-issue-136741.rs:3:9 | ||
| | ||
LL | #![deny(unused_braces)] | ||
| ^^^^^^^^^^^^^ | ||
help: remove these braces | ||
| | ||
LL - let _closure = |x: i32, y: i32| { x * (x + (y * 2)) }; | ||
LL + let _closure = |x: i32, y: i32| x * (x + (y * 2)); | ||
| | ||
|
||
error: unnecessary parentheses around closure body | ||
--> $DIR/closure-body-issue-136741.rs:6:16 | ||
| | ||
LL | let _ = || (0 == 0); | ||
| ^ ^ | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/closure-body-issue-136741.rs:2:9 | ||
| | ||
LL | #![deny(unused_parens)] | ||
| ^^^^^^^^^^^^^ | ||
help: remove these parentheses | ||
| | ||
LL - let _ = || (0 == 0); | ||
LL + let _ = || 0 == 0; | ||
| | ||
|
||
error: unnecessary parentheses around closure body | ||
--> $DIR/closure-body-issue-136741.rs:7:28 | ||
| | ||
LL | let _ = (0..).find(|n| (n % 2 == 0)); | ||
| ^ ^ | ||
| | ||
help: remove these parentheses | ||
| | ||
LL - let _ = (0..).find(|n| (n % 2 == 0)); | ||
LL + let _ = (0..).find(|n| n % 2 == 0); | ||
| | ||
|
||
error: unnecessary braces around closure body | ||
--> $DIR/closure-body-issue-136741.rs:8:28 | ||
| | ||
LL | let _ = (0..).find(|n| {n % 2 == 0}); | ||
| ^ ^ | ||
| | ||
help: remove these braces | ||
| | ||
LL - let _ = (0..).find(|n| {n % 2 == 0}); | ||
LL + let _ = (0..).find(|n| n % 2 == 0); | ||
| | ||
|
||
error: unnecessary parentheses around block return value | ||
--> $DIR/closure-body-issue-136741.rs:11:9 | ||
| | ||
LL | (0 == 0) | ||
| ^ ^ | ||
| | ||
help: remove these parentheses | ||
| | ||
LL - (0 == 0) | ||
LL + 0 == 0 | ||
| | ||
|
||
error: aborting due to 5 previous errors | ||
|