about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMara Bos <m-ou.se@m-ou.se>2021-07-09 15:33:42 +0200
committerMara Bos <m-ou.se@m-ou.se>2021-07-28 16:10:43 +0200
commit76cf1b8bd03142eacee3bd31ca4651f0ce0431ca (patch)
tree18a04df420dd49b49271ebce86caf3376c8ae0dd
parent91d0823dffc29dc3e7b09791469d0c7b8beb2407 (diff)
downloadrust-76cf1b8bd03142eacee3bd31ca4651f0ce0431ca.tar.gz
rust-76cf1b8bd03142eacee3bd31ca4651f0ce0431ca.zip
Add test for const panic in Rust 2021.
-rw-r--r--src/test/ui/consts/const-eval/const_panic_2021.rs27
-rw-r--r--src/test/ui/consts/const-eval/const_panic_2021.stderr67
2 files changed, 94 insertions, 0 deletions
diff --git a/src/test/ui/consts/const-eval/const_panic_2021.rs b/src/test/ui/consts/const-eval/const_panic_2021.rs
new file mode 100644
index 00000000000..daef34cd6a3
--- /dev/null
+++ b/src/test/ui/consts/const-eval/const_panic_2021.rs
@@ -0,0 +1,27 @@
+// edition:2021
+#![feature(const_panic)]
+#![crate_type = "lib"]
+
+const A: () = std::panic!("blåhaj");
+//~^ ERROR evaluation of constant value failed
+
+const B: () = std::panic!();
+//~^ ERROR evaluation of constant value failed
+
+const C: () = std::unreachable!();
+//~^ ERROR evaluation of constant value failed
+
+const D: () = std::unimplemented!();
+//~^ ERROR evaluation of constant value failed
+
+const E: () = core::panic!("shark");
+//~^ ERROR evaluation of constant value failed
+
+const F: () = core::panic!();
+//~^ ERROR evaluation of constant value failed
+
+const G: () = core::unreachable!();
+//~^ ERROR evaluation of constant value failed
+
+const H: () = core::unimplemented!();
+//~^ ERROR evaluation of constant value failed
diff --git a/src/test/ui/consts/const-eval/const_panic_2021.stderr b/src/test/ui/consts/const-eval/const_panic_2021.stderr
new file mode 100644
index 00000000000..c1bdab3693d
--- /dev/null
+++ b/src/test/ui/consts/const-eval/const_panic_2021.stderr
@@ -0,0 +1,67 @@
+error[E0080]: evaluation of constant value failed
+  --> $DIR/const_panic_2021.rs:5:15
+   |
+LL | const A: () = std::panic!("blåhaj");
+   |               ^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'blåhaj', $DIR/const_panic_2021.rs:5:15
+   |
+   = note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0080]: evaluation of constant value failed
+  --> $DIR/const_panic_2021.rs:8:15
+   |
+LL | const B: () = std::panic!();
+   |               ^^^^^^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/const_panic_2021.rs:8:15
+   |
+   = note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0080]: evaluation of constant value failed
+  --> $DIR/const_panic_2021.rs:11:15
+   |
+LL | const C: () = std::unreachable!();
+   |               ^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_2021.rs:11:15
+   |
+   = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0080]: evaluation of constant value failed
+  --> $DIR/const_panic_2021.rs:14:15
+   |
+LL | const D: () = std::unimplemented!();
+   |               ^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'not implemented', $DIR/const_panic_2021.rs:14:15
+   |
+   = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0080]: evaluation of constant value failed
+  --> $DIR/const_panic_2021.rs:17:15
+   |
+LL | const E: () = core::panic!("shark");
+   |               ^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'shark', $DIR/const_panic_2021.rs:17:15
+   |
+   = note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0080]: evaluation of constant value failed
+  --> $DIR/const_panic_2021.rs:20:15
+   |
+LL | const F: () = core::panic!();
+   |               ^^^^^^^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/const_panic_2021.rs:20:15
+   |
+   = note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0080]: evaluation of constant value failed
+  --> $DIR/const_panic_2021.rs:23:15
+   |
+LL | const G: () = core::unreachable!();
+   |               ^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_2021.rs:23:15
+   |
+   = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0080]: evaluation of constant value failed
+  --> $DIR/const_panic_2021.rs:26:15
+   |
+LL | const H: () = core::unimplemented!();
+   |               ^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'not implemented', $DIR/const_panic_2021.rs:26:15
+   |
+   = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to 8 previous errors
+
+For more information about this error, try `rustc --explain E0080`.