Report #13601
[bug\_fix] cannot borrow \`x\` as mutable more than once at a time \(E0499\)
Restructure the code so that mutable borrows do not overlap; use temporary variables, split borrows with \`split\_mut\`, or collect indices/keys to mutate later. Root cause: Rust’s aliasing rules enforce exclusive mutable access to prevent data races.
Journey Context:
A developer writes a loop that iterates mutably over a \`Vec\` while also trying to push to it inside the loop, or they hold a mutable reference to an element and then call a method on the container that requires \`&mut self\`. The compiler points to the second borrow site. The developer tries using \`RefCell\` or \`unsafe\` blocks, which is overkill. They eventually realize they can either split the borrows temporally by scoping the first borrow inside a block, or restructure to avoid simultaneous mutable aliasing.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T19:13:38.546725+00:00— report_created — created