about summary refs log tree commit diff
path: root/tests/ui/consts
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/consts')
-rw-r--r--tests/ui/consts/std/conjure_zst.rs10
-rw-r--r--tests/ui/consts/std/conjure_zst.stderr12
2 files changed, 22 insertions, 0 deletions
diff --git a/tests/ui/consts/std/conjure_zst.rs b/tests/ui/consts/std/conjure_zst.rs
new file mode 100644
index 00000000000..c04deae502b
--- /dev/null
+++ b/tests/ui/consts/std/conjure_zst.rs
@@ -0,0 +1,10 @@
+#![feature(mem_conjure_zst)]
+
+use std::{convert::Infallible, mem};
+
+const INVALID: Infallible = unsafe { mem::conjure_zst() };
+//~^ ERROR attempted to instantiate uninhabited type
+
+const VALID: () = unsafe { mem::conjure_zst() };
+
+fn main() {}
diff --git a/tests/ui/consts/std/conjure_zst.stderr b/tests/ui/consts/std/conjure_zst.stderr
new file mode 100644
index 00000000000..0c4a978b81e
--- /dev/null
+++ b/tests/ui/consts/std/conjure_zst.stderr
@@ -0,0 +1,12 @@
+error[E0080]: evaluation panicked: aborted execution: attempted to instantiate uninhabited type `Infallible`
+  --> $DIR/conjure_zst.rs:5:38
+   |
+LL | const INVALID: Infallible = unsafe { mem::conjure_zst() };
+   |                                      ^^^^^^^^^^^^^^^^^^ evaluation of `INVALID` failed inside this call
+   |
+note: inside `conjure_zst::<Infallible>`
+  --> $SRC_DIR/core/src/mem/mod.rs:LL:COL
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0080`.