]> git.lizzy.rs Git - rust.git/blob - src/test/ui/parser/issue-103381.rs
Rollup merge of #106043 - c410-f3r:moar-errors, r=petrochenkov
[rust.git] / src / test / ui / parser / issue-103381.rs
1 // run-rustfix
2
3 #![feature(let_chains)]
4 #![allow(unused_variables)]
5 #![allow(dead_code)]
6 #![allow(irrefutable_let_patterns)]
7
8 fn err_some(b: bool, x: Option<u32>) {
9     if b && if let Some(x) = x {}
10     //~^ ERROR unexpected `if` in the condition expression
11 }
12
13 fn err_none(b: bool, x: Option<u32>) {
14     if b && if let None = x {}
15     //~^ ERROR unexpected `if` in the condition expression
16 }
17
18 fn err_bool_1() {
19     if true && if true { true } else { false };
20     //~^ ERROR unexpected `if` in the condition expression
21 }
22
23 fn err_bool_2() {
24     if true && if false { true } else { false };
25     //~^ ERROR unexpected `if` in the condition expression
26 }
27
28 fn should_ok_1() {
29     if true && if let x = 1 { true } else { true } {}
30 }
31
32 fn should_ok_2() {
33     if true && if let 1 = 1 { true } else { true } {}
34 }
35
36 fn should_ok_3() {
37     if true && if true { true } else { false } {}
38 }
39
40 fn shoule_match_ok() {
41     #[cfg(feature = "full")]
42     {
43         let a = 1;
44         let b = 2;
45         if match a {
46             1 if b == 1 => true,
47             _ => false,
48         } && if a > 1 { true } else { false }
49         {
50             true
51         }
52     }
53 }
54
55 fn should_ok_in_nested() {
56     if true && if true { true } else { false } { true } else { false };
57 }
58
59 fn main() {}