Closed
Description
Code
#![allow(dead_code)]
enum State {
Waiting { start_at: u64 }
}
fn main() {
match (&mut State::Waiting { start_at: 0u64 }) {
_ => {}
}
}
Current output
warning: unnecessary parentheses around `match` scrutinee expression
--> src/main.rs:8:11
|
8 | match (&mut State::Waiting { start_at: 0u64 }) {
| ^ ^
|
= note: `#[warn(unused_parens)]` on by default
help: remove these parentheses
|
8 - match (&mut State::Waiting { start_at: 0u64 }) {
8 + match &mut State::Waiting { start_at: 0u64 } {
|
Desired output
No `unused_parens` warning.
Rationale and extra context
The unused_parens
lint should not fire in this case because the parentheses are actually necessary. Otherwise, following the help to "remove these parentheses" will cause a compilation error.
error: struct literals are not allowed here
--> src/main.rs:8:16
|
8 | match &mut State::Waiting { start_at: 0u64 } {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: surround the struct literal with parentheses
|
8 | match &mut (State::Waiting { start_at: 0u64 }) {
| + +
Although, following help from the error after applying the suggestion from the unused_parens
lint does lead to valid code.
Other cases
No response
Anything else?
No response