UI test for deprecation warning of casting enum implementing Drop

This commit is contained in:
oddg 2020-06-14 15:49:20 -07:00
parent d5ea0e9f8d
commit a40156e5b7
2 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,18 @@
#![deny(cenum_impl_drop_cast)]
enum E {
A = 0,
}
impl Drop for E {
fn drop(&mut self) {
println!("Drop");
}
}
fn main() {
let e = E::A;
let i = e as u32;
//~^ ERROR Cast `enum` implementing `Drop` `E` to integer `u32`
//~| WARN this was previously accepted
}

View File

@ -0,0 +1,16 @@
error: Cast `enum` implementing `Drop` `E` to integer `u32`
--> $DIR/cenum_impl_drop_cast.rs:15:13
|
LL | let i = e as u32;
| ^^^^^^^^
|
note: the lint level is defined here
--> $DIR/cenum_impl_drop_cast.rs:1:9
|
LL | #![deny(cenum_impl_drop_cast)]
| ^^^^^^^^^^^^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #73333 <https://github.com/rust-lang/rust/issues/73333>
error: aborting due to previous error