Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/ui/nll/polonius/iterating-updating-mutref.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0499]: cannot borrow `self.buf_read` as mutable more than once at a time
--> $DIR/iterating-updating-mutref.rs:61:23
--> $DIR/iterating-updating-mutref.rs:76:23
|
LL | pub fn next<'a>(&'a mut self) -> &'a str {
| -- lifetime `'a` defined here
Expand Down
15 changes: 15 additions & 0 deletions tests/ui/nll/polonius/iterating-updating-mutref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,21 @@ fn to_refs2<T>(mut list: &mut List<T>) -> Vec<&mut T> {
result
}

// In a-mir-formality, the local `cursor` was (incorrectly) considered live
// on a second borrowck pass, resulting in an incorrect error.
fn to_refs3<'a, T>(list: &'a mut List<T>) -> &'a mut T {
let mut result: &'a mut T;
let mut cursor: &'a mut List<T> = &mut *list;
loop {
result = &mut cursor.value;
if let Some(n) = cursor.next.as_mut() {
cursor = n;
} else {
return result;
}
}
}

// Another MCVE from the same issue, but was rejected by NLLs.
pub struct Decoder {
buf_read: BufRead,
Expand Down
Loading