Re:Microsoft is to enable Rust use for Windows 11 kernel
by dataflow on Friday April 28, 2023 @03:26PM
(#35745974)
> the use-after-move checks aren't bugprone in Rust
I can't tell if one if us is confused here or if this is just confusing wording, but the check I referred to is not bug-prone. The pattern of using something after it's been moved from is bug-prone (even though it'd work fine for things like integers, in either language), and it's checking for that bug-prone pattern, hence the name.
Essentially all the stuff that makes std::move questionable "just works" in Rust. It doesn't even exist, values are moved by default and clones must be explicit (equivalent of a copy constructor for non-trivially copyable types).
The other giant advantage is that use-after-free doesn't exist in safe Rust, since you can't have a reference to a value outlive the value.
* It is also a compile error for a closure that captures a value by reference to outlive the value.