rust/tests/ui/tag-variant-cast-non-nullary.fixed

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

21 lines
435 B
Rust
Raw Normal View History

// run-rustfix
#![allow(dead_code, unused_variables)]
enum NonNullary {
Nullary,
Other(isize),
}
impl From<NonNullary> for isize {
fn from(val: NonNullary) -> isize {
match val {
NonNullary::Nullary => 0,
NonNullary::Other(i) => i,
}
}
}
fn main() {
let v = NonNullary::Nullary;
let val = isize::from(v); //~ ERROR non-primitive cast: `NonNullary` as `isize` [E0605]
}