I've seen people say "Rust is faster than XYZ" (and the other way round) but it's usually light on details why is that. Is it because the benchmarked programs use different algorithms/data structures (e.g. different hash map)? Is it the number of memory accesses? Is it because the compiler generates better code? Is it because it can generate better code because the language has some guarantees?
I'm looking for some details/in-depth descriptions/experiments about code generation/optimisations that are possible in Rust but not in other languages like C++.
I'm less interested in comparing standard library implementations and more about language-specific features that enable "better" code generation. One example could be pointer aliasing where Rust should have an advantage over C++, but that's not enabled at the moment.
In other words, what is the class of algorithms for which Rust might/can produce better code than e.g. C++? (In theory and in practice.) Is there a class of algorithms for which Rust can never produce better code?
I came across this old topic that discusses similar concerns and I've been wondering whether there are new articles/ideas/development regarding optimisation techniques.