Skip to content

Commit a40156e

Browse files
committed
UI test for deprecation warning of casting enum implementing Drop
1 parent d5ea0e9 commit a40156e

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

src/test/ui/cenum_impl_drop_cast.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#![deny(cenum_impl_drop_cast)]
2+
3+
enum E {
4+
A = 0,
5+
}
6+
7+
impl Drop for E {
8+
fn drop(&mut self) {
9+
println!("Drop");
10+
}
11+
}
12+
13+
fn main() {
14+
let e = E::A;
15+
let i = e as u32;
16+
//~^ ERROR Cast `enum` implementing `Drop` `E` to integer `u32`
17+
//~| WARN this was previously accepted
18+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error: Cast `enum` implementing `Drop` `E` to integer `u32`
2+
--> $DIR/cenum_impl_drop_cast.rs:15:13
3+
|
4+
LL | let i = e as u32;
5+
| ^^^^^^^^
6+
|
7+
note: the lint level is defined here
8+
--> $DIR/cenum_impl_drop_cast.rs:1:9
9+
|
10+
LL | #![deny(cenum_impl_drop_cast)]
11+
| ^^^^^^^^^^^^^^^^^^^^
12+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
13+
= note: for more information, see issue #73333 <https://github.com/rust-lang/rust/issues/73333>
14+
15+
error: aborting due to previous error
16+

0 commit comments

Comments
 (0)