Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UI test for deprecation warning of casting enum implementing Drop
- Loading branch information
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|