From dc52040efd3c61ac71b9d837a67ba220d08bc931 Mon Sep 17 00:00:00 2001 From: Gary Guo Date: Sat, 14 Aug 2021 18:29:04 +0100 Subject: [PATCH] Add test for issue 82518 --- .../ui/inline-const/const-match-pat-generic.rs | 16 ++++++++++++++++ .../inline-const/const-match-pat-generic.stderr | 9 +++++++++ 2 files changed, 25 insertions(+) create mode 100644 src/test/ui/inline-const/const-match-pat-generic.rs create mode 100644 src/test/ui/inline-const/const-match-pat-generic.stderr 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() { + 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`.