Expand let-else allow tests · Dylan-DPC/rust@e7730dc (original) (raw)
6 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
1 | +#![feature(let_else)] | |
2 | + | |
3 | +#![deny(unused_variables)] | |
4 | + | |
5 | +fn main() { | |
6 | +let Some(_): Option<u32> = ({ | |
7 | +let x = 1; //~ ERROR unused variable: `x` | |
8 | +Some(1) | |
9 | +}) else { | |
10 | +return; | |
11 | +}; | |
12 | + | |
13 | +#[allow(unused_variables)] | |
14 | +let Some(_): Option<u32> = ({ | |
15 | +let x = 1; | |
16 | +Some(1) | |
17 | +}) else { | |
18 | +return; | |
19 | +}; | |
20 | + | |
21 | +let Some(_): Option<u32> = ({ | |
22 | +#[allow(unused_variables)] | |
23 | +let x = 1; | |
24 | +Some(1) | |
25 | +}) else { | |
26 | +return; | |
27 | +}; | |
28 | + | |
29 | +let x = 1; //~ ERROR unused variable: `x` | |
30 | +} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
1 | +error: unused variable: `x` | |
2 | + --> $DIR/let-else-allow-in-expr.rs:7:13 | |
3 | + | | |
4 | +LL | let x = 1; | |
5 | + | ^ help: if this is intentional, prefix it with an underscore: `_x` | |
6 | + | | |
7 | +note: the lint level is defined here | |
8 | + --> $DIR/let-else-allow-in-expr.rs:3:9 | |
9 | + | | |
10 | +LL | #![deny(unused_variables)] | |
11 | + | ^^^^^^^^^^^^^^^^ | |
12 | + | |
13 | +error: unused variable: `x` | |
14 | + --> $DIR/let-else-allow-in-expr.rs:29:9 | |
15 | + | | |
16 | +LL | let x = 1; | |
17 | + | ^ help: if this is intentional, prefix it with an underscore: `_x` | |
18 | + | |
19 | +error: aborting due to 2 previous errors | |
20 | + |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
1 | -// check-pass | |
2 | 1 | // issue #89807 |
3 | 2 | |
4 | 3 | #![feature(let_else)] |
@@ -10,5 +9,7 @@ fn main() { | ||
10 | 9 | #[allow(unused)] |
11 | 10 | let banana = 1; |
12 | 11 | #[allow(unused)] |
13 | -let Some(chaenomeles) = value else { return }; // OK | |
12 | +let Some(chaenomeles) = value.clone() else { return }; // OK | |
13 | + | |
14 | +let Some(chaenomeles) = value else { return }; //~ ERROR unused variable: `chaenomeles` | |
14 | 15 | } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
1 | +error: unused variable: `chaenomeles` | |
2 | + --> $DIR/let-else-allow-unused.rs:14:14 | |
3 | + | | |
4 | +LL | let Some(chaenomeles) = value else { return }; | |
5 | + | ^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_chaenomeles` | |
6 | + | | |
7 | +note: the lint level is defined here | |
8 | + --> $DIR/let-else-allow-unused.rs:5:8 | |
9 | + | | |
10 | +LL | #[deny(unused_variables)] | |
11 | + | ^^^^^^^^^^^^^^^^ | |
12 | + | |
13 | +error: aborting due to previous error | |
14 | + |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -10,5 +10,10 @@ fn main() { | ||
10 | 10 | return; |
11 | 11 | }; |
12 | 12 | |
13 | +let Some(_): Option<u32> = Some(Default::default()) else { | |
14 | +let x = 1; //~ ERROR unused variable: `x` | |
15 | +return; | |
16 | +}; | |
17 | + | |
13 | 18 | let x = 1; //~ ERROR unused variable: `x` |
14 | 19 | } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
1 | 1 | error: unused variable: `x` |
2 | - --> $DIR/let-else-check.rs:13:9 | |
2 | + --> $DIR/let-else-check.rs🔞9 | |
3 | 3 | | |
4 | 4 | LL | let x = 1; |
5 | 5 | | ^ help: if this is intentional, prefix it with an underscore: `_x` |
@@ -10,5 +10,11 @@ note: the lint level is defined here | ||
10 | 10 | LL | #![deny(unused_variables)] |
11 | 11 | | ^^^^^^^^^^^^^^^^ |
12 | 12 | |
13 | -error: aborting due to previous error | |
13 | +error: unused variable: `x` | |
14 | + --> $DIR/let-else-check.rs:14:13 | |
15 | + | | |
16 | +LL | let x = 1; | |
17 | + | ^ help: if this is intentional, prefix it with an underscore: `_x` | |
18 | + | |
19 | +error: aborting due to 2 previous errors | |
14 | 20 |