That is not true, it is known always in compile time that it is moved. Rust guarantee that everything is dropped when goes out of scope, so on compile time it is always known who is the owner of the variable.
But shared references are Copy so moves don't matter. If he had used String::from("anything") in his second example, then moves would matter.
Not if the move depends on a runtime conditional. Then the compiler can't know at compile time if the move occurred.
Rust will emit some flags which track the owner at runtime in these cases. These flags are generated by the compiler, and can only be accessed by the compiler.
@RustyYato It depends on point of view. Semantically it does know that it is moved for the if expression, and outside of it is unavailable. Technically it need to actually store some flag on stack to know if it needs to be dropped at the end of scope, this is pretty much obvious.
Can be reference lifetime longer than lifetime borrowed object? How guarante that will not this?
What if reference is declared on block outer to object block ?