Closed JohnTitor closed 2 years ago
I've read this over several times, and I'm not clear on this.
The original says: "the value of a local variable can't be aliased by things that existed before it was declared" which I read to be true. The local variable can't be aliased before it is declared because it doesn't exist, yet. There is nothing to alias. That is:
fn compute(input: &u32, output: &mut u32) {
// Up to this point, nothing can alias `temp` because `temp` doesn't exist, yet.
let mut temp = *output;
if *input > 10 {
temp = 1;
}
if *input > 5 {
temp *= 2;
}
*output = temp;
}
The new version says: "the value of a local variable cannot alias things that existed before it was declared." This doesn't seem correct to me because local variables can be created which alias things before their declaration.
fn f(a: &str) {
let b = a; // local variable `b` created an alias of `a`
}
Can you help me understand the proposed correction?
Thanks for pointing out, hmm, I was confused then. So, we should say "We're still relying on alias analysis to assume that input
doesn't alias temp
" instead, right?
Friendly-ping @ehuss it'd be great if you could take another look :)
It should've said "the value of a local variable cannot alias things...".
Fixes #362