Missing trailing expression in block with let else
yields incorrectly spanned error message · Issue #94176 · rust-lang/rust (original) (raw)
I tried this code:
#![feature(let_else)]
pub fn test(a: Option) -> Option { let Some(_) = a else { return None; }; println!("Foo"); }
fn main() {}
I expected to see this happen: A helpful error message pointing to the end of the block.
Instead, this happened: An error message with a wrong span:
error[E0308]: mismatched types
--> test.rs:4:5
|
4 | let Some(_) = a else { return None; };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum Option
, found ()
|
= note: expected enum Option<u32>
found unit type ()
error: aborting due to previous error
For more information about this error, try rustc --explain E0308
.
Meta
rustc --version --verbose
:
rustc 1.60.0-nightly (b17226fcc 2022-02-18)
binary: rustc
commit-hash: b17226fcc11587fed612631be372a5b4cb89988a
commit-date: 2022-02-18
host: x86_64-unknown-linux-gnu
release: 1.60.0-nightly
LLVM version: 14.0.0
cc #87335
@rustbot labels: +T-compiler +F-let-else +requires-nightly +A-diagnostics