about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/test/ui/inline-const/const-match-pat-generic.rs16
-rw-r--r--src/test/ui/inline-const/const-match-pat-generic.stderr9
2 files changed, 25 insertions, 0 deletions
diff --git a/src/test/ui/inline-const/const-match-pat-generic.rs b/src/test/ui/inline-const/const-match-pat-generic.rs
new file mode 100644
index 00000000000..61680d653d0
--- /dev/null
+++ b/src/test/ui/inline-const/const-match-pat-generic.rs
@@ -0,0 +1,16 @@
+#![allow(incomplete_features)]
+#![feature(inline_const)]
+
+// rust-lang/rust#82518: ICE with inline-const in match referencing const-generic parameter
+
+fn foo<const V: usize>() {
+  match 0 {
+    const { V } => {},
+    //~^ ERROR const parameters cannot be referenced in patterns [E0158]
+    _ => {},
+  }
+}
+
+fn main() {
+    foo::<1>();
+}
diff --git a/src/test/ui/inline-const/const-match-pat-generic.stderr b/src/test/ui/inline-const/const-match-pat-generic.stderr
new file mode 100644
index 00000000000..a3ed41a3f6a
--- /dev/null
+++ b/src/test/ui/inline-const/const-match-pat-generic.stderr
@@ -0,0 +1,9 @@
+error[E0158]: const parameters cannot be referenced in patterns
+  --> $DIR/const-match-pat-generic.rs:8:11
+   |
+LL |     const { V } => {},
+   |           ^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0158`.