]> git.lizzy.rs Git - rust.git/blob - src/test/ui/rfc-2497-if-let-chains/ensure-that-let-else-does-not-interact-with-let-chains.rs
Rollup merge of #105843 - compiler-errors:sugg-const, r=lcnr
[rust.git] / src / test / ui / rfc-2497-if-let-chains / ensure-that-let-else-does-not-interact-with-let-chains.rs
1 #![feature(let_chains)]
2
3 fn main() {
4     let opt = Some(1i32);
5
6     let Some(n) = opt else {
7         return;
8     };
9     let Some(n) = opt && n == 1 else {
10     //~^ ERROR a `&&` expression cannot be directly assigned in `let...else`
11     //~| ERROR mismatched types
12     //~| ERROR mismatched types
13         return;
14     };
15     let Some(n) = opt && let another = n else {
16     //~^ ERROR a `&&` expression cannot be directly assigned in `let...else`
17     //~| ERROR `let` expressions are not supported here
18     //~| ERROR mismatched types
19     //~| ERROR mismatched types
20     //~| ERROR expected expression, found `let` statement
21         return;
22     };
23
24     if let Some(n) = opt else {
25     //~^ ERROR this `if` expression is missing a block after the condition
26         return;
27     };
28     if let Some(n) = opt && n == 1 else {
29     //~^ ERROR this `if` expression is missing a block after the condition
30         return;
31     };
32     if let Some(n) = opt && let another = n else {
33     //~^ ERROR this `if` expression is missing a block after the condition
34         return;
35     };
36
37     {
38         while let Some(n) = opt else {
39         //~^ ERROR expected `{`, found keyword `else`
40             return;
41         };
42     }
43     {
44         while let Some(n) = opt && n == 1 else {
45         //~^ ERROR expected `{`, found keyword `else`
46             return;
47         };
48     }
49     {
50         while let Some(n) = opt && let another = n else {
51         //~^ ERROR expected `{`, found keyword `else`
52             return;
53         };
54     }
55 }