error[E0658]: `?` is not allowed in a `const`
--> kfb.rs:2:9
|
2 | D = Some(0)?
| ^^^^^^^^
|
= note: see issue #74935 <https://github.com/rust-lang/rust/issues/74935> for more information
= help: add `#![feature(const_try)]` to the crate attributes to enable
error[E0572]: return statement outside of function body
--> kfb.rs:2:16
|
2 | D = Some(0)?
| ^
Code
playground
Current output
Why these messages are weird
const, but I didn't typeconst. Instead, we're in a const context implied by writing=while defining an enum discriminant.return, but I didn't typereturn. Instead, thereturncomes from desugaring?.Ideal output
?operator outside function body?with.unwrap(), perhapsNotes
?here as a shorthand for.unwrap()? Either way we want compilation to stop if the value isNone.