Skip to content

Commit ef50477

Browse files
committed
Add a regression test for match guard
Unlike if condition, match guard accepts struct literal.
1 parent 0a8d4ce commit ef50477

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Diff for: src/test/ui/parser/struct-literal-in-match-guard.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// check-pass
2+
3+
// Unlike `if` condition, `match` guards accept struct literals.
4+
// This is detected in <https://github.com/rust-lang/rust/pull/74566#issuecomment-663613705>.
5+
6+
#[derive(PartialEq)]
7+
struct Foo {
8+
x: isize,
9+
}
10+
11+
fn foo(f: Foo) {
12+
match () {
13+
() if f == Foo { x: 42 } => {}
14+
_ => {}
15+
}
16+
}
17+
18+
fn main() {}

0 commit comments

Comments
 (0)