In my code below, I (thought I) correctly scoped my mutable borrows, but Rust compiler insists there's more than 1 borrow occurring "at the same time". I'm boggled. This is synchronous code and scope should kill the prior references, no?
{
let r = &mut roots;
let s = &mut store;
let l = &mut rels;
build(&mut items, r, s, l);
}
{
let r = &mut roots;
let s = &mut store;
build_top(lt, r, s);
}
{
let s = &mut store;
let l = &mut rels;
build_instance(1, "2", "4", s, l);
}
error[E0499]: cannot borrow `roots` as mutable more than once at a time
--> src/clue/tree_tests.rs:26:21
|
20 | let r = &mut roots;
| ---------- first mutable borrow occurs here
...
26 | let r = &mut roots;
| ^^^^^^^^^^
| |
| second mutable borrow occurs here
| first borrow later used here
error[E0499]: cannot borrow `store` as mutable more than once at a time
--> src/clue/tree_tests.rs:27:21
|
21 | let s = &mut store;
| ---------- first mutable borrow occurs here
...
27 | let s = &mut store;
| ^^^^^^^^^^
| |
| second mutable borrow occurs here
| first borrow later used here
error[E0499]: cannot borrow `store` as mutable more than once at a time
--> src/clue/tree_tests.rs:31:21
|
21 | let s = &mut store;
| ---------- first mutable borrow occurs here
...
31 | let s = &mut store;
| ^^^^^^^^^^
| |
| second mutable borrow occurs here
| first borrow later used here
error[E0499]: cannot borrow `rels` as mutable more than once at a time
--> src/clue/tree_tests.rs:32:21
|
22 | let l = &mut rels;
| --------- first mutable borrow occurs here
...
32 | let l = &mut rels;
| ^^^^^^^^^
| |
| second mutable borrow occurs here
| first borrow later used here