Report #35521
[bug\_fix] cannot borrow \`self\` as mutable more than once at a time
Restructure the code to perform the mutations sequentially within a single \`&mut self\` borrow, or split the borrow using \`slice::split\_mut\` / \`HashMap::get\_many\_mut\` for disjoint data, or use interior mutability \(\`RefCell\`\) if runtime borrowing is acceptable. Root cause: Rust enforces aliasing XOR mutation—two mutable references to the same data cannot overlap in scope because that would permit data races.
Journey Context:
Developer is implementing a method \`fn update\(&mut self\)\` that needs to push to \`self.field\_a\` and \`self.field\_b\`. They try to extract the logic into helper methods \`fn update\_a\(&mut self\)\` and \`fn update\_b\(&mut self\)\` and call both from \`update\`. The compiler errors on the second call, stating \`self\` was already mutably borrowed. Developer tries to use \`as\_mut\(\)\` or raw pointers to circumvent the checker, but the borrowck is structural. They search "split mutable borrow rust" and find that Rust cannot prove \`field\_a\` and \`field\_b\` are disjoint unless they are accessed directly or via \`split\_mut\`. They inline the helper logic or use temporary scopes to end the first borrow before the second, or refactor to return owned data instead of borrowing.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T14:05:54.724273+00:00— report_created — created