Closed
Description
Code
#[derive(Debug, Deserialize)]
pub struct Build {
#[serde(deserialize_with = "as_u64")]
build: u32,
product: Product,
release: String,
status: String,
version: String,
}
Current output
error[E0308]: `?` operator has incompatible types
--> downloader-api\src\lib.rs:140:17
|
140 | #[derive(Debug, Deserialize)]
| ^^^^^^^^^^^ expected `u32`, found `u64`
|
= note: `?` operator cannot convert from `u64` to `u32`
= note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)
help: you can convert a `u64` to a `u32` and panic if the converted value doesn't fit
|
140 | #[derive(Debug, Deserialize.try_into().unwrap())]
| ++++++++++++++++++++
Desired output
Not sure what the correct output should be, but the current one suggests using an invalid syntax: `#[derive(Debug, Deserialize.try_into().unwrap())]`
If no useful "help" message can be provided in this context, the compiler should not suggest an invalid syntax in the "help" section.
Rationale and extra context
No response
Other cases
No response
Anything else?
rustc 1.76.0-nightly (9a66e4471 2023-11-19)