]> git.lizzy.rs Git - rust.git/blob - src/test/ui/binding/expr-match.rs
Auto merge of #99612 - yanchen4791:issue-95079-fix, r=compiler-errors
[rust.git] / src / test / ui / binding / expr-match.rs
1 // run-pass
2
3
4
5
6 // Tests for using match as an expression
7
8 fn test_basic() {
9     let mut rs: bool = match true { true => { true } false => { false } };
10     assert!((rs));
11     rs = match false { true => { false } false => { true } };
12     assert!((rs));
13 }
14
15 fn test_inferrence() {
16     let rs = match true { true => { true } false => { false } };
17     assert!((rs));
18 }
19
20 fn test_alt_as_alt_head() {
21     // Yeah, this is kind of confusing ...
22
23     let rs =
24         match match false { true => { true } false => { false } } {
25           true => { false }
26           false => { true }
27         };
28     assert!((rs));
29 }
30
31 fn test_alt_as_block_result() {
32     let rs =
33         match false {
34           true => { false }
35           false => { match true { true => { true } false => { false } } }
36         };
37     assert!((rs));
38 }
39
40 pub fn main() {
41     test_basic();
42     test_inferrence();
43     test_alt_as_alt_head();
44     test_alt_as_block_result();
45 }