UI test for deprecation warning of casting enum implementing Drop
This commit is contained in:
parent
d5ea0e9f8d
commit
a40156e5b7
18
src/test/ui/cenum_impl_drop_cast.rs
Normal file
18
src/test/ui/cenum_impl_drop_cast.rs
Normal 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
|
||||||
|
}
|
16
src/test/ui/cenum_impl_drop_cast.stderr
Normal file
16
src/test/ui/cenum_impl_drop_cast.stderr
Normal 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
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user