Add a regression test for match guard
Unlike if condition, match guard accepts struct literal.
This commit is contained in:
parent
0a8d4ce055
commit
ef50477c78
1 changed files with 18 additions and 0 deletions
18
src/test/ui/parser/struct-literal-in-match-guard.rs
Normal file
18
src/test/ui/parser/struct-literal-in-match-guard.rs
Normal file
|
|
@ -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() {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue