d7de4e9aff
Implement the stronger guarantees for mutable borrows from #12624. This removes the ability to read from a mutably borrowed path for the duration of the borrow, and enforces a unique access path for any mutable borrow, for both reads and writes. This makes mutable borrows work better with concurrent accesses from multiple threads, and it opens the door for allowing moves out of mutably borrowed values, as long as a new value is written before the mutable borrow ends. This also aligns Rust more closely with academic languages based on substructural types and separation logic. The most common situation triggering an error after this change is a call to a function mutably borrowing self with self.field as one of the arguments. The workaround is to bind self.field to a temporary, but the need for these temporaries will hopefully go away after #6268 is fixed. Another situation that triggers an error is using the head expression of a match in an arm that binds a variable with a mutable reference. The use of the head expression needs to be replaced with an expression that reconstructs it from match-bound variables. This fixes #12624. [breaking-change] |
||
---|---|---|
.. | ||
borrowck | ||
cfg | ||
save | ||
trans | ||
typeck | ||
astencode.rs | ||
check_const.rs | ||
check_loop.rs | ||
check_match.rs | ||
check_static.rs | ||
const_eval.rs | ||
dataflow.rs | ||
dead.rs | ||
def.rs | ||
dependency_format.rs | ||
effect.rs | ||
entry.rs | ||
expr_use_visitor.rs | ||
freevars.rs | ||
graph.rs | ||
intrinsicck.rs | ||
kind.rs | ||
lang_items.rs | ||
lint.rs | ||
liveness.rs | ||
mem_categorization.rs | ||
pat_util.rs | ||
privacy.rs | ||
reachable.rs | ||
region.rs | ||
resolve_lifetime.rs | ||
resolve.rs | ||
subst.rs | ||
ty_fold.rs | ||
ty.rs | ||
weak_lang_items.rs |