Closed
Description
Reduced version of code encountered during a tutorial:
fn main() {
let x = 0;
x += 1.0;
}
Compiler error message:
error: the trait bound `_: std::ops::AddAssign<_>` is not satisfied [--explain E0277]
--> <anon>:3:5
3 |> x += 1.0;
|> ^^^^^^^^
help: the following implementations were found:
help: <f64 as std::ops::AddAssign>
help: <f32 as std::ops::AddAssign>
help: <u64 as std::ops::AddAssign>
help: <i64 as std::ops::AddAssign>
help: and 21 others
error: aborting due to previous error
Namely, the error message says nothing about i32
nor f64
nor the use of let x = 0;
, so a beginner really has no place to go for help here.
Can we leverage the on_unimplemented
functionality to provide better feedback in the case where one is mixing i32
and f64
? (Or does it not have a way to put in a more specific message depending on the types involved in this case?)
There may be an issue for this elsewhere (we all know that our error messaging when type-inference goes to numeric-fallback), but the error message here was particularly bad, and I couldn't find an existing issue quickly, so I am filing this one to make sure this doesn't fall through the cracks.