-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Closed
Copy link
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerC-bugCategory: This is a bug.Category: This is a bug.fixed-by-NLLBugs fixed, but only when NLL is enabled.Bugs fixed, but only when NLL is enabled.
Description
pub struct FragmentRepr(Vec<FragmentRepr>);
pub fn accepted(mut entry: &mut FragmentRepr) {
loop {
let FragmentRepr(ref mut discrs) = *{entry};
entry = &mut discrs[0];
}
}
pub fn rejected(mut entry: &mut FragmentRepr) {
loop {
let FragmentRepr(ref mut discrs) = *entry;
entry = &mut discrs[0];
}
}
fn main() {}
Rust accepts the first function, but rejects the second with "error: cannot borrow entry.0
as mutable more than once at a time". It would be nice not to be forced to insert random curly braces to convince the borrow checker that my code is correct.
Metadata
Metadata
Assignees
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerC-bugCategory: This is a bug.Category: This is a bug.fixed-by-NLLBugs fixed, but only when NLL is enabled.Bugs fixed, but only when NLL is enabled.