3 ms·
The Rust compiler cannot assume the loop will never iterate, the analysis phases that could determine that are ran before optimizations. And optimizations are
by eddyb 12y ago
The Rust compiler cannot assume the loop will never iterate, the analysis phases that could determine that are ran before optimizations.
And optimizations are performed by LLVM, with no feedback to the compiler.
I actually analyzed your example, and what happens there is that `i` is a reference to array elements and we don't pass enough metadata to LLVM to inform it of pointers with a fixed number of usable bytes, so it believes the formatting runtime is capable of accessing more of the array.