Add regression test for #94176

This commit is contained in:
est31 2022-07-15 18:53:23 +02:00
parent e3c5bd617d
commit 981852677c
2 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,10 @@
// Issue #94176: wrong span for the error message of a mismatched type error,
// if the function uses a `let else` construct.
#![feature(let_else)]
pub fn test(a: Option<u32>) -> Option<u32> { //~ ERROR mismatched types
let Some(_) = a else { return None; };
println!("Foo");
}
fn main() {}

View File

@ -0,0 +1,19 @@
error[E0308]: mismatched types
--> $DIR/issue-94176.rs:5:32
|
LL | pub fn test(a: Option<u32>) -> Option<u32> {
| ---- ^^^^^^^^^^^ expected enum `Option`, found `()`
| |
| implicitly returns `()` as its body has no tail or `return` expression
|
= note: expected enum `Option<u32>`
found unit type `()`
help: consider returning the local binding `a`
|
LL ~ println!("Foo");
LL + a
|
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.