-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #113679 - chenyukang:yukang-fix-lint-113459, r=cjgillot
Match scrutinee need necessary parentheses for structs Fixes #113459
- Loading branch information
Showing
3 changed files
with
68 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#![allow(dead_code)] | ||
#![deny(unused_parens)] | ||
|
||
enum State { | ||
Waiting { start_at: u64 } | ||
} | ||
struct Foo {} | ||
|
||
fn main() { | ||
let e = &mut State::Waiting { start_at: 0u64 }; | ||
match (&mut State::Waiting { start_at: 0u64 }) { | ||
_ => {} | ||
} | ||
|
||
match (e) { | ||
//~^ ERROR unnecessary parentheses around `match` scrutinee expression | ||
_ => {} | ||
} | ||
|
||
match &(State::Waiting { start_at: 0u64 }) { | ||
_ => {} | ||
} | ||
|
||
match (State::Waiting { start_at: 0u64 }) { | ||
_ => {} | ||
} | ||
|
||
match (&&Foo {}) { | ||
_ => {} | ||
} | ||
} |
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,19 @@ | ||
error: unnecessary parentheses around `match` scrutinee expression | ||
--> $DIR/lint-struct-necessary.rs:15:11 | ||
| | ||
LL | match (e) { | ||
| ^ ^ | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/lint-struct-necessary.rs:2:9 | ||
| | ||
LL | #![deny(unused_parens)] | ||
| ^^^^^^^^^^^^^ | ||
help: remove these parentheses | ||
| | ||
LL - match (e) { | ||
LL + match e { | ||
| | ||
|
||
error: aborting due to previous error | ||
|