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
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
}
}

Some(Cause::DropVar(local, location)) => {
Some(Cause::DropVar(local, location)) if !is_local_boring(local) => {
let mut should_note_order = false;
if self.local_name(local).is_some()
&& let Some((WriteKind::StorageDeadOrDrop, place)) = kind_place
Expand All @@ -705,7 +705,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
}
}

Some(Cause::LiveVar(..)) | None => {
Some(Cause::LiveVar(..) | Cause::DropVar(..)) | None => {
// Here, under NLL: no cause was found. Under polonius: no cause was found, or a
// boring local was found, which we ignore like NLLs do to match its diagnostics.
if let Some(region) = self.to_error_region_vid(borrow_region_vid) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
error[E0499]: cannot borrow `*t` as mutable more than once at a time
--> $DIR/lending-iterator-sanity-checks.rs:19:19
|
LL | fn use_live<T: LendingIterator>(t: &mut T) -> Option<(T::Item<'_>, T::Item<'_>)> {
| - let's call the lifetime of this reference `'1`
LL | let Some(i) = t.next() else { return None };
| - first mutable borrow occurs here
LL | let Some(j) = t.next() else { return None };
| ^ second mutable borrow occurs here
...
LL | }
| - first borrow might be used here, when `i` is dropped and runs the destructor for type `<T as LendingIterator>::Item<'_>`
LL | Some((i, j))
| ------------ returning this value requires that `*t` is borrowed for `'1`

error[E0499]: cannot borrow `*t` as mutable more than once at a time
--> $DIR/lending-iterator-sanity-checks.rs:31:13
Expand Down
Loading