rust-lang / nomicon

The Dark Arts of Advanced and Unsafe Rust Programming
https://doc.rust-lang.org/nomicon/
Apache License 2.0
1.82k stars 263 forks source link

Is the proof of the assume that`temp` doesn't alias `input`wrong in section 3.2 #362

Closed yejunjin closed 2 years ago

yejunjin commented 2 years ago

The doc says:

We're still relying on alias analysis to assume that temp doesn't alias input, but the proof is much simpler: the value of a local variable can't be aliased by things that existed before it was declared. This is an assumption every language freely makes, and so this version of the function could be optimized the way we want in any language.

The assumption is that temp doesn't ALIAS input, but the proof is try to prove input doesn't ALIAS local variable temp.