I did a small experiment in Compiler Explorer to test whether non-aliasing guarantees of mutable references let rustc do additional optimizations in some situations.
I wrote a very short function in C and Rust to compare how they are compiled down to assembly. My expectation was that rustc would take advantage of the fact that a and b are non-aliasing pointers, and generate assembly that would simply return 10 (without even dereferencing the pointers). However, it turns out the generated assembly from gcc and rustc are identical, indicating that Rustc didn't work as I expected. Optimization levels were O3 in both gcc and rustc.
It seems to me that rustc is missing an optimization opportunity, but I'd like to know what other Rustaceans would think about this. Thanks!