From 37fa92552586a9f91fefd92518b66dfde4c64771 Mon Sep 17 00:00:00 2001 From: Dylan MacKenzie Date: Wed, 1 Dec 2021 10:04:21 -0800 Subject: [PATCH] Add regression test for #90770 --- src/test/ui/consts/drop_zst.rs | 17 +++++++++++++++++ src/test/ui/consts/drop_zst.stderr | 9 +++++++++ 2 files changed, 26 insertions(+) create mode 100644 src/test/ui/consts/drop_zst.rs create mode 100644 src/test/ui/consts/drop_zst.stderr 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`.