Why does Rust not optimize code assuming that mutable references cannot alias?
stackoverflow.com
stackoverflow.com
For anyone ever designing a compiler, do yourself a huge favor: do not try to scope aliasing/etc info using metadata. Make it an explicit part of the ir somehow so that the control and dataflow is explicit to the compiler. (GCC went thru the same fun before LLVM did).
It seems like a good idea at first, but it is almost impossible to keep it conservatively correct during transforms (unless you drop it when anything at all changes, which also turns out badly)