about summary refs log tree commit diff
diff options
context:
space:
mode:
authoroddg <odegevigney@gmail.com>2020-06-14 15:49:20 -0700
committeroddg <odegevigney@gmail.com>2020-06-14 15:49:20 -0700
commita40156e5b7053dcc36ba1ad65fb567b183c4e1fb (patch)
tree06d1605a2deee0a23c799f35a755b274c21dd3a7
parentd5ea0e9f8def9a3ec0eb2dd88f0465d4d1a81c21 (diff)
downloadrust-a40156e5b7053dcc36ba1ad65fb567b183c4e1fb.tar.gz
rust-a40156e5b7053dcc36ba1ad65fb567b183c4e1fb.zip
UI test for deprecation warning of casting enum implementing Drop
-rw-r--r--src/test/ui/cenum_impl_drop_cast.rs18
-rw-r--r--src/test/ui/cenum_impl_drop_cast.stderr16
2 files changed, 34 insertions, 0 deletions
diff --git a/src/test/ui/cenum_impl_drop_cast.rs b/src/test/ui/cenum_impl_drop_cast.rs
new file mode 100644
index 00000000000..623460673bf
--- /dev/null
+++ b/src/test/ui/cenum_impl_drop_cast.rs
@@ -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
+}
diff --git a/src/test/ui/cenum_impl_drop_cast.stderr b/src/test/ui/cenum_impl_drop_cast.stderr
new file mode 100644
index 00000000000..5c8f86ffd72
--- /dev/null
+++ b/src/test/ui/cenum_impl_drop_cast.stderr
@@ -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
+