about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-05-23 10:44:10 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-05-23 10:48:39 +0000
commit301c8decceb7bb87de350cf062140e937c4d6120 (patch)
tree4cb346af3500aeb7e9d7f447e62e2c5aaf392b1f
parent39d2f2affdd6b2856ab4b91359cc0d32b90bd26f (diff)
downloadrust-301c8decceb7bb87de350cf062140e937c4d6120.tar.gz
rust-301c8decceb7bb87de350cf062140e937c4d6120.zip
Add regression tests
-rw-r--r--tests/ui/consts/erroneous_type_in_promoted.rs14
-rw-r--r--tests/ui/consts/erroneous_type_in_promoted.stderr28
2 files changed, 42 insertions, 0 deletions
diff --git a/tests/ui/consts/erroneous_type_in_promoted.rs b/tests/ui/consts/erroneous_type_in_promoted.rs
new file mode 100644
index 00000000000..32e33c2030f
--- /dev/null
+++ b/tests/ui/consts/erroneous_type_in_promoted.rs
@@ -0,0 +1,14 @@
+//! ICE test #124348
+//! We should not be running const eval if the layout has errors.
+
+enum Eek {
+    TheConst,
+    UnusedByTheConst(Sum),
+    //~^ ERROR cannot find type `Sum` in this scope
+}
+
+const fn foo() {
+    let x: &'static [Eek] = &[];
+}
+
+fn main() {}
diff --git a/tests/ui/consts/erroneous_type_in_promoted.stderr b/tests/ui/consts/erroneous_type_in_promoted.stderr
new file mode 100644
index 00000000000..48502adebce
--- /dev/null
+++ b/tests/ui/consts/erroneous_type_in_promoted.stderr
@@ -0,0 +1,28 @@
+error[E0412]: cannot find type `Sum` in this scope
+  --> $DIR/erroneous_type_in_promoted.rs:6:22
+   |
+LL |     UnusedByTheConst(Sum),
+   |                      ^^^ not found in this scope
+   |
+help: consider importing this trait
+   |
+LL + use std::iter::Sum;
+   |
+
+note: erroneous constant encountered
+  --> $DIR/erroneous_type_in_promoted.rs:11:29
+   |
+LL |     let x: &'static [Eek] = &[];
+   |                             ^^^
+
+note: erroneous constant encountered
+  --> $DIR/erroneous_type_in_promoted.rs:11:29
+   |
+LL |     let x: &'static [Eek] = &[];
+   |                             ^^^
+   |
+   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0412`.