]> git.lizzy.rs Git - rust.git/blob - src/test/ui/binding/optional_comma_in_match_arm.rs
Auto merge of #99612 - yanchen4791:issue-95079-fix, r=compiler-errors
[rust.git] / src / test / ui / binding / optional_comma_in_match_arm.rs
1 // run-pass
2 #![allow(unused_unsafe)]
3 // ignore-pretty issue #37199
4 #![allow(while_true)]
5
6 fn main() {
7     let x = 1;
8
9     match x {
10         1 => loop { break; },
11         2 => while true { break; },
12         3 => if true { () },
13         4 => if true { () } else { () },
14         5 => match () { () => () },
15         6 => { () },
16         7 => unsafe { () },
17         _ => (),
18     }
19
20     match x {
21         1 => loop { break; }
22         2 => while true { break; }
23         3 => if true { () }
24         4 => if true { () } else { () }
25         5 => match () { () => () }
26         6 => { () }
27         7 => unsafe { () }
28         _ => ()
29     }
30
31     let r: &i32 = &x;
32
33     match r {
34         // Absence of comma should not cause confusion between a pattern
35         // and a bitwise and.
36         &1 => if true { () } else { () }
37         &2 => (),
38         _ =>()
39     }
40 }