Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 41a7534

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

File tree

Expand file treeCollapse file tree

3 files changed

+41
-2
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+41
-2
lines changed

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

Copy file name to clipboardExpand all lines: tests/ui/lint/unused/closure-body-issue-136741.fixed
+9Lines changed: 9 additions & 0 deletions
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

Copy file name to clipboardExpand all lines: tests/ui/lint/unused/closure-body-issue-136741.rs
+11Lines changed: 11 additions & 0 deletions
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

Copy file name to clipboardExpand all lines: tests/ui/lint/unused/closure-body-issue-136741.stderr
+21-2Lines changed: 21 additions & 2 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.