Skip to content

Commit 9818526

Browse files
committed
Add regression test for rust-lang#94176
1 parent e3c5bd6 commit 9818526

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/test/ui/let-else/issue-94176.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Issue #94176: wrong span for the error message of a mismatched type error,
2+
// if the function uses a `let else` construct.
3+
#![feature(let_else)]
4+
5+
pub fn test(a: Option<u32>) -> Option<u32> { //~ ERROR mismatched types
6+
let Some(_) = a else { return None; };
7+
println!("Foo");
8+
}
9+
10+
fn main() {}
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/issue-94176.rs:5:32
3+
|
4+
LL | pub fn test(a: Option<u32>) -> Option<u32> {
5+
| ---- ^^^^^^^^^^^ expected enum `Option`, found `()`
6+
| |
7+
| implicitly returns `()` as its body has no tail or `return` expression
8+
|
9+
= note: expected enum `Option<u32>`
10+
found unit type `()`
11+
help: consider returning the local binding `a`
12+
|
13+
LL ~ println!("Foo");
14+
LL + a
15+
|
16+
17+
error: aborting due to previous error
18+
19+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)