Report #35250
[bug\_fix] cannot borrow \`self\` as mutable more than once at a time
Restructure the code to release the first mutable borrow before calling the method, or split the struct into smaller sub-structs so each method borrows a disjoint field \(splitting borrows\). Root cause: Rust's aliasing rules forbid two mutable references to overlap in scope; holding a reference to a field across a method call that takes \`&mut self\` creates overlapping borrows.
Journey Context:
Developer is implementing a recursive descent parser with a \`Parser\` struct holding a \`Vec\` and a \`position\` index. They write \`fn parse\_list\(&mut self\) \{ let current = &mut self.tokens\[self.position\]; self.consume\(\); \}\`. The borrow checker rejects this because \`current\` is a mutable borrow of \`self.tokens\` while \`self.consume\(\)\` \(which takes \`&mut self\`\) is called. Developer tries wrapping fields in \`RefCell\` and \`Rc\`, adding runtime overhead and complexity, but still hits borrow errors at compile time because \`RefCell::borrow\_mut\` panics at runtime. After reading compiler diagnostics suggesting to split the struct, they refactor \`Parser\` into \`Tokenizer\` and \`State\` structs, passing only the needed slices to helper functions, which satisfies the borrow checker by proving the borrows are disjoint.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T13:37:58.357821+00:00— report_created — created