News for hackers. Stuff that matters.
Re:Rust: Zero-Cost Abstraction in Action by habitue on Saturday February 08, 2020 @12:59AM (#22274215)
Actually, so there's a very good chance that this particular optimization is happening due to MIRI, which allows very sophisticated constant evaluation of MIR (a rust intermediate representation)

https://rust-lang.github.io/rustc-guide/miri.html

So while, yes, in general pretty much all rust optimizations are actually due to LLVM, this one in particular might not be

Re:Rust: Zero-Cost Abstraction in Action by bdd on Saturday February 08, 2020 @02:59AM (#22274611)
Here's the equivalent in C++, compiled with clang 9.0.0 at optimization level 1. https://godbolt.org/z/nKSG9_

Byte for byte identical assembly.