diff options
| author | Lzu Tao <taolzu@gmail.com> | 2020-07-25 01:14:10 +0000 |
|---|---|---|
| committer | Lzu Tao <taolzu@gmail.com> | 2020-08-08 10:38:49 +0000 |
| commit | ef50477c786016bf1712a34155d067b407e35cc0 (patch) | |
| tree | 9286af7fa7e9a5b8f07f48a3d29c5fa7b280a173 | |
| parent | 0a8d4ce055d40bb4897d1cd5c110174ede8ed505 (diff) | |
| download | rust-ef50477c786016bf1712a34155d067b407e35cc0.tar.gz rust-ef50477c786016bf1712a34155d067b407e35cc0.zip | |
Add a regression test for match guard
Unlike if condition, match guard accepts struct literal.
| -rw-r--r-- | src/test/ui/parser/struct-literal-in-match-guard.rs | 18 |
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 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 <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() {} |
