Closed
Description
The following code has a misleading proposed fix:
struct RGB { r: f64, g: f64, b: f64 }
fn main() {
let (r, g, b): (f32, f32, f32) = (0., 0., 0.);
let _ = RGB { r, g, b };
}
The reported error message is:
error[E0308]: mismatched types
--> src/main.rs:4:17
|
4 | let _ = RGB { r, g, b };
| ^ expected f64, found f32
help: you can cast an `f32` to `f64` in a lossless way
|
4 | let _ = RGB { r.into(), g, b };
| ^^^^^^^^
Trying to apply the suggestion fails and causes a syntax error, the correct fix would be r: r.into()
.