summaryrefslogtreecommitdiffstats
path: root/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/consts/const-eval/index-out-of-bounds-never-type.rs')
-rw-r--r--src/test/ui/consts/const-eval/index-out-of-bounds-never-type.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.rs b/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.rs
new file mode 100644
index 000000000..8064cc493
--- /dev/null
+++ b/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.rs
@@ -0,0 +1,23 @@
+// build-fail
+
+// Regression test for #66975
+#![warn(const_err, unconditional_panic)]
+#![feature(never_type)]
+
+struct PrintName<T>(T);
+
+impl<T> PrintName<T> {
+ const VOID: ! = { let x = 0 * std::mem::size_of::<T>(); [][x] };
+ //~^ WARN any use of this value will cause an error
+ //~| WARN this was previously accepted by the compiler but is being phased out
+
+}
+
+fn f<T>() {
+ let _ = PrintName::<T>::VOID;
+ //~^ ERROR erroneous constant encountered
+}
+
+pub fn main() {
+ f::<()>();
+}