From ef50477c786016bf1712a34155d067b407e35cc0 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sat, 25 Jul 2020 01:14:10 +0000 Subject: [PATCH] Add a regression test for match guard Unlike if condition, match guard accepts struct literal. --- .../ui/parser/struct-literal-in-match-guard.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/test/ui/parser/struct-literal-in-match-guard.rs 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 00000000000..bf0551b5c97 --- /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 . + +#[derive(PartialEq)] +struct Foo { + x: isize, +} + +fn foo(f: Foo) { + match () { + () if f == Foo { x: 42 } => {} + _ => {} + } +} + +fn main() {}