Closed
Description
I'm sure that there is a more concise way to generate this error, but this produces a dead_code
lint warning:
#![deny(warnings)]
use std::mem;
#[derive(Default)]
struct Y {}
enum X {
A { y: Y },
B { y: Y },
}
impl X {
fn test(&mut self) {
if let Self::A { y } = self {
*self = Self::B { y: mem::take(y) };
}
}
}
pub fn main() {
let mut x = X::A { y: Y {} };
x.test();
}
This code instantiates X::B
, but the dead_code
lint disagrees:
Compiling playground v0.0.1 (/playground)
error: variant is never constructed: `B`
--> src/main.rs:9:5
|
9 | B { y: Y },
| ^^^^^^^^^^
|
note: lint level defined here
--> src/main.rs:1:9
|
1 | #![deny(warnings)]
| ^^^^^^^^
= note: `#[deny(dead_code)]` implied by `#[deny(warnings)]`