mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-13 18:37:33 +00:00

This changes the `cenum_impl_drop_cast` lint to be a hard error. This lint has been deny-by-default and warning in dependencies since https://github.com/rust-lang/rust/pull/97652 about 2.5 years ago. Closes https://github.com/rust-lang/rust/issues/73333
81 lines
1.1 KiB
Rust
81 lines
1.1 KiB
Rust
// skip-filecheck
|
|
// EMIT_MIR enum_cast.foo.built.after.mir
|
|
// EMIT_MIR enum_cast.bar.built.after.mir
|
|
// EMIT_MIR enum_cast.boo.built.after.mir
|
|
// EMIT_MIR enum_cast.far.built.after.mir
|
|
|
|
enum Foo {
|
|
A,
|
|
}
|
|
|
|
enum Bar {
|
|
A,
|
|
B,
|
|
}
|
|
|
|
#[repr(u8)]
|
|
enum Boo {
|
|
A,
|
|
B,
|
|
}
|
|
|
|
#[repr(i16)]
|
|
enum Far {
|
|
A,
|
|
B,
|
|
}
|
|
|
|
fn foo(foo: Foo) -> usize {
|
|
foo as usize
|
|
}
|
|
|
|
fn bar(bar: Bar) -> usize {
|
|
bar as usize
|
|
}
|
|
|
|
fn boo(boo: Boo) -> usize {
|
|
boo as usize
|
|
}
|
|
|
|
fn far(far: Far) -> isize {
|
|
far as isize
|
|
}
|
|
|
|
#[repr(i16)]
|
|
enum SignedAroundZero {
|
|
A = -2,
|
|
B = 0,
|
|
C = 2,
|
|
}
|
|
|
|
#[repr(u16)]
|
|
enum UnsignedAroundZero {
|
|
A = 65535,
|
|
B = 0,
|
|
C = 1,
|
|
}
|
|
|
|
// EMIT_MIR enum_cast.signy.built.after.mir
|
|
fn signy(x: SignedAroundZero) -> i16 {
|
|
x as i16
|
|
}
|
|
|
|
// EMIT_MIR enum_cast.unsigny.built.after.mir
|
|
fn unsigny(x: UnsignedAroundZero) -> u16 {
|
|
// FIXME: This doesn't get an around-the-end range today, sadly.
|
|
x as u16
|
|
}
|
|
|
|
enum NotStartingAtZero {
|
|
A = 4,
|
|
B = 6,
|
|
C = 8,
|
|
}
|
|
|
|
// EMIT_MIR enum_cast.offsetty.built.after.mir
|
|
fn offsetty(x: NotStartingAtZero) -> u32 {
|
|
x as u32
|
|
}
|
|
|
|
fn main() {}
|