Closed
Description
tl;dr; If you comment out the let error
line, all will compile, obviously.
fn main() {
let error = error; // Comment me
for value in (1..10).map(|a| a as f32) {
}
}
However, in presence of it, compiler complains
error[E0605]: non-primitive cast: `{integer}` as `f32`
--> src/main.rs:3:34
|
3 | for value in (1..10).map(|a| a as f32) {
| ^^^^^^^^
|
= note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait
…which is strange and may mislead user in more complex situation. Looks like broken code affects type inference somehow. By the way, error will also appear, if you put erroneous line after the loop.
rustc 1.21.0-nightly (13d94d5fa 2017-08-10)
binary: rustc
commit-hash: 13d94d5fa8129a34f5c77a1bcd76983f5aed2434
commit-date: 2017-08-10
host: x86_64-unknown-linux-gnu
release: 1.21.0-nightly
LLVM version: 4.0