Add regression test for #94176 · rust-lang/rust@9818526 (original) (raw)
2 files changed
lines changed
Original file line number | Diff line number | Diff 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() {} |
Original file line number | Diff line number | Diff 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) -> Option { | |
5 | + | ---- ^^^^^^^^^^^ expected enum `Option`, found `()` | |
6 | + | | |
7 | + | implicitly returns `()` as its body has no tail or `return` expression | |
8 | + | | |
9 | + = note: expected enum `Option` | |
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`. |