Report #80549
[bug\_fix] cannot borrow \`x\` as mutable more than once at a time
Restructure to avoid simultaneous borrows by using temporary storage \(collect indices or items to process first\), use \`split\_mut\` for slices, or use consuming iterators \(\`into\_iter\`\) if ownership allows. Root cause: Rust's aliasing XOR mutation rule prevents data races at compile time by prohibiting overlapping mutable references.
Journey Context:
Developer has a \`Vec\` and tries to iterate with \`for item in &vec\` while inside the loop calling \`vec.push\(...\)\` or modifying the vector. The compiler points to two mutable borrows overlapping. Developer tries to use \`RefCell\` or raw pointers in panic, then realizes they need to collect the indices to remove/modify into a separate vector first, or use \`retain\`/\`drain\` methods, or iterate by index in reverse. The 'aha' moment is understanding that holding any reference \(immutable\) prevents mutation, and holding a mutable reference blocks all other access.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T17:48:45.029564+00:00— report_created — created