summaryrefslogtreecommitdiffstats
path: root/src/test/ui/consts/match-const-fn-structs.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/test/ui/consts/match-const-fn-structs.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/test/ui/consts/match-const-fn-structs.rs b/src/test/ui/consts/match-const-fn-structs.rs
new file mode 100644
index 000000000..5a68048c4
--- /dev/null
+++ b/src/test/ui/consts/match-const-fn-structs.rs
@@ -0,0 +1,22 @@
+// run-pass
+#![allow(unused_variables)]
+
+// https://github.com/rust-lang/rust/issues/46114
+
+#[derive(Eq, PartialEq)]
+struct A { value: u32 }
+
+const fn new(value: u32) -> A {
+ A { value }
+}
+
+const A_1: A = new(1);
+const A_2: A = new(2);
+
+fn main() {
+ let a_str = match new(42) {
+ A_1 => "A 1",
+ A_2 => "A 2",
+ _ => "Unknown A",
+ };
+}