Homepage sample code gives weird error


In the runnable code on the rust-lang homepage, if you change the accumulator to 0.0 then click run, it gives a wierd error message.


There is an open issue about this strange error message, which includes a bit of discussion about what it means.


To be more direct without linking: 0 is inferred to i32. 0.0 is inferred to f64. Rust will not add them together without explicit casting which is why the error appears. There is an issue which would allow floats being inferred from integers like 0 which would likely fix this.

Compiler errors when comparing inferred types may use the _ to state that the type is yet unknown to the compiler (see @thombles’ link). So the error is just stating it found 2 unknown types which are different.