Closed
Description
Code
struct Stuff { count: i32 }
struct Error;
fn demo() -> Result<Stuff, Error> {
let count = Ok(1);
Ok(Stuff { count })
}
Current output
error[E0308]: mismatched types
--> src/lib.rs:6:16
|
6 | Ok(Stuff { count })
| ^^^^^ expected `i32`, found `Result<{integer}, _>`
|
= note: expected type `i32`
found enum `Result<{integer}, _>`
help: use the `?` operator to extract the `Result<{integer}, _>` value, propagating a `Result::Err` value to the caller
|
6 | Ok(Stuff { count? })
| +
Desired output
error[E0308]: mismatched types
--> src/lib.rs:6:16
|
6 | Ok(Stuff { count })
| ^^^^^ expected `i32`, found `Result<{integer}, _>`
|
= note: expected type `i32`
found enum `Result<{integer}, _>`
help: use the `?` operator to extract the `Result<{integer}, _>` value, propagating a `Result::Err` value to the caller
|
6 | Ok(Stuff { count: count? })
| ++++++++
Rationale and extra context
No response
Other cases
No response
Anything else?
This appears to be a new diagnostic, as it appears in 1.75.0-beta.3 (2023-11-20 b66b795) but not in 1.74.0.