This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +80
-4
lines changed Expand file tree Collapse file tree 6 files changed +80
-4
lines changed Original file line number Diff line number Diff line change 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 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- // check-pass
21// issue #89807
32
43#![ feature( let_else) ]
@@ -10,5 +9,7 @@ fn main() {
109 #[ allow( unused) ]
1110 let banana = 1 ;
1211 #[ 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`
1415}
Original file line number Diff line number Diff line change 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() {
1010 return ;
1111 } ;
1212
13+ let Some ( _) : Option < u32 > = Some ( Default :: default ( ) ) else {
14+ let x = 1 ; //~ ERROR unused variable: `x`
15+ return ;
16+ } ;
17+
1318 let x = 1 ; //~ ERROR unused variable: `x`
1419}
Original file line number Diff line number Diff line change 11error: unused variable: `x`
2- --> $DIR/let-else-check.rs:13 :9
2+ --> $DIR/let-else-check.rs:18 :9
33 |
44LL | let x = 1;
55 | ^ help: if this is intentional, prefix it with an underscore: `_x`
@@ -10,5 +10,11 @@ note: the lint level is defined here
1010LL | #![deny(unused_variables)]
1111 | ^^^^^^^^^^^^^^^^
1212
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
1420
You can’t perform that action at this time.
0 commit comments