Accessing &mut
inside of @mut
requires first borrowing the @mut
#6269
Labels
&mut
inside of @mut
requires first borrowing the @mut
#6269
Right now, if you have an
&mut
pointer inside of an@mut
data structure, you cannot access it without first borrowing the@mut
to&mut
:The reason for this is that we require a unique access path to mutate or re-borrow
&mut
pointers, and@mut
is aliasable. Once the@mut
is borrowed to&mut
, though, we know that no mutable aliases exist, because otherwise the borrow would have failed. We could just however accept the original code and insert a write guard check ourselves. I don't do this now because it would require various subtle bits of code to make sure that the automatically inserted borrow has the appropriate lifetime to guarantee soundness. Still, it's kind of annoying.cc #5074
The text was updated successfully, but these errors were encountered: