about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan MacKenzie <ecstaticmorse@gmail.com>2021-12-01 10:04:21 -0800
committerDylan MacKenzie <ecstaticmorse@gmail.com>2021-12-01 10:04:21 -0800
commit37fa92552586a9f91fefd92518b66dfde4c64771 (patch)
tree30840a1645d2f4343788f5964c073427a1ed63bd
parent9aaca1d38ea3218b7f5030bd486cbbdf8917985b (diff)
downloadrust-37fa92552586a9f91fefd92518b66dfde4c64771.tar.gz
rust-37fa92552586a9f91fefd92518b66dfde4c64771.zip
Add regression test for #90770
-rw-r--r--src/test/ui/consts/drop_zst.rs17
-rw-r--r--src/test/ui/consts/drop_zst.stderr9
2 files changed, 26 insertions, 0 deletions
diff --git a/src/test/ui/consts/drop_zst.rs b/src/test/ui/consts/drop_zst.rs
new file mode 100644
index 00000000000..f7c70d3978b
--- /dev/null
+++ b/src/test/ui/consts/drop_zst.rs
@@ -0,0 +1,17 @@
+// check-fail
+
+#![feature(const_precise_live_drops)]
+
+struct S;
+
+impl Drop for S {
+    fn drop(&mut self) {
+        println!("Hello!");
+    }
+}
+
+const fn foo() {
+    let s = S; //~ destructor
+}
+
+fn main() {}
diff --git a/src/test/ui/consts/drop_zst.stderr b/src/test/ui/consts/drop_zst.stderr
new file mode 100644
index 00000000000..d4be5aa56d9
--- /dev/null
+++ b/src/test/ui/consts/drop_zst.stderr
@@ -0,0 +1,9 @@
+error[E0493]: destructors cannot be evaluated at compile-time
+  --> $DIR/drop_zst.rs:14:9
+   |
+LL |     let s = S;
+   |         ^ constant functions cannot evaluate destructors
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0493`.