Open
Description
Code
fn main() {
if let Some(whatever) = todo!() {
todo!();
} else {
todo!();
}
}
Current output
error[E0282]: type annotations needed
--> src/main.rs:2:17
|
2 | if let Some(whatever) = todo!() {
| ^^^^^^^^ cannot infer type
For more information about this error, try `rustc --explain E0282`.
It's not really clear how rustc would like to see the type annotations, without adding an extra binding and without type_ascription
What does not work:
if let Some(whatever): Option<i32> = todo!() {
or
if let Some(whatever: i32) = todo!() {
what did end up working:
if let Some(x) = Some(todo!()) {
or
if let Some(x @ ()) = todo!() {
Rust Version
rustc 1.89.0-nightly (6f6971078 2025-05-28)
binary: rustc
commit-hash: 6f69710780d579b180ab38da4c1384d630f7bd31
commit-date: 2025-05-28
host: x86_64-unknown-linux-gnu
release: 1.89.0-nightly
LLVM version: 20.1.5