Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//@ revisions: current next
//@ ignore-compare-mode-next-solver (explicit revisions)
//@[next] compile-flags: -Znext-solver
//@ check-pass
//@ edition: 2018
//@ run-rustfix
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
warning: unnecessary parentheses around function argument
--> $DIR/try-block-unused-delims.rs:11:13
--> $DIR/try-block-unused-delims.rs:14:13
|
LL | consume((try {}));
| ^ ^
|
note: the lint level is defined here
--> $DIR/try-block-unused-delims.rs:6:9
--> $DIR/try-block-unused-delims.rs:9:9
|
LL | #![warn(unused_parens, unused_braces)]
| ^^^^^^^^^^^^^
Expand All @@ -16,13 +16,13 @@ LL + consume(try {});
|

warning: unnecessary braces around function argument
--> $DIR/try-block-unused-delims.rs:14:13
--> $DIR/try-block-unused-delims.rs:17:13
|
LL | consume({ try {} });
| ^^ ^^
|
note: the lint level is defined here
--> $DIR/try-block-unused-delims.rs:6:24
--> $DIR/try-block-unused-delims.rs:9:24
|
LL | #![warn(unused_parens, unused_braces)]
| ^^^^^^^^^^^^^
Expand All @@ -33,7 +33,7 @@ LL + consume(try {});
|

warning: unnecessary parentheses around `match` scrutinee expression
--> $DIR/try-block-unused-delims.rs:17:11
--> $DIR/try-block-unused-delims.rs:20:11
|
LL | match (try {}) {
| ^ ^
Expand All @@ -45,7 +45,7 @@ LL + match try {} {
|

warning: unnecessary parentheses around `let` scrutinee expression
--> $DIR/try-block-unused-delims.rs:22:22
--> $DIR/try-block-unused-delims.rs:25:22
|
LL | if let Err(()) = (try {}) {}
| ^ ^
Expand All @@ -57,7 +57,7 @@ LL + if let Err(()) = try {} {}
|

warning: unnecessary parentheses around `match` scrutinee expression
--> $DIR/try-block-unused-delims.rs:25:11
--> $DIR/try-block-unused-delims.rs:28:11
|
LL | match (try {}) {
| ^ ^
Expand Down
32 changes: 32 additions & 0 deletions tests/ui/try-block/try-block-unused-delims.next.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//@ revisions: current next
//@ ignore-compare-mode-next-solver (explicit revisions)
//@[next] compile-flags: -Znext-solver
//@ check-pass
//@ edition: 2018
//@ run-rustfix

#![feature(try_blocks)]
#![warn(unused_parens, unused_braces)]

fn consume<T>(_: Result<T, T>) -> T { todo!() }

fn main() {
consume(try {});
//~^ WARN unnecessary parentheses

consume(try {});
//~^ WARN unnecessary braces

match try {} {
//~^ WARN unnecessary parentheses
Ok(()) | Err(()) => (),
}

if let Err(()) = try {} {}
//~^ WARN unnecessary parentheses

match try {} {
//~^ WARN unnecessary parentheses
Ok(()) | Err(()) => (),
}
}
72 changes: 72 additions & 0 deletions tests/ui/try-block/try-block-unused-delims.next.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
warning: unnecessary parentheses around function argument
--> $DIR/try-block-unused-delims.rs:14:13
|
LL | consume((try {}));
| ^ ^
|
note: the lint level is defined here
--> $DIR/try-block-unused-delims.rs:9:9
|
LL | #![warn(unused_parens, unused_braces)]
| ^^^^^^^^^^^^^
help: remove these parentheses
|
LL - consume((try {}));
LL + consume(try {});
|

warning: unnecessary braces around function argument
--> $DIR/try-block-unused-delims.rs:17:13
|
LL | consume({ try {} });
| ^^ ^^
|
note: the lint level is defined here
--> $DIR/try-block-unused-delims.rs:9:24
|
LL | #![warn(unused_parens, unused_braces)]
| ^^^^^^^^^^^^^
help: remove these braces
|
LL - consume({ try {} });
LL + consume(try {});
|

warning: unnecessary parentheses around `match` scrutinee expression
--> $DIR/try-block-unused-delims.rs:20:11
|
LL | match (try {}) {
| ^ ^
|
help: remove these parentheses
|
LL - match (try {}) {
LL + match try {} {
|

warning: unnecessary parentheses around `let` scrutinee expression
--> $DIR/try-block-unused-delims.rs:25:22
|
LL | if let Err(()) = (try {}) {}
| ^ ^
|
help: remove these parentheses
|
LL - if let Err(()) = (try {}) {}
LL + if let Err(()) = try {} {}
|

warning: unnecessary parentheses around `match` scrutinee expression
--> $DIR/try-block-unused-delims.rs:28:11
|
LL | match (try {}) {
| ^ ^
|
help: remove these parentheses
|
LL - match (try {}) {
LL + match try {} {
|

warning: 5 warnings emitted

3 changes: 3 additions & 0 deletions tests/ui/try-block/try-block-unused-delims.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//@ revisions: current next
//@ ignore-compare-mode-next-solver (explicit revisions)
//@[next] compile-flags: -Znext-solver
//@ check-pass
//@ edition: 2018
//@ run-rustfix
Expand Down
Loading