Skip to content

Commit

Permalink
Add a regression test for match guard
Browse files Browse the repository at this point in the history
Unlike if condition, match guard accepts struct literal.
  • Loading branch information
tesuji committed Aug 8, 2020
1 parent 0a8d4ce commit ef50477
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/test/ui/parser/struct-literal-in-match-guard.rs
Original file line number Diff line number Diff line change
@@ -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() {}

0 comments on commit ef50477

Please sign in to comment.