Compiling playground v0.0.1 (/playground)
error[E0499]: cannot borrow `s` as mutable more than once at a time
--> src/main.rs:23:9
|
20 | x = &mut s;
| ------ first mutable borrow occurs here
...
23 | f = &mut s;
| ^^^^^^
| |
| second mutable borrow occurs here
| first borrow later used here
For more information about this error, try `rustc --explain E0499`.
error: could not compile `playground` (bin "playground") due to 1 previous error
I believe so. If you make only this change, it compiles.
- let mut f: &mut &mut u32 = &mut x;
+ let mut f: & &mut u32 = &mut x;
I don't think anyone's "walking around" mental model goes this deep, especially if we assume polonius isn't buggy -- as in that case, we're just poking at code to find the limitations of the current NLL implementation.
So the NLL RFC may be a better bet than someone's mental model. Even then, the RFC isn't an exact reflection of the implementation.[1]
Location sensitive outlives relations are not implemented in NLL for example. ↩︎
If you want to create a bunch of contrived examples to help yourself understand how the borrow checker works, that's fine, but please keep it to one discussion thread instead of opening a new one for each example?
(I've merged the new thread into this one, for that reason.)