rust-clippy/tests/ui/cast_enum_constructor.rs

21 lines
492 B
Rust
Raw Normal View History

2022-03-17 20:04:45 +00:00
#![warn(clippy::cast_enum_constructor)]
#![allow(clippy::fn_to_numeric_cast)]
fn main() {
enum Foo {
Y(u32),
}
enum Bar {
X,
}
let _ = Foo::Y as usize;
//~^ ERROR: cast of an enum tuple constructor to an integer
//~| NOTE: `-D clippy::cast-enum-constructor` implied by `-D warnings`
2022-03-17 20:04:45 +00:00
let _ = Foo::Y as isize;
//~^ ERROR: cast of an enum tuple constructor to an integer
2022-03-17 20:04:45 +00:00
let _ = Foo::Y as fn(u32) -> Foo;
let _ = Bar::X as usize;
}