Report #10948
[bug\_fix] cannot borrow \`self\` as mutable more than once at a time
The root cause is violating Rust's aliasing XOR mutability rule: you cannot hold overlapping mutable references simultaneously. The fix is to restructure the code to limit the scope of borrows so they do not overlap, use \`split\_at\_mut\` for slices to get disjoint mutable references, or use interior mutability \(e.g., \`RefCell\`\) only when runtime borrowing is truly required.
Journey Context:
You are building a game loop or web server handler that needs to update both the player's health and their inventory simultaneously. You write \`self.health.update\(\)\` and \`self.inventory.add\_item\(\)\` and the compiler hits you with "cannot borrow \`self\` as mutable more than once at a time." You descend into the rabbit hole: first you try wrapping fields in \`RefCell\` everywhere, which turns your compile-time errors into runtime panics. Then you try splitting the methods into separate immutable queries followed by mutations, but the borrows still overlap. You read the error message closely and realize the mutable reference \`&mut self\` in the first method call lasts until the end of the statement, overlapping with the second call. The epiphany comes when you restructure to use temporary scopes: \`\{ let h = &mut self.health; h.update\(\); \} \{ let i = &mut self.inventory; i.add\_item\(\); \}\` or realize you need to borrow disjoint fields simultaneously using \`let \(health, inventory\) = self.split\_mut\(\)\` if working with slices.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T12:10:48.055252+00:00— report_created — created