Closed
Description
The following code [playground]
#![feature(let_else)]
fn foo() -> u32 {
println!("foo");
let () = () else {
return 12;
};
println!("foo");
}
fails to build with the following:
error[E0308]: mismatched types
--> src/lib.rs:6:5
|
6 | / let () = () else {
7 | | return 12;
8 | | };
| |______^ expected `u32`, found `()`
note the span points to just the let .. else
, but there's nothing wrong with it, the problem is the function return type doesn't match. I'd have expected the error to look the same as if the let else
wasn't there, which is:
error[E0308]: mismatched types
--> src/lib.rs:3:13
|
3 | fn foo() -> u32 {
| --- ^^^ expected `u32`, found `()`
| |
| implicitly returns `()` as its body has no tail or `return` expression