about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-06-30 16:42:39 +0200
committerMatthias Krüger <matthias.krueger@famsik.de>2022-06-30 16:42:39 +0200
commitd067cb4105e7f135b00698c3350e9eb44eb61e7a (patch)
tree66b2c7bd8480d9189228098f9bac53c25191ed0b
parent7425fb293f510a6f138e82a963a3bc599a5b9e1c (diff)
downloadrust-d067cb4105e7f135b00698c3350e9eb44eb61e7a.tar.gz
rust-d067cb4105e7f135b00698c3350e9eb44eb61e7a.zip
add ice test for #97047
Fixes #97047
-rw-r--r--src/test/ui/const-generics/generic_const_exprs/issue-97047-ice-1.rs25
-rw-r--r--src/test/ui/const-generics/generic_const_exprs/issue-97047-ice-1.stderr19
-rw-r--r--src/test/ui/const-generics/generic_const_exprs/issue-97047-ice-2.rs23
-rw-r--r--src/test/ui/const-generics/generic_const_exprs/issue-97047-ice-2.stderr19
4 files changed, 86 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/generic_const_exprs/issue-97047-ice-1.rs b/src/test/ui/const-generics/generic_const_exprs/issue-97047-ice-1.rs
new file mode 100644
index 00000000000..67e30232e2f
--- /dev/null
+++ b/src/test/ui/const-generics/generic_const_exprs/issue-97047-ice-1.rs
@@ -0,0 +1,25 @@
+// check-pass
+
+#![feature(adt_const_params, generic_const_exprs)]
+//~^ WARN the feature `adt_const_params` is incomplete and may not be safe to use and/or cause compiler crashes [incomplete_features]
+//~^^ WARN the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes [incomplete_features]
+
+pub struct Changes<const CHANGES: &'static [&'static str]>
+where
+    [(); CHANGES.len()]:,
+{
+    changes: [usize; CHANGES.len()],
+}
+
+impl<const CHANGES: &'static [&'static str]> Changes<CHANGES>
+where
+    [(); CHANGES.len()]:,
+{
+    pub const fn new() -> Self {
+        Self {
+            changes: [0; CHANGES.len()],
+        }
+    }
+}
+
+pub fn main() {}
diff --git a/src/test/ui/const-generics/generic_const_exprs/issue-97047-ice-1.stderr b/src/test/ui/const-generics/generic_const_exprs/issue-97047-ice-1.stderr
new file mode 100644
index 00000000000..b5b2b0e405a
--- /dev/null
+++ b/src/test/ui/const-generics/generic_const_exprs/issue-97047-ice-1.stderr
@@ -0,0 +1,19 @@
+warning: the feature `adt_const_params` is incomplete and may not be safe to use and/or cause compiler crashes
+  --> $DIR/issue-97047-ice-1.rs:3:12
+   |
+LL | #![feature(adt_const_params, generic_const_exprs)]
+   |            ^^^^^^^^^^^^^^^^
+   |
+   = note: `#[warn(incomplete_features)]` on by default
+   = note: see issue #95174 <https://github.com/rust-lang/rust/issues/95174> for more information
+
+warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
+  --> $DIR/issue-97047-ice-1.rs:3:30
+   |
+LL | #![feature(adt_const_params, generic_const_exprs)]
+   |                              ^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
+
+warning: 2 warnings emitted
+
diff --git a/src/test/ui/const-generics/generic_const_exprs/issue-97047-ice-2.rs b/src/test/ui/const-generics/generic_const_exprs/issue-97047-ice-2.rs
new file mode 100644
index 00000000000..00568a08944
--- /dev/null
+++ b/src/test/ui/const-generics/generic_const_exprs/issue-97047-ice-2.rs
@@ -0,0 +1,23 @@
+// check-pass
+
+#![feature(adt_const_params, generic_const_exprs)]
+//~^ WARN the feature `adt_const_params` is incomplete and may not be safe to use and/or cause compiler crashes [incomplete_features]
+//~^^ WARN the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes [incomplete_features]
+
+pub struct Changes<const CHANGES: &'static [&'static str]>
+where
+    [(); CHANGES.len()]:,
+{
+    changes: [usize; CHANGES.len()],
+}
+
+impl<const CHANGES: &'static [&'static str]> Changes<CHANGES>
+where
+    [(); CHANGES.len()]:,
+{
+    pub fn combine(&mut self, other: &Self) {
+        for _change in &self.changes {}
+    }
+}
+
+pub fn main() {}
diff --git a/src/test/ui/const-generics/generic_const_exprs/issue-97047-ice-2.stderr b/src/test/ui/const-generics/generic_const_exprs/issue-97047-ice-2.stderr
new file mode 100644
index 00000000000..5dfbd87ccd4
--- /dev/null
+++ b/src/test/ui/const-generics/generic_const_exprs/issue-97047-ice-2.stderr
@@ -0,0 +1,19 @@
+warning: the feature `adt_const_params` is incomplete and may not be safe to use and/or cause compiler crashes
+  --> $DIR/issue-97047-ice-2.rs:3:12
+   |
+LL | #![feature(adt_const_params, generic_const_exprs)]
+   |            ^^^^^^^^^^^^^^^^
+   |
+   = note: `#[warn(incomplete_features)]` on by default
+   = note: see issue #95174 <https://github.com/rust-lang/rust/issues/95174> for more information
+
+warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
+  --> $DIR/issue-97047-ice-2.rs:3:30
+   |
+LL | #![feature(adt_const_params, generic_const_exprs)]
+   |                              ^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
+
+warning: 2 warnings emitted
+