diff --git a/src/test/ui/consts/drop_zst.rs b/src/test/ui/consts/drop_zst.rs new file mode 100644 index 0000000000000..f7c70d3978b7f --- /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 0000000000000..d4be5aa56d9af --- /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`.