about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2023-09-18 15:20:36 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2023-09-21 08:50:08 +0000
commit44e199bf300a79df302a5b068dba0c39d9a12c0f (patch)
tree6f80afe5c1a01cc880eadcf739781bf53fc4f1a9
parent0a689c1be85d635bf61ffb7922ef9ce02587a3b1 (diff)
downloadrust-44e199bf300a79df302a5b068dba0c39d9a12c0f.tar.gz
rust-44e199bf300a79df302a5b068dba0c39d9a12c0f.zip
Add regression test
-rw-r--r--tests/ui/inline-const/promotion.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/ui/inline-const/promotion.rs b/tests/ui/inline-const/promotion.rs
new file mode 100644
index 00000000000..e211f46acf9
--- /dev/null
+++ b/tests/ui/inline-const/promotion.rs
@@ -0,0 +1,21 @@
+#![feature(inline_const)]
+#![allow(arithmetic_overflow, unconditional_panic)]
+// check-pass
+
+// The only way to have promoteds that fail is in `const fn` called from `const`/`static`.
+const fn div_by_zero() -> i32 {
+    1 / 0
+}
+
+const fn mk_false() -> bool {
+    false
+}
+
+fn main() {
+    let v = const {
+        if mk_false() {
+            let _x: &'static i32 = &div_by_zero();
+        }
+        42
+    };
+}