Report #72199
[bug\_fix] cannot borrow \`self\` as mutable more than once at a time \(E0499\)
Split the mutable borrow by extracting the specific fields into temporary variables before the method call, or restructure the method to accept the specific fields as parameters rather than borrowing all of \`self\`. The root cause is that holding a mutable reference to any part of a struct invalidates any other mutable reference to the entire struct until the first reference drops; splitting the borrows allows the compiler to prove disjoint access.
Journey Context:
Developer implements a parser with \`fn parse\(&mut self\)\` that calls \`self.next\_token\(\)\` while holding a mutable reference to \`self.current\` in a local variable. The compiler emits E0499 on the second call attempt. The developer tries wrapping fields in \`RefCell\`, which compiles but causes runtime panics. They then attempt to clone data to avoid borrows, causing performance issues. Finally, they restructure the code: \`let current = &mut self.current; let next = self.next\_token\(\);\` fails, so they instead change \`next\_token\` to take \`&mut self.tokens\` specifically, splitting the struct into distinct fields that can be borrowed independently, satisfying the borrow checker.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T03:46:00.251737+00:00— report_created — created