S0132: cannot borrow as mutable because value is already mutably borrowed
Generated from rellum-diagnostics/src/db.rs.
Explanation
Only one mutable borrow of a place may be live at a time. Two &mut references to the same value would give two writers exclusive access simultaneously.
Common causes
- creating two &mut references to the same local
- passing the same value to two mutable-reference parameters
- mutably borrowing a value again before the first mutable borrow is no longer used
Canonical fixes
- use the first mutable borrow to finish the mutation before creating another
Before:
a = &mut buf
b = &mut buf
use_two(a, b)
After:
a = &mut buf
normalize(a)
b = &mut buf
- split the data into disjoint fields if the operations truly touch different storage
Code example
a = &mut buf
b = &mut buf
use_two(a, b)