What's the property of this line?

fn main() {
    let mut a = 1;
    let a = &mut a; // What's the property of this line?
    *a = 2;
    assert_eq!(*a, 2);

It doesn't seem like the normal variable shadowing where a new local variable is declared with the same name in a block.
It seems related to drop check, specifically the temporary lifetime extension.

Why do you think it isn't shadowing? A shadowed variable still exists until it is dropped at the end of the scope.


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.