Skip to content

Commit e3c5bd6

Browse files
cormacrelfest31
authored andcommitted
let-else: add a test for warnings on let-else with diverging tail
1 parent e2b52ff commit e3c5bd6

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// popped up in in #94012, where an alternative desugaring was
3+
// causing unreachable code errors
4+
5+
#![feature(let_else)]
6+
#![deny(unused_variables)]
7+
#![deny(unreachable_code)]
8+
9+
fn let_else_diverge() -> bool {
10+
let Some(_) = Some("test") else {
11+
let x = 5; //~ ERROR unused variable: `x`
12+
return false;
13+
};
14+
return true;
15+
}
16+
17+
fn main() {
18+
let_else_diverge();
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error: unused variable: `x`
2+
--> $DIR/let-else-then-diverge.rs:11:13
3+
|
4+
LL | let x = 5;
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-then-diverge.rs:6:9
9+
|
10+
LL | #![deny(unused_variables)]
11+
| ^^^^^^^^^^^^^^^^
12+
13+
error: aborting due to previous error
14+

0 commit comments

Comments
 (0)