If I call:
fn nothing() -> i32{
let x = 2;
let x = 3;
}
I have read that a new address is allocated on the stack and the old variable is "inaccessible" by its name (but isn't deallocated?). Did I get bad information?
Why doesn't Rust keep the same part of memory on the stack and.. mutate it? let does not declare a constant or static so what is going on here? Is there a way to have multiple handles during variable shadowing such as pointing to the stack?
If so can the compiler perform a 0 reference count check and optimize away multiple lets with a single mut if it is never pointed to since there is by definition only the name handle that mutates value?
Is this solely due to the native multithreading and concurrence safety design choices?