Closed
Description
A "variant is never used" lint is incorrectly triggered, presumably due to optimizations on MIR. I know my code sample looks pretty stupid as no human would write this, probably. But this kind of code might be generated. Anyway, the lint is incorrect I'd say.
I tried this code:
enum Baz {
Foo,
Bar,
}
fn main() {
let x = Baz::Foo;
match x {
Baz::Foo => {},
Baz::Bar if true => {},
_ => {}
}
}
I expected to see this happen: no warning
Instead, this happened:
warning: variant is never used: `Bar`
--> src/main.rs:3:5
|
3 | Bar,
| ^^^
|
= note: #[warn(dead_code)] on by default
Meta
Happens with
- 1.19 stable,
- 1.20 beta,
- 1.21 nightly
Metadata
Metadata
Assignees
Labels
No labels