about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-08-19 03:27:00 +0200
committerGitHub <noreply@github.com>2023-08-19 03:27:00 +0200
commitd8bde4878a1efea6f18d63a0ee93ee25c90be551 (patch)
tree690796b088fa3b53082bda01723eb3656ea7b87d
parent8d52b4d2f310f466f030627c43478678754dfc11 (diff)
parent26fe88fedb19a4118d58a6e439709759f65c63c9 (diff)
downloadrust-d8bde4878a1efea6f18d63a0ee93ee25c90be551.tar.gz
rust-d8bde4878a1efea6f18d63a0ee93ee25c90be551.zip
Rollup merge of #114972 - nbdd0121:const_check, r=compiler-errors
Add a test to check that inline const is in required_consts

This was a commit in #104087. This commit, as a test, can go in while the overall inline const stabilisation is blocked.

Suggested in https://github.com/rust-lang/rust/issues/76001#issuecomment-1315975027
-rw-r--r--tests/ui/inline-const/required-const.rs13
-rw-r--r--tests/ui/inline-const/required-const.stderr11
2 files changed, 24 insertions, 0 deletions
diff --git a/tests/ui/inline-const/required-const.rs b/tests/ui/inline-const/required-const.rs
new file mode 100644
index 00000000000..0483410662b
--- /dev/null
+++ b/tests/ui/inline-const/required-const.rs
@@ -0,0 +1,13 @@
+// build-fail
+// compile-flags: -Zmir-opt-level=3
+#![feature(inline_const)]
+
+fn foo<T>() {
+    if false {
+        const { panic!() } //~ ERROR E0080
+    }
+}
+
+fn main() {
+    foo::<i32>();
+}
diff --git a/tests/ui/inline-const/required-const.stderr b/tests/ui/inline-const/required-const.stderr
new file mode 100644
index 00000000000..d6948e7acc0
--- /dev/null
+++ b/tests/ui/inline-const/required-const.stderr
@@ -0,0 +1,11 @@
+error[E0080]: evaluation of `foo::<i32>::{constant#0}` failed
+  --> $DIR/required-const.rs:7:17
+   |
+LL |         const { panic!() }
+   |                 ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/required-const.rs:7:17
+   |
+   = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0080`.