summaryrefslogtreecommitdiffstats
path: root/src/test/ui/parser/struct-literal-in-match-guard.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/test/ui/parser/struct-literal-in-match-guard.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/test/ui/parser/struct-literal-in-match-guard.rs b/src/test/ui/parser/struct-literal-in-match-guard.rs
new file mode 100644
index 000000000..bf0551b5c
--- /dev/null
+++ b/src/test/ui/parser/struct-literal-in-match-guard.rs
@@ -0,0 +1,18 @@
+// check-pass
+
+// Unlike `if` condition, `match` guards accept struct literals.
+// This is detected in <https://github.com/rust-lang/rust/pull/74566#issuecomment-663613705>.
+
+#[derive(PartialEq)]
+struct Foo {
+ x: isize,
+}
+
+fn foo(f: Foo) {
+ match () {
+ () if f == Foo { x: 42 } => {}
+ _ => {}
+ }
+}
+
+fn main() {}