-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
This code should compile without warnings:
enum Enum {
Variant { field: usize }
}
impl Enum {
fn read_field(self) -> usize {
match self {
// Enum::Variant { field } => field
Self::Variant { field } => field
}
}
}
fn main() {
let e = Enum::Variant { field: 42 };
println!("{}", e.read_field());
}
However, it produces the following one:
warning: field is never used: `field`
--> src/main.rs:2:15
|
2 | Variant { field: usize }
| ^^^^^^^^^^^^
|
= note: `#[warn(dead_code)]` on by default
If we switch the pattern within match
to the one that's commented out, the warning is gone.
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.