diff options
| author | Matthew Jasper <mjjasper1@gmail.com> | 2018-09-29 11:47:47 +0100 |
|---|---|---|
| committer | Matthew Jasper <mjjasper1@gmail.com> | 2018-10-03 20:32:38 +0100 |
| commit | bc4f9b848d745022ededdfaa3099158a766e8faa (patch) | |
| tree | 09130b6605ea1381a5ae0755323f5d7be6f6e120 | |
| parent | cc09cb5e5ad8c072441f2156aa9bcd1484e55b1c (diff) | |
| download | rust-bc4f9b848d745022ededdfaa3099158a766e8faa.tar.gz rust-bc4f9b848d745022ededdfaa3099158a766e8faa.zip | |
Clearer later use messages for calls
Give a special message when the later use is from a call. Use the span of the callee instead of the whole expression. For conflicting borrow messages say that the later use is of the first borrow.
102 files changed, 607 insertions, 636 deletions
diff --git a/src/librustc_mir/borrow_check/error_reporting.rs b/src/librustc_mir/borrow_check/error_reporting.rs index 22b135bee49..260e6ee5e2b 100644 --- a/src/librustc_mir/borrow_check/error_reporting.rs +++ b/src/librustc_mir/borrow_check/error_reporting.rs @@ -15,9 +15,9 @@ use rustc::hir; use rustc::hir::def_id::DefId; use rustc::middle::region::ScopeTree; use rustc::mir::{ - self, AggregateKind, BindingForm, BorrowKind, ClearCrossCrate, FakeReadCause, Field, Local, - LocalDecl, LocalKind, Location, Operand, Place, PlaceProjection, ProjectionElem, Rvalue, - Statement, StatementKind, TerminatorKind, VarBindingForm, + self, AggregateKind, BindingForm, BorrowKind, ClearCrossCrate, Field, Local, + LocalDecl, LocalKind, Location, Operand, Place, PlaceProjection, ProjectionElem, + Rvalue, Statement, StatementKind, TerminatorKind, VarBindingForm, }; use rustc::ty; use rustc::util::ppaux::with_highlight_region_for_bound_region; @@ -262,7 +262,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { move_spans.var_span_label(&mut err, "move occurs due to use in closure"); self.explain_why_borrow_contains_point(context, borrow, None) - .emit(self.infcx.tcx, &mut err); + .emit(self.infcx.tcx, &mut err, String::new()); err.buffer(&mut self.errors_buffer); } @@ -299,7 +299,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { }); self.explain_why_borrow_contains_point(context, borrow, None) - .emit(self.infcx.tcx, &mut err); + .emit(self.infcx.tcx, &mut err, String::new()); err.buffer(&mut self.errors_buffer); } @@ -319,6 +319,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { let desc_place = self.describe_place(place).unwrap_or("_".to_owned()); let tcx = self.infcx.tcx; + let first_borrow_desc; + // FIXME: supply non-"" `opt_via` when appropriate let mut err = match ( gen_borrow_kind, @@ -328,8 +330,23 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { "immutable", "mutable", ) { - (BorrowKind::Shared, lft, _, BorrowKind::Mut { .. }, _, rgt) - | (BorrowKind::Mut { .. }, _, lft, BorrowKind::Shared, rgt, _) => { + (BorrowKind::Shared, lft, _, BorrowKind::Mut { .. }, _, rgt) => { + first_borrow_desc = "mutable "; + tcx.cannot_reborrow_already_borrowed( + span, + &desc_place, + "", + lft, + issued_span, + "it", + rgt, + "", + None, + Origin::Mir, + ) + } + (BorrowKind::Mut { .. }, _, lft, BorrowKind::Shared, rgt, _) => { + first_borrow_desc = "immutable "; tcx.cannot_reborrow_already_borrowed( span, &desc_place, @@ -345,6 +362,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { } (BorrowKind::Mut { .. }, _, _, BorrowKind::Mut { .. }, _, _) => { + first_borrow_desc = "first "; tcx.cannot_mutably_borrow_multiply( span, &desc_place, @@ -357,6 +375,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { } (BorrowKind::Unique, _, _, BorrowKind::Unique, _, _) => { + first_borrow_desc = "first "; tcx.cannot_uniquely_borrow_by_two_closures( span, &desc_place, @@ -384,18 +403,22 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { return; } - (BorrowKind::Unique, _, _, _, _, _) => tcx.cannot_uniquely_borrow_by_one_closure( - span, - &desc_place, - "", - issued_span, - "it", - "", - None, - Origin::Mir, - ), + (BorrowKind::Unique, _, _, _, _, _) => { + first_borrow_desc = "first "; + tcx.cannot_uniquely_borrow_by_one_closure( + span, + &desc_place, + "", + issued_span, + "it", + "", + None, + Origin::Mir, + ) + }, (BorrowKind::Shared, lft, _, BorrowKind::Unique, _, _) => { + first_borrow_desc = "first "; tcx.cannot_reborrow_already_uniquely_borrowed( span, &desc_place, @@ -409,6 +432,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { } (BorrowKind::Mut { .. }, _, lft, BorrowKind::Unique, _, _) => { + first_borrow_desc = "first "; tcx.cannot_reborrow_already_uniquely_borrowed( span, &desc_place, @@ -459,7 +483,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { } self.explain_why_borrow_contains_point(context, issued_borrow, None) - .emit(self.infcx.tcx, &mut err); + .emit(self.infcx.tcx, &mut err, first_borrow_desc.to_string()); err.buffer(&mut self.errors_buffer); } @@ -614,7 +638,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { if let BorrowExplanation::MustBeValidFor(..) = explanation { } else { - explanation.emit(self.infcx.tcx, &mut err); + explanation.emit(self.infcx.tcx, &mut err, String::new()); } } else { err.span_label(borrow_span, "borrowed value does not live long enough"); @@ -625,7 +649,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { borrow_spans.args_span_label(&mut err, "value captured here"); - explanation.emit(self.infcx.tcx, &mut err); + explanation.emit(self.infcx.tcx, &mut err, String::new()); } err @@ -685,7 +709,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { _ => {} } - explanation.emit(self.infcx.tcx, &mut err); + explanation.emit(self.infcx.tcx, &mut err, String::new()); err.buffer(&mut self.errors_buffer); } @@ -752,7 +776,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { } _ => {} } - explanation.emit(self.infcx.tcx, &mut err); + explanation.emit(self.infcx.tcx, &mut err, String::new()); borrow_spans.args_span_label(&mut err, "value captured here"); @@ -889,7 +913,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { loan_spans.var_span_label(&mut err, "borrow occurs due to use in closure"); self.explain_why_borrow_contains_point(context, loan, None) - .emit(self.infcx.tcx, &mut err); + .emit(self.infcx.tcx, &mut err, String::new()); err.buffer(&mut self.errors_buffer); } @@ -1262,21 +1286,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { } } - /// Returns the `FakeReadCause` at this location if it is a `FakeRead` statement. - pub(super) fn retrieve_fake_read_cause_for_location( - &self, - location: &Location, - ) -> Option<FakeReadCause> { - let stmt = self.mir.basic_blocks()[location.block] - .statements - .get(location.statement_index)?; - if let StatementKind::FakeRead(cause, _) = stmt.kind { - Some(cause) - } else { - None - } - } - fn classify_drop_access_kind(&self, place: &Place<'tcx>) -> StorageDeadOrDrop<'tcx> { let tcx = self.infcx.tcx; match place { diff --git a/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs b/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs index 8d1caec2d72..6b5c9f0333e 100644 --- a/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs +++ b/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs @@ -9,10 +9,11 @@ // except according to those terms. use borrow_check::borrow_set::BorrowData; +use borrow_check::error_reporting::UseSpans; use borrow_check::nll::region_infer::Cause; use borrow_check::{Context, MirBorrowckCtxt, WriteKind}; use rustc::ty::{Region, TyCtxt}; -use rustc::mir::{FakeReadCause, Location, Place, TerminatorKind}; +use rustc::mir::{FakeReadCause, Location, Operand, Place, StatementKind, TerminatorKind}; use rustc_errors::DiagnosticBuilder; use syntax_pos::Span; use syntax_pos::symbol::Symbol; @@ -20,42 +21,57 @@ use syntax_pos::symbol::Symbol; mod find_use; pub(in borrow_check) enum BorrowExplanation<'tcx> { - UsedLater(bool, Option<FakeReadCause>, Span), - UsedLaterInLoop(bool, Span), + UsedLater(LaterUseKind, Span), + UsedLaterInLoop(LaterUseKind, Span), UsedLaterWhenDropped(Span, Symbol, bool), MustBeValidFor(Region<'tcx>), Unexplained, } +#[derive(Clone, Copy)] +pub(in borrow_check) enum LaterUseKind { + ClosureCapture, + Call, + FakeLetRead, + Other, +} + impl<'tcx> BorrowExplanation<'tcx> { pub(in borrow_check) fn emit<'cx, 'gcx>( &self, tcx: TyCtxt<'cx, 'gcx, 'tcx>, - err: &mut DiagnosticBuilder<'_> + err: &mut DiagnosticBuilder<'_>, + borrow_desc: String, ) { match *self { - BorrowExplanation::UsedLater(is_in_closure, fake_read_cause, var_or_use_span) => { - let message = if is_in_closure { - "borrow later captured here by closure" - } else if let Some(FakeReadCause::ForLet) = fake_read_cause { - "borrow later stored here" - } else { - "borrow later used here" + BorrowExplanation::UsedLater(later_use_kind, var_or_use_span) => { + let message = borrow_desc + match later_use_kind { + LaterUseKind::ClosureCapture => "borrow later captured here by closure", + LaterUseKind::Call => "borrow later used by call", + LaterUseKind::FakeLetRead => "borrow later stored here", + LaterUseKind::Other => "borrow later used here", }; err.span_label(var_or_use_span, message); }, - BorrowExplanation::UsedLaterInLoop(is_in_closure, var_or_use_span) => { - let message = if is_in_closure { - "borrow captured here by closure, in later iteration of loop" - } else { - "borrow used here, in later iteration of loop" + BorrowExplanation::UsedLaterInLoop(later_use_kind, var_or_use_span) => { + let message = borrow_desc + match later_use_kind { + LaterUseKind::ClosureCapture => { + "borrow captured here by closure, in later iteration of loop" + }, + LaterUseKind::Call => "borrow used by call, in later iteration of loop", + LaterUseKind::FakeLetRead => "borrow later stored here", + LaterUseKind::Other => "borrow used here, in later iteration of loop", }; err.span_label(var_or_use_span, message); }, BorrowExplanation::UsedLaterWhenDropped(span, local_name, should_note_order) => { err.span_label( span, - format!("borrow later used here, when `{}` is dropped", local_name), + format!( + "{}borrow later used here, when `{}` is dropped", + borrow_desc, + local_name, + ), ); if should_note_order { @@ -68,7 +84,7 @@ impl<'tcx> BorrowExplanation<'tcx> { BorrowExplanation::MustBeValidFor(region) => { tcx.note_and_explain_free_region( err, - "borrowed value must be valid for ", + &(borrow_desc + "borrowed value must be valid for "), region, "...", ); @@ -127,16 +143,14 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { .or_else(|| self.borrow_spans(span, location)); if self.is_borrow_location_in_loop(context.loc) { - BorrowExplanation::UsedLaterInLoop(spans.for_closure(), spans.var_or_use()) + let later_use = self.later_use_kind(spans, location); + BorrowExplanation::UsedLaterInLoop(later_use.0, later_use.1) } else { // Check if the location represents a `FakeRead`, and adapt the error // message to the `FakeReadCause` it is from: in particular, // the ones inserted in optimized `let var = <expr>` patterns. - BorrowExplanation::UsedLater( - spans.for_closure(), - self.retrieve_fake_read_cause_for_location(&location), - spans.var_or_use() - ) + let later_use = self.later_use_kind(spans, location); + BorrowExplanation::UsedLater(later_use.0, later_use.1) } } @@ -246,4 +260,43 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { false } + + fn later_use_kind(&self, use_spans: UseSpans, location: Location) -> (LaterUseKind, Span) { + use self::LaterUseKind::*; + + let block = &self.mir.basic_blocks()[location.block]; + match use_spans { + UseSpans::ClosureUse { var_span, .. } => (LaterUseKind::ClosureCapture, var_span), + UseSpans::OtherUse(span) => { + (if let Some(stmt) = block.statements.get(location.statement_index) { + match stmt.kind { + StatementKind::FakeRead(FakeReadCause::ForLet, _) => FakeLetRead, + _ => Other, + } + } else { + assert_eq!(location.statement_index, block.statements.len()); + match block.terminator().kind { + TerminatorKind::Call { ref func, from_hir_call: true, .. } => { + // Just point to the function, to reduce the chance + // of overlapping spans. + let function_span = match func { + Operand::Constant(c) => c.span, + Operand::Copy(Place::Local(l)) | Operand::Move(Place::Local(l)) => { + let local_decl = &self.mir.local_decls[*l]; + if local_decl.name.is_none() { + local_decl.source_info.span + } else { + span + } + }, + _ => span, + }; + return (Call, function_span); + }, + _ => Other, + } + }, span) + } + } + } } diff --git a/src/test/ui/E0501.ast.nll.stderr b/src/test/ui/E0501.ast.nll.stderr index a9abc79400e..72fda9079d6 100644 --- a/src/test/ui/E0501.ast.nll.stderr +++ b/src/test/ui/E0501.ast.nll.stderr @@ -10,7 +10,7 @@ LL | outside_closure_1(a); //[ast]~ ERROR cannot borrow `*a` as mutable beca | ^ borrow occurs here ... LL | drop(bar); - | --- borrow later used here + | --- first borrow later used here error[E0501]: cannot borrow `*a` as immutable because previous closure requires unique access --> $DIR/E0501.rs:31:23 @@ -24,7 +24,7 @@ LL | outside_closure_2(a); //[ast]~ ERROR cannot borrow `*a` as immutable be | ^ borrow occurs here ... LL | drop(bar); - | --- borrow later used here + | --- first borrow later used here error: aborting due to 2 previous errors diff --git a/src/test/ui/E0501.mir.stderr b/src/test/ui/E0501.mir.stderr index a9abc79400e..72fda9079d6 100644 --- a/src/test/ui/E0501.mir.stderr +++ b/src/test/ui/E0501.mir.stderr @@ -10,7 +10,7 @@ LL | outside_closure_1(a); //[ast]~ ERROR cannot borrow `*a` as mutable beca | ^ borrow occurs here ... LL | drop(bar); - | --- borrow later used here + | --- first borrow later used here error[E0501]: cannot borrow `*a` as immutable because previous closure requires unique access --> $DIR/E0501.rs:31:23 @@ -24,7 +24,7 @@ LL | outside_closure_2(a); //[ast]~ ERROR cannot borrow `*a` as immutable be | ^ borrow occurs here ... LL | drop(bar); - | --- borrow later used here + | --- first borrow later used here error: aborting due to 2 previous errors diff --git a/src/test/ui/binop/binop-move-semantics.nll.stderr b/src/test/ui/binop/binop-move-semantics.nll.stderr index 98762a0f6cf..545a60f6770 100644 --- a/src/test/ui/binop/binop-move-semantics.nll.stderr +++ b/src/test/ui/binop/binop-move-semantics.nll.stderr @@ -44,7 +44,7 @@ LL | | + LL | | &f; //~ ERROR: cannot borrow `f` as immutable because it is also borrowed as mutable | | ^- | |_____|| - | |borrow later used here + | |mutable borrow later used here | immutable borrow occurs here error[E0502]: cannot borrow `f` as mutable because it is also borrowed as immutable @@ -59,7 +59,7 @@ LL | | + LL | | &mut f; //~ ERROR: cannot borrow `f` as mutable because it is also borrowed as immutable | | ^^^^^- | |_____|____| - | | borrow later used here + | | immutable borrow later used here | mutable borrow occurs here error: aborting due to 6 previous errors diff --git a/src/test/ui/borrowck/borrow-tuple-fields.nll.stderr b/src/test/ui/borrowck/borrow-tuple-fields.nll.stderr index 855488e1eef..873581d9105 100644 --- a/src/test/ui/borrowck/borrow-tuple-fields.nll.stderr +++ b/src/test/ui/borrowck/borrow-tuple-fields.nll.stderr @@ -17,7 +17,7 @@ LL | let a = &x.0; LL | let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable because it is also borrowed as | ^^^^^^^^ mutable borrow occurs here LL | a.use_ref(); - | - borrow later used here + | - immutable borrow later used here error[E0499]: cannot borrow `x.0` as mutable more than once at a time --> $DIR/borrow-tuple-fields.rs:33:13 @@ -27,7 +27,7 @@ LL | let a = &mut x.0; LL | let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable more than once at a time | ^^^^^^^^ second mutable borrow occurs here LL | a.use_ref(); - | - borrow later used here + | - first borrow later used here error[E0505]: cannot move out of `x` because it is borrowed --> $DIR/borrow-tuple-fields.rs:38:13 @@ -47,7 +47,7 @@ LL | let a = &x.0; LL | let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable because it is also borrowed as | ^^^^^^^^ mutable borrow occurs here LL | a.use_ref(); - | - borrow later used here + | - immutable borrow later used here error[E0499]: cannot borrow `x.0` as mutable more than once at a time --> $DIR/borrow-tuple-fields.rs:48:13 @@ -57,7 +57,7 @@ LL | let a = &mut x.0; LL | let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable more than once at a time | ^^^^^^^^ second mutable borrow occurs here LL | a.use_mut(); - | - borrow later used here + | - first borrow later used here error: aborting due to 6 previous errors diff --git a/src/test/ui/borrowck/borrowck-anon-fields-struct.nll.stderr b/src/test/ui/borrowck/borrowck-anon-fields-struct.nll.stderr index 963a89ed44d..4d61840d9e8 100644 --- a/src/test/ui/borrowck/borrowck-anon-fields-struct.nll.stderr +++ b/src/test/ui/borrowck/borrowck-anon-fields-struct.nll.stderr @@ -8,7 +8,7 @@ LL | Y(ref mut b, _) => b //~ ERROR cannot borrow | ^^^^^^^^^ second mutable borrow occurs here ... LL | *a += 1; - | ------- borrow later used here + | ------- first borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-anon-fields-tuple.nll.stderr b/src/test/ui/borrowck/borrowck-anon-fields-tuple.nll.stderr index f06822f7bb6..f36741e9a02 100644 --- a/src/test/ui/borrowck/borrowck-anon-fields-tuple.nll.stderr +++ b/src/test/ui/borrowck/borrowck-anon-fields-tuple.nll.stderr @@ -8,7 +8,7 @@ LL | (ref mut b, _) => b //~ ERROR cannot borrow | ^^^^^^^^^ second mutable borrow occurs here ... LL | *a += 1; - | ------- borrow later used here + | ------- first borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-anon-fields-variant.nll.stderr b/src/test/ui/borrowck/borrowck-anon-fields-variant.nll.stderr index 05197205e81..17722bf226d 100644 --- a/src/test/ui/borrowck/borrowck-anon-fields-variant.nll.stderr +++ b/src/test/ui/borrowck/borrowck-anon-fields-variant.nll.stderr @@ -8,7 +8,7 @@ LL | Foo::Y(ref mut b, _) => b, //~ ERROR cannot borrow | ^^^^^^^^^ second mutable borrow occurs here ... LL | *a += 1; - | ------- borrow later used here + | ------- first borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-assign-comp-idx.nll.stderr b/src/test/ui/borrowck/borrowck-assign-comp-idx.nll.stderr index f4568d7c9eb..2dda17b38bb 100644 --- a/src/test/ui/borrowck/borrowck-assign-comp-idx.nll.stderr +++ b/src/test/ui/borrowck/borrowck-assign-comp-idx.nll.stderr @@ -8,19 +8,19 @@ LL | p[0] = 5; //~ ERROR cannot borrow | ^ mutable borrow occurs here LL | LL | println!("{}", *q); - | -- borrow later used here + | -- immutable borrow later used here error[E0502]: cannot borrow `p` as mutable because it is also borrowed as immutable --> $DIR/borrowck-assign-comp-idx.rs:37:9 | -LL | / borrow( -LL | | &p, - | | -- immutable borrow occurs here -LL | | || p[0] = 5); //~ ERROR cannot borrow `p` as mutable - | |_________^^_-_______- borrow later used here - | | | - | | second borrow occurs due to use of `p` in closure - | mutable borrow occurs here +LL | borrow( + | ------ immutable borrow later used by call +LL | &p, + | -- immutable borrow occurs here +LL | || p[0] = 5); //~ ERROR cannot borrow `p` as mutable + | ^^ - second borrow occurs due to use of `p` in closure + | | + | mutable borrow occurs here error: aborting due to 2 previous errors diff --git a/src/test/ui/borrowck/borrowck-autoref-3261.nll.stderr b/src/test/ui/borrowck/borrowck-autoref-3261.nll.stderr index eb26676cde2..f4ae5eaba16 100644 --- a/src/test/ui/borrowck/borrowck-autoref-3261.nll.stderr +++ b/src/test/ui/borrowck/borrowck-autoref-3261.nll.stderr @@ -1,21 +1,15 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/borrowck-autoref-3261.rs:25:9 | -LL | (&mut x).with( - | -------- - | | - | _____first mutable borrow occurs here - | | -LL | | |opt| { //~ ERROR cannot borrow `x` as mutable more than once at a time - | | ^^^^^ second mutable borrow occurs here -LL | | match opt { -LL | | &Either::Right(ref f) => { -LL | | x = X(Either::Left((0, 0))); - | | - second borrow occurs due to use of `x` in closure -... | -LL | | } -LL | | }) - | |__________- borrow later used here +LL | (&mut x).with( + | -------- ---- first borrow later used by call + | | + | first mutable borrow occurs here +LL | |opt| { //~ ERROR cannot borrow `x` as mutable more than once at a time + | ^^^^^ second mutable borrow occurs here +... +LL | x = X(Either::Left((0, 0))); + | - second borrow occurs due to use of `x` in closure error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-bad-nested-calls-free.nll.stderr b/src/test/ui/borrowck/borrowck-bad-nested-calls-free.nll.stderr index 73f533a6b96..77c637b7b4e 100644 --- a/src/test/ui/borrowck/borrowck-bad-nested-calls-free.nll.stderr +++ b/src/test/ui/borrowck/borrowck-bad-nested-calls-free.nll.stderr @@ -1,24 +1,22 @@ error[E0502]: cannot borrow `a` as mutable because it is also borrowed as immutable --> $DIR/borrowck-bad-nested-calls-free.rs:35:17 | -LL | / add( -LL | | &*a, - | | --- immutable borrow occurs here -LL | | rewrite(&mut a)); //~ ERROR cannot borrow - | |_________________^^^^^^_- borrow later used here - | | - | mutable borrow occurs here +LL | add( + | --- immutable borrow later used by call +LL | &*a, + | --- immutable borrow occurs here +LL | rewrite(&mut a)); //~ ERROR cannot borrow + | ^^^^^^ mutable borrow occurs here error[E0502]: cannot borrow `a` as mutable because it is also borrowed as immutable --> $DIR/borrowck-bad-nested-calls-free.rs:42:17 | -LL | / add( -LL | | &*a, - | | --- immutable borrow occurs here -LL | | rewrite(&mut a)); //~ ERROR cannot borrow - | |_________________^^^^^^_- borrow later used here - | | - | mutable borrow occurs here +LL | add( + | --- immutable borrow later used by call +LL | &*a, + | --- immutable borrow occurs here +LL | rewrite(&mut a)); //~ ERROR cannot borrow + | ^^^^^^ mutable borrow occurs here error: aborting due to 2 previous errors diff --git a/src/test/ui/borrowck/borrowck-bad-nested-calls-move.nll.stderr b/src/test/ui/borrowck/borrowck-bad-nested-calls-move.nll.stderr index ecb70068fed..d3ee9b2b2b2 100644 --- a/src/test/ui/borrowck/borrowck-bad-nested-calls-move.nll.stderr +++ b/src/test/ui/borrowck/borrowck-bad-nested-calls-move.nll.stderr @@ -1,24 +1,22 @@ error[E0505]: cannot move out of `a` because it is borrowed --> $DIR/borrowck-bad-nested-calls-move.rs:35:9 | -LL | / add( -LL | | &*a, - | | --- borrow of `*a` occurs here -LL | | a); //~ ERROR cannot move - | |_________^- borrow later used here - | | - | move out of `a` occurs here +LL | add( + | --- borrow later used by call +LL | &*a, + | --- borrow of `*a` occurs here +LL | a); //~ ERROR cannot move + | ^ move out of `a` occurs here error[E0505]: cannot move out of `a` because it is borrowed --> $DIR/borrowck-bad-nested-calls-move.rs:42:9 | -LL | / add( -LL | | &*a, - | | --- borrow of `*a` occurs here -LL | | a); //~ ERROR cannot move - | |_________^- borrow later used here - | | - | move out of `a` occurs here +LL | add( + | --- borrow later used by call +LL | &*a, + | --- borrow of `*a` occurs here +LL | a); //~ ERROR cannot move + | ^ move out of `a` occurs here error: aborting due to 2 previous errors diff --git a/src/test/ui/borrowck/borrowck-borrow-from-owned-ptr.nll.stderr b/src/test/ui/borrowck/borrowck-borrow-from-owned-ptr.nll.stderr index 603f4d63f7f..a368ef5b254 100644 --- a/src/test/ui/borrowck/borrowck-borrow-from-owned-ptr.nll.stderr +++ b/src/test/ui/borrowck/borrowck-borrow-from-owned-ptr.nll.stderr @@ -6,7 +6,7 @@ LL | let bar1 = &mut foo.bar1; LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow | ^^^^^^^^^^^^^ second mutable borrow occurs here LL | *bar1; - | ----- borrow later used here + | ----- first borrow later used here error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable --> $DIR/borrowck-borrow-from-owned-ptr.rs:36:17 @@ -16,7 +16,7 @@ LL | let bar1 = &mut foo.bar1; LL | let _bar2 = &foo.bar1; //~ ERROR cannot borrow | ^^^^^^^^^ immutable borrow occurs here LL | *bar1; - | ----- borrow later used here + | ----- mutable borrow later used here error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable --> $DIR/borrowck-borrow-from-owned-ptr.rs:43:17 @@ -26,7 +26,7 @@ LL | let bar1 = &foo.bar1; LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow | ^^^^^^^^^^^^^ mutable borrow occurs here LL | *bar1; - | ----- borrow later used here + | ----- immutable borrow later used here error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time --> $DIR/borrowck-borrow-from-owned-ptr.rs:73:21 @@ -38,7 +38,7 @@ LL | Foo { bar1: ref mut _bar1, bar2: _ } => {} | ^^^^^^^^^^^^^ second mutable borrow occurs here ... LL | *bar1; - | ----- borrow later used here + | ----- first borrow later used here error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable --> $DIR/borrowck-borrow-from-owned-ptr.rs:82:17 @@ -49,7 +49,7 @@ LL | let _foo1 = &foo.bar1; //~ ERROR cannot borrow | ^^^^^^^^^ immutable borrow occurs here LL | let _foo2 = &*foo; //~ ERROR cannot borrow LL | *bar1; - | ----- borrow later used here + | ----- mutable borrow later used here error[E0502]: cannot borrow `*foo` as immutable because it is also borrowed as mutable --> $DIR/borrowck-borrow-from-owned-ptr.rs:83:17 @@ -60,7 +60,7 @@ LL | let _foo1 = &foo.bar1; //~ ERROR cannot borrow LL | let _foo2 = &*foo; //~ ERROR cannot borrow | ^^^^^ immutable borrow occurs here LL | *bar1; - | ----- borrow later used here + | ----- mutable borrow later used here error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time --> $DIR/borrowck-borrow-from-owned-ptr.rs:90:17 @@ -70,7 +70,7 @@ LL | let bar1 = &mut foo.bar1.int1; LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow | ^^^^^^^^^^^^^ second mutable borrow occurs here LL | *bar1; - | ----- borrow later used here + | ----- first borrow later used here error[E0499]: cannot borrow `*foo` as mutable more than once at a time --> $DIR/borrowck-borrow-from-owned-ptr.rs:97:17 @@ -80,7 +80,7 @@ LL | let bar1 = &mut foo.bar1.int1; LL | let _foo2 = &mut *foo; //~ ERROR cannot borrow | ^^^^^^^^^ second mutable borrow occurs here LL | *bar1; - | ----- borrow later used here + | ----- first borrow later used here error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable --> $DIR/borrowck-borrow-from-owned-ptr.rs:104:17 @@ -90,7 +90,7 @@ LL | let bar1 = &foo.bar1.int1; LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow | ^^^^^^^^^^^^^ mutable borrow occurs here LL | *bar1; - | ----- borrow later used here + | ----- immutable borrow later used here error[E0502]: cannot borrow `*foo` as mutable because it is also borrowed as immutable --> $DIR/borrowck-borrow-from-owned-ptr.rs:111:17 @@ -100,7 +100,7 @@ LL | let bar1 = &foo.bar1.int1; LL | let _foo2 = &mut *foo; //~ ERROR cannot borrow | ^^^^^^^^^ mutable borrow occurs here LL | *bar1; - | ----- borrow later used here + | ----- immutable borrow later used here error[E0596]: cannot borrow `foo.bar1` as mutable, as `foo` is not declared as mutable --> $DIR/borrowck-borrow-from-owned-ptr.rs:132:16 diff --git a/src/test/ui/borrowck/borrowck-borrow-from-stack-variable.nll.stderr b/src/test/ui/borrowck/borrowck-borrow-from-stack-variable.nll.stderr index 3a215f2336a..d02cf6381d2 100644 --- a/src/test/ui/borrowck/borrowck-borrow-from-stack-variable.nll.stderr +++ b/src/test/ui/borrowck/borrowck-borrow-from-stack-variable.nll.stderr @@ -6,7 +6,7 @@ LL | let bar1 = &mut foo.bar1; LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow | ^^^^^^^^^^^^^ second mutable borrow occurs here LL | *bar1; - | ----- borrow later used here + | ----- first borrow later used here error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable --> $DIR/borrowck-borrow-from-stack-variable.rs:35:17 @@ -16,7 +16,7 @@ LL | let bar1 = &mut foo.bar1; LL | let _bar2 = &foo.bar1; //~ ERROR cannot borrow | ^^^^^^^^^ immutable borrow occurs here LL | *bar1; - | ----- borrow later used here + | ----- mutable borrow later used here error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable --> $DIR/borrowck-borrow-from-stack-variable.rs:42:17 @@ -26,7 +26,7 @@ LL | let bar1 = &foo.bar1; LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow | ^^^^^^^^^^^^^ mutable borrow occurs here LL | *bar1; - | ----- borrow later used here + | ----- immutable borrow later used here error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time --> $DIR/borrowck-borrow-from-stack-variable.rs:71:21 @@ -38,7 +38,7 @@ LL | Foo { bar1: ref mut _bar1, bar2: _ } => {} // | ^^^^^^^^^^^^^ second mutable borrow occurs here ... LL | *bar1; - | ----- borrow later used here + | ----- first borrow later used here error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable --> $DIR/borrowck-borrow-from-stack-variable.rs:80:17 @@ -49,7 +49,7 @@ LL | let _foo1 = &foo.bar1; //~ ERROR cannot borrow | ^^^^^^^^^ immutable borrow occurs here LL | let _foo2 = &foo; //~ ERROR cannot borrow LL | *bar1; - | ----- borrow later used here + | ----- mutable borrow later used here error[E0502]: cannot borrow `foo` as immutable because it is also borrowed as mutable --> $DIR/borrowck-borrow-from-stack-variable.rs:81:17 @@ -60,7 +60,7 @@ LL | let _foo1 = &foo.bar1; //~ ERROR cannot borrow LL | let _foo2 = &foo; //~ ERROR cannot borrow | ^^^^ immutable borrow occurs here LL | *bar1; - | ----- borrow later used here + | ----- mutable borrow later used here error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time --> $DIR/borrowck-borrow-from-stack-variable.rs:88:17 @@ -70,7 +70,7 @@ LL | let bar1 = &mut foo.bar1.int1; LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow | ^^^^^^^^^^^^^ second mutable borrow occurs here LL | *bar1; - | ----- borrow later used here + | ----- first borrow later used here error[E0499]: cannot borrow `foo` as mutable more than once at a time --> $DIR/borrowck-borrow-from-stack-variable.rs:95:17 @@ -80,7 +80,7 @@ LL | let bar1 = &mut foo.bar1.int1; LL | let _foo2 = &mut foo; //~ ERROR cannot borrow | ^^^^^^^^ second mutable borrow occurs here LL | *bar1; - | ----- borrow later used here + | ----- first borrow later used here error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable --> $DIR/borrowck-borrow-from-stack-variable.rs:102:17 @@ -90,7 +90,7 @@ LL | let bar1 = &foo.bar1.int1; LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow | ^^^^^^^^^^^^^ mutable borrow occurs here LL | *bar1; - | ----- borrow later used here + | ----- immutable borrow later used here error[E0502]: cannot borrow `foo` as mutable because it is also borrowed as immutable --> $DIR/borrowck-borrow-from-stack-variable.rs:109:17 @@ -100,7 +100,7 @@ LL | let bar1 = &foo.bar1.int1; LL | let _foo2 = &mut foo; //~ ERROR cannot borrow | ^^^^^^^^ mutable borrow occurs here LL | *bar1; - | ----- borrow later used here + | ----- immutable borrow later used here error[E0596]: cannot borrow `foo.bar1` as mutable, as `foo` is not declared as mutable --> $DIR/borrowck-borrow-from-stack-variable.rs:130:16 diff --git a/src/test/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.nll.stderr b/src/test/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.nll.stderr index 8c30e6ac002..fb04b3b93dc 100644 --- a/src/test/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.nll.stderr +++ b/src/test/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.nll.stderr @@ -15,7 +15,7 @@ LL | let t1 = &mut *t0; LL | let p: &isize = &**t0; //~ ERROR cannot borrow | ^^^^^ immutable borrow occurs here LL | **t1 = 22; - | --------- borrow later used here + | --------- mutable borrow later used here error[E0596]: cannot borrow `**t0` as mutable, as it is behind a `&` reference --> $DIR/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs:29:26 diff --git a/src/test/ui/borrowck/borrowck-borrow-mut-object-twice.nll.stderr b/src/test/ui/borrowck/borrowck-borrow-mut-object-twice.nll.stderr index 9c3d0b170d9..65c4a392887 100644 --- a/src/test/ui/borrowck/borrowck-borrow-mut-object-twice.nll.stderr +++ b/src/test/ui/borrowck/borrowck-borrow-mut-object-twice.nll.stderr @@ -6,7 +6,7 @@ LL | let y = x.f1(); LL | x.f2(); //~ ERROR cannot borrow `*x` as mutable | ^ second mutable borrow occurs here LL | y.use_ref(); - | - borrow later used here + | - first borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-closures-mut-and-imm.ast.nll.stderr b/src/test/ui/borrowck/borrowck-closures-mut-and-imm.ast.nll.stderr index f24d0ed046a..814fb7bbedc 100644 --- a/src/test/ui/borrowck/borrowck-closures-mut-and-imm.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-closures-mut-and-imm.ast.nll.stderr @@ -11,7 +11,7 @@ LL | let c2 = || x * 5; //[ast]~ ERROR cannot borrow `x` | immutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable LL | drop(c1); - | -- borrow later used here + | -- mutable borrow later used here error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable --> $DIR/borrowck-closures-mut-and-imm.rs:39:14 @@ -26,7 +26,7 @@ LL | let c2 = || get(&x); //[ast]~ ERROR cannot borrow `x` | immutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable LL | drop(c1); - | -- borrow later used here + | -- mutable borrow later used here error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable --> $DIR/borrowck-closures-mut-and-imm.rs:47:14 @@ -41,7 +41,7 @@ LL | let c2 = || x * 5; //[ast]~ ERROR cannot borrow `x` | immutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable LL | drop(c1); - | -- borrow later used here + | -- mutable borrow later used here error[E0506]: cannot assign to `x` because it is borrowed --> $DIR/borrowck-closures-mut-and-imm.rs:55:5 @@ -108,7 +108,7 @@ LL | let c2 = || *x.f = 5; //[ast]~ ERROR cannot borrow `x` as mutable | mutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable LL | drop(c1); - | -- borrow later used here + | -- immutable borrow later used here error: aborting due to 8 previous errors diff --git a/src/test/ui/borrowck/borrowck-closures-mut-and-imm.mir.stderr b/src/test/ui/borrowck/borrowck-closures-mut-and-imm.mir.stderr index f24d0ed046a..814fb7bbedc 100644 --- a/src/test/ui/borrowck/borrowck-closures-mut-and-imm.mir.stderr +++ b/src/test/ui/borrowck/borrowck-closures-mut-and-imm.mir.stderr @@ -11,7 +11,7 @@ LL | let c2 = || x * 5; //[ast]~ ERROR cannot borrow `x` | immutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable LL | drop(c1); - | -- borrow later used here + | -- mutable borrow later used here error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable --> $DIR/borrowck-closures-mut-and-imm.rs:39:14 @@ -26,7 +26,7 @@ LL | let c2 = || get(&x); //[ast]~ ERROR cannot borrow `x` | immutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable LL | drop(c1); - | -- borrow later used here + | -- mutable borrow later used here error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable --> $DIR/borrowck-closures-mut-and-imm.rs:47:14 @@ -41,7 +41,7 @@ LL | let c2 = || x * 5; //[ast]~ ERROR cannot borrow `x` | immutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable LL | drop(c1); - | -- borrow later used here + | -- mutable borrow later used here error[E0506]: cannot assign to `x` because it is borrowed --> $DIR/borrowck-closures-mut-and-imm.rs:55:5 @@ -108,7 +108,7 @@ LL | let c2 = || *x.f = 5; //[ast]~ ERROR cannot borrow `x` as mutable | mutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable LL | drop(c1); - | -- borrow later used here + | -- immutable borrow later used here error: aborting due to 8 previous errors diff --git a/src/test/ui/borrowck/borrowck-closures-two-mut-fail.nll.stderr b/src/test/ui/borrowck/borrowck-closures-two-mut-fail.nll.stderr index c96799c85f2..fea61420b19 100644 --- a/src/test/ui/borrowck/borrowck-closures-two-mut-fail.nll.stderr +++ b/src/test/ui/borrowck/borrowck-closures-two-mut-fail.nll.stderr @@ -10,7 +10,7 @@ LL | let c2 = to_fn_mut(|| x = 5); //~ ERROR cannot borrow `x` as mutable mo | | | second mutable borrow occurs here LL | c1; - | -- borrow later used here + | -- first borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/borrowck-closures-two-mut-fail.rs:37:24 @@ -24,7 +24,7 @@ LL | let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as muta | | | second mutable borrow occurs here LL | c1; - | -- borrow later used here + | -- first borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/borrowck-closures-two-mut-fail.rs:44:24 @@ -38,7 +38,7 @@ LL | let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as muta | | | second mutable borrow occurs here LL | c1; - | -- borrow later used here + | -- first borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/borrowck-closures-two-mut-fail.rs:51:24 @@ -53,7 +53,7 @@ LL | let c2 = to_fn_mut(|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nes | second mutable borrow occurs here LL | //~^ ERROR cannot borrow `x` as mutable more than once LL | c1; - | -- borrow later used here + | -- first borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/borrowck-closures-two-mut-fail.rs:63:24 @@ -68,7 +68,7 @@ LL | let c2 = to_fn_mut(|| set(&mut *x.f)); | second mutable borrow occurs here LL | //~^ ERROR cannot borrow `x` as mutable more than once LL | c1; - | -- borrow later used here + | -- first borrow later used here error: aborting due to 5 previous errors diff --git a/src/test/ui/borrowck/borrowck-closures-two-mut.stderr b/src/test/ui/borrowck/borrowck-closures-two-mut.stderr index 6186c383919..bbfe3770236 100644 --- a/src/test/ui/borrowck/borrowck-closures-two-mut.stderr +++ b/src/test/ui/borrowck/borrowck-closures-two-mut.stderr @@ -86,7 +86,7 @@ LL | let c2 = to_fn_mut(|| x = 5); //~ ERROR cannot borrow `x` as mutable mo | second mutable borrow occurs here LL | //~| ERROR cannot borrow `x` as mutable more than once LL | drop((c1, c2)); - | -- borrow later used here + | -- first borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir) --> $DIR/borrowck-closures-two-mut.rs:36:24 @@ -101,7 +101,7 @@ LL | let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as muta | second mutable borrow occurs here LL | //~| ERROR cannot borrow `x` as mutable more than once LL | drop((c1, c2)); - | -- borrow later used here + | -- first borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir) --> $DIR/borrowck-closures-two-mut.rs:44:24 @@ -116,7 +116,7 @@ LL | let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as muta | second mutable borrow occurs here LL | //~| ERROR cannot borrow `x` as mutable more than once LL | drop((c1, c2)); - | -- borrow later used here + | -- first borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir) --> $DIR/borrowck-closures-two-mut.rs:52:24 @@ -131,7 +131,7 @@ LL | let c2 = to_fn_mut(|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nes | second mutable borrow occurs here ... LL | drop((c1, c2)); - | -- borrow later used here + | -- first borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir) --> $DIR/borrowck-closures-two-mut.rs:65:24 @@ -146,7 +146,7 @@ LL | let c2 = to_fn_mut(|| set(&mut *x.f)); | second mutable borrow occurs here ... LL | drop((c1, c2)); - | -- borrow later used here + | -- first borrow later used here error: aborting due to 10 previous errors diff --git a/src/test/ui/borrowck/borrowck-closures-unique-imm.nll.stderr b/src/test/ui/borrowck/borrowck-closures-unique-imm.nll.stderr index b8f17570a64..aca4f309257 100644 --- a/src/test/ui/borrowck/borrowck-closures-unique-imm.nll.stderr +++ b/src/test/ui/borrowck/borrowck-closures-unique-imm.nll.stderr @@ -6,7 +6,7 @@ LL | let p = &this.x; LL | &mut this.x; //~ ERROR cannot borrow | ^^^^^^^^^^^ mutable borrow occurs here LL | p.use_ref(); - | - borrow later used here + | - immutable borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-closures-unique.nll.stderr b/src/test/ui/borrowck/borrowck-closures-unique.nll.stderr index 17519ccb143..231ae53fe82 100644 --- a/src/test/ui/borrowck/borrowck-closures-unique.nll.stderr +++ b/src/test/ui/borrowck/borrowck-closures-unique.nll.stderr @@ -10,7 +10,7 @@ LL | let c2 = || set(x); //~ ERROR closure requires unique access to `x` | | | closure construction occurs here LL | c1; - | -- borrow later used here + | -- first borrow later used here error[E0500]: closure requires unique access to `x` but it is already borrowed --> $DIR/borrowck-closures-unique.rs:42:14 @@ -24,7 +24,7 @@ LL | let c2 = || { get(x); set(x); }; //~ ERROR closure requires unique acce | | | closure construction occurs here LL | c1; - | -- borrow later used here + | -- first borrow later used here error[E0524]: two closures require unique access to `x` at the same time --> $DIR/borrowck-closures-unique.rs:48:14 @@ -38,7 +38,7 @@ LL | let c2 = || set(x); //~ ERROR two closures require unique access to `x` | | | second closure is constructed here LL | c1; - | -- borrow later used here + | -- first borrow later used here error[E0594]: cannot assign to `x`, as it is not declared as mutable --> $DIR/borrowck-closures-unique.rs:57:38 diff --git a/src/test/ui/borrowck/borrowck-closures-use-after-free.nll.stderr b/src/test/ui/borrowck/borrowck-closures-use-after-free.nll.stderr index dc73929989c..90eb7fda026 100644 --- a/src/test/ui/borrowck/borrowck-closures-use-after-free.nll.stderr +++ b/src/test/ui/borrowck/borrowck-closures-use-after-free.nll.stderr @@ -7,10 +7,9 @@ LL | ptr = box Foo { x: ptr.x + 1 }; | --- first borrow occurs due to use of `ptr` in closure LL | }; LL | test(&*ptr); //~ ERROR cannot borrow `*ptr` - | -----^^^^^- - | | | - | | immutable borrow occurs here - | borrow later used here + | ---- ^^^^^ immutable borrow occurs here + | | + | mutable borrow later used by call error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-describe-lvalue.ast.nll.stderr b/src/test/ui/borrowck/borrowck-describe-lvalue.ast.nll.stderr index e417dadf6df..ac6cfac2a16 100644 --- a/src/test/ui/borrowck/borrowck-describe-lvalue.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-describe-lvalue.ast.nll.stderr @@ -7,7 +7,7 @@ LL | &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than | ^^^^^^ second mutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time LL | *y = 1; - | ------ borrow later used here + | ------ first borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/borrowck-describe-lvalue.rs:307:20 @@ -18,7 +18,7 @@ LL | &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable mo | ^^^^^^ second mutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time LL | *y = 1; - | ------ borrow later used here + | ------ first borrow later used here error: unsatisfied lifetime constraints --> $DIR/borrowck-describe-lvalue.rs:305:16 @@ -269,7 +269,7 @@ LL | E::A(ref ax) => | ^^^^^^ immutable borrow occurs here ... LL | drop(x); - | - borrow later used here + | - mutable borrow later used here error[E0502]: cannot borrow `e.x` as immutable because it is also borrowed as mutable --> $DIR/borrowck-describe-lvalue.rs:207:23 @@ -281,7 +281,7 @@ LL | E::B { x: ref bx } => | ^^^^^^ immutable borrow occurs here ... LL | drop(x); - | - borrow later used here + | - mutable borrow later used here error[E0502]: cannot borrow `s.y.0` as immutable because it is also borrowed as mutable --> $DIR/borrowck-describe-lvalue.rs:221:22 @@ -293,7 +293,7 @@ LL | S { y: (ref y0, _), .. } => | ^^^^^^ immutable borrow occurs here ... LL | drop(x); - | - borrow later used here + | - mutable borrow later used here error[E0502]: cannot borrow `s.x.y` as immutable because it is also borrowed as mutable --> $DIR/borrowck-describe-lvalue.rs:228:28 @@ -305,7 +305,7 @@ LL | S { x: F { y: ref x0, .. }, .. } => | ^^^^^^ immutable borrow occurs here ... LL | drop(x); - | - borrow later used here + | - mutable borrow later used here error[E0503]: cannot use `*v` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:271:9 @@ -339,7 +339,7 @@ LL | &[_, F {x: ref xf, ..}] => println!("{}", xf), | ^^^^^^ immutable borrow occurs here ... LL | drop(x); - | - borrow later used here + | - mutable borrow later used here error[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable --> $DIR/borrowck-describe-lvalue.rs:245:29 @@ -350,7 +350,7 @@ LL | let p: &'a u8 = &*block.current; | ^^^^^^^^^^^^^^^ immutable borrow occurs here ... LL | drop(x); - | - borrow later used here + | - mutable borrow later used here error[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable --> $DIR/borrowck-describe-lvalue.rs:260:33 @@ -361,7 +361,7 @@ LL | let p : *const u8 = &*(*block).current; | ^^^^^^^^^^^^^^^^^^ immutable borrow occurs here ... LL | drop(x); - | - borrow later used here + | - mutable borrow later used here error[E0382]: use of moved value: `x` --> $DIR/borrowck-describe-lvalue.rs:318:22 diff --git a/src/test/ui/borrowck/borrowck-describe-lvalue.mir.stderr b/src/test/ui/borrowck/borrowck-describe-lvalue.mir.stderr index e417dadf6df..ac6cfac2a16 100644 --- a/src/test/ui/borrowck/borrowck-describe-lvalue.mir.stderr +++ b/src/test/ui/borrowck/borrowck-describe-lvalue.mir.stderr @@ -7,7 +7,7 @@ LL | &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than | ^^^^^^ second mutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time LL | *y = 1; - | ------ borrow later used here + | ------ first borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/borrowck-describe-lvalue.rs:307:20 @@ -18,7 +18,7 @@ LL | &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable mo | ^^^^^^ second mutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time LL | *y = 1; - | ------ borrow later used here + | ------ first borrow later used here error: unsatisfied lifetime constraints --> $DIR/borrowck-describe-lvalue.rs:305:16 @@ -269,7 +269,7 @@ LL | E::A(ref ax) => | ^^^^^^ immutable borrow occurs here ... LL | drop(x); - | - borrow later used here + | - mutable borrow later used here error[E0502]: cannot borrow `e.x` as immutable because it is also borrowed as mutable --> $DIR/borrowck-describe-lvalue.rs:207:23 @@ -281,7 +281,7 @@ LL | E::B { x: ref bx } => | ^^^^^^ immutable borrow occurs here ... LL | drop(x); - | - borrow later used here + | - mutable borrow later used here error[E0502]: cannot borrow `s.y.0` as immutable because it is also borrowed as mutable --> $DIR/borrowck-describe-lvalue.rs:221:22 @@ -293,7 +293,7 @@ LL | S { y: (ref y0, _), .. } => | ^^^^^^ immutable borrow occurs here ... LL | drop(x); - | - borrow later used here + | - mutable borrow later used here error[E0502]: cannot borrow `s.x.y` as immutable because it is also borrowed as mutable --> $DIR/borrowck-describe-lvalue.rs:228:28 @@ -305,7 +305,7 @@ LL | S { x: F { y: ref x0, .. }, .. } => | ^^^^^^ immutable borrow occurs here ... LL | drop(x); - | - borrow later used here + | - mutable borrow later used here error[E0503]: cannot use `*v` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:271:9 @@ -339,7 +339,7 @@ LL | &[_, F {x: ref xf, ..}] => println!("{}", xf), | ^^^^^^ immutable borrow occurs here ... LL | drop(x); - | - borrow later used here + | - mutable borrow later used here error[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable --> $DIR/borrowck-describe-lvalue.rs:245:29 @@ -350,7 +350,7 @@ LL | let p: &'a u8 = &*block.current; | ^^^^^^^^^^^^^^^ immutable borrow occurs here ... LL | drop(x); - | - borrow later used here + | - mutable borrow later used here error[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable --> $DIR/borrowck-describe-lvalue.rs:260:33 @@ -361,7 +361,7 @@ LL | let p : *const u8 = &*(*block).current; | ^^^^^^^^^^^^^^^^^^ immutable borrow occurs here ... LL | drop(x); - | - borrow later used here + | - mutable borrow later used here error[E0382]: use of moved value: `x` --> $DIR/borrowck-describe-lvalue.rs:318:22 diff --git a/src/test/ui/borrowck/borrowck-field-sensitivity.nll.stderr b/src/test/ui/borrowck/borrowck-field-sensitivity.nll.stderr index fb300d32b05..6ac5fef1416 100644 --- a/src/test/ui/borrowck/borrowck-field-sensitivity.nll.stderr +++ b/src/test/ui/borrowck/borrowck-field-sensitivity.nll.stderr @@ -62,7 +62,7 @@ LL | let p = &mut x.a; LL | let q = &mut x.a; //~ ERROR cannot borrow `x.a` as mutable more than once at a time | ^^^^^^^^ second mutable borrow occurs here LL | drop(*p); - | -- borrow later used here + | -- first borrow later used here error[E0382]: use of moved value: `x.b` --> $DIR/borrowck-field-sensitivity.rs:66:10 diff --git a/src/test/ui/borrowck/borrowck-for-loop-head-linkage.nll.stderr b/src/test/ui/borrowck/borrowck-for-loop-head-linkage.nll.stderr index b7803cbc804..a6487ede6f8 100644 --- a/src/test/ui/borrowck/borrowck-for-loop-head-linkage.nll.stderr +++ b/src/test/ui/borrowck/borrowck-for-loop-head-linkage.nll.stderr @@ -5,7 +5,7 @@ LL | for &x in &vector { | ------- | | | immutable borrow occurs here - | borrow used here, in later iteration of loop + | immutable borrow used here, in later iteration of loop LL | let cap = vector.capacity(); LL | vector.extend(repeat(0)); //~ ERROR cannot borrow | ^^^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here @@ -17,7 +17,7 @@ LL | for &x in &vector { | ------- | | | immutable borrow occurs here - | borrow used here, in later iteration of loop + | immutable borrow used here, in later iteration of loop ... LL | vector[1] = 5; //~ ERROR cannot borrow | ^^^^^^ mutable borrow occurs here diff --git a/src/test/ui/borrowck/borrowck-insert-during-each.nll.stderr b/src/test/ui/borrowck/borrowck-insert-during-each.nll.stderr index e403b076ab4..123d475f1c0 100644 --- a/src/test/ui/borrowck/borrowck-insert-during-each.nll.stderr +++ b/src/test/ui/borrowck/borrowck-insert-during-each.nll.stderr @@ -1,34 +1,28 @@ error[E0501]: cannot borrow `*f` as mutable because previous closure requires unique access --> $DIR/borrowck-insert-during-each.rs:26:3 | -LL | f.foo( - | ___^ - | |___| - | || -LL | || |a| { //~ ERROR closure requires unique access to `f` - | || --- closure construction occurs here -LL | || f.n.insert(*a); - | || - first borrow occurs due to use of `f` in closure -LL | || }) - | || ^ - | ||__________| - | |___________borrow occurs here - | borrow later used here - -error[E0500]: closure requires unique access to `f` but it is already borrowed - --> $DIR/borrowck-insert-during-each.rs:27:9 - | LL | f.foo( - | - - | | - | ___borrow occurs here + | ^ --- first borrow later used by call + | ___| | | LL | | |a| { //~ ERROR closure requires unique access to `f` - | | ^^^ closure construction occurs here + | | --- closure construction occurs here LL | | f.n.insert(*a); - | | - second borrow occurs due to use of `f` in closure + | | - first borrow occurs due to use of `f` in closure LL | | }) - | |__________- borrow later used here + | |__________^ borrow occurs here + +error[E0500]: closure requires unique access to `f` but it is already borrowed + --> $DIR/borrowck-insert-during-each.rs:27:9 + | +LL | f.foo( + | - --- first borrow later used by call + | | + | borrow occurs here +LL | |a| { //~ ERROR closure requires unique access to `f` + | ^^^ closure construction occurs here +LL | f.n.insert(*a); + | - second borrow occurs due to use of `f` in closure error: aborting due to 2 previous errors diff --git a/src/test/ui/borrowck/borrowck-lend-flow-if.nll.stderr b/src/test/ui/borrowck/borrowck-lend-flow-if.nll.stderr index 0f0eed4a051..f1c33a596cb 100644 --- a/src/test/ui/borrowck/borrowck-lend-flow-if.nll.stderr +++ b/src/test/ui/borrowck/borrowck-lend-flow-if.nll.stderr @@ -7,7 +7,7 @@ LL | } LL | borrow_mut(&mut *v); //~ ERROR cannot borrow | ^^^^^^^ mutable borrow occurs here LL | _w.use_ref(); - | -- borrow later used here + | -- immutable borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-lend-flow-loop.nll.stderr b/src/test/ui/borrowck/borrowck-lend-flow-loop.nll.stderr index 81aa1e2c960..388fc9c5fa8 100644 --- a/src/test/ui/borrowck/borrowck-lend-flow-loop.nll.stderr +++ b/src/test/ui/borrowck/borrowck-lend-flow-loop.nll.stderr @@ -8,13 +8,13 @@ LL | borrow(&*v); //~ ERROR cannot borrow | ^^^ immutable borrow occurs here LL | } LL | *x = box 5; - | -- borrow used here, in later iteration of loop + | -- mutable borrow used here, in later iteration of loop error[E0502]: cannot borrow `*v` as immutable because it is also borrowed as mutable --> $DIR/borrowck-lend-flow-loop.rs:109:16 | LL | **x += 1; - | -------- borrow used here, in later iteration of loop + | -------- mutable borrow used here, in later iteration of loop LL | borrow(&*v); //~ ERROR cannot borrow | ^^^ immutable borrow occurs here LL | if cond2 { diff --git a/src/test/ui/borrowck/borrowck-lend-flow.nll.stderr b/src/test/ui/borrowck/borrowck-lend-flow.nll.stderr index 7ebc2ce47cd..e97ba68cd5c 100644 --- a/src/test/ui/borrowck/borrowck-lend-flow.nll.stderr +++ b/src/test/ui/borrowck/borrowck-lend-flow.nll.stderr @@ -6,7 +6,7 @@ LL | let _w = &v; LL | borrow_mut(&mut *v); //~ ERROR cannot borrow | ^^^^^^^ mutable borrow occurs here LL | _w.use_ref(); - | -- borrow later used here + | -- immutable borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-loan-blocks-mut-uniq.nll.stderr b/src/test/ui/borrowck/borrowck-loan-blocks-mut-uniq.nll.stderr index 5c3cd46a87d..b181fcf8b54 100644 --- a/src/test/ui/borrowck/borrowck-loan-blocks-mut-uniq.nll.stderr +++ b/src/test/ui/borrowck/borrowck-loan-blocks-mut-uniq.nll.stderr @@ -1,18 +1,14 @@ error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable --> $DIR/borrowck-loan-blocks-mut-uniq.rs:20:12 | -LL | borrow(&*v, - | - --- immutable borrow occurs here - | _____| - | | -LL | | |w| { //~ ERROR cannot borrow `v` as mutable - | | ^^^ mutable borrow occurs here -LL | | v = box 4; - | | - second borrow occurs due to use of `v` in closure -LL | | assert_eq!(*v, 3); -LL | | assert_eq!(*w, 4); -LL | | }) - | |__________- borrow later used here +LL | borrow(&*v, + | ------ --- immutable borrow occurs here + | | + | immutable borrow later used by call +LL | |w| { //~ ERROR cannot borrow `v` as mutable + | ^^^ mutable borrow occurs here +LL | v = box 4; + | - second borrow occurs due to use of `v` in closure error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-loan-rcvr-overloaded-op.nll.stderr b/src/test/ui/borrowck/borrowck-loan-rcvr-overloaded-op.nll.stderr index b7c87162587..6f08c13caa4 100644 --- a/src/test/ui/borrowck/borrowck-loan-rcvr-overloaded-op.nll.stderr +++ b/src/test/ui/borrowck/borrowck-loan-rcvr-overloaded-op.nll.stderr @@ -20,7 +20,7 @@ LL | p.times(3); //~ ERROR cannot borrow `p` | ^ immutable borrow occurs here LL | LL | *q + 3; // OK to use the new alias `q` - | -- borrow later used here + | -- mutable borrow later used here error: aborting due to 2 previous errors diff --git a/src/test/ui/borrowck/borrowck-loan-rcvr.nll.stderr b/src/test/ui/borrowck/borrowck-loan-rcvr.nll.stderr index a5b81027c2f..18c2d67f6b0 100644 --- a/src/test/ui/borrowck/borrowck-loan-rcvr.nll.stderr +++ b/src/test/ui/borrowck/borrowck-loan-rcvr.nll.stderr @@ -1,15 +1,13 @@ error[E0502]: cannot borrow `p` as mutable because it is also borrowed as immutable --> $DIR/borrowck-loan-rcvr.rs:34:14 | -LL | p.blockm(|| { //~ ERROR cannot borrow `p` as mutable - | - ^^ mutable borrow occurs here - | | - | _____immutable borrow occurs here - | | -LL | | p.x = 10; - | | - second borrow occurs due to use of `p` in closure -LL | | }) - | |______- borrow later used here +LL | p.blockm(|| { //~ ERROR cannot borrow `p` as mutable + | - ------ ^^ mutable borrow occurs here + | | | + | | immutable borrow later used by call + | immutable borrow occurs here +LL | p.x = 10; + | - second borrow occurs due to use of `p` in closure error[E0502]: cannot borrow `p` as immutable because it is also borrowed as mutable --> $DIR/borrowck-loan-rcvr.rs:45:5 @@ -20,7 +18,7 @@ LL | p.impurem(); //~ ERROR cannot borrow | ^ immutable borrow occurs here LL | LL | l.x += 1; - | -------- borrow later used here + | -------- mutable borrow later used here error: aborting due to 2 previous errors diff --git a/src/test/ui/borrowck/borrowck-loan-vec-content.nll.stderr b/src/test/ui/borrowck/borrowck-loan-vec-content.nll.stderr index 492e90914ea..2b22a125d3f 100644 --- a/src/test/ui/borrowck/borrowck-loan-vec-content.nll.stderr +++ b/src/test/ui/borrowck/borrowck-loan-vec-content.nll.stderr @@ -1,15 +1,14 @@ error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable --> $DIR/borrowck-loan-vec-content.rs:28:9 | -LL | / takes_imm_elt( -LL | | &v[0], - | | - immutable borrow occurs here -LL | | || { //~ ERROR cannot borrow `v` as mutable - | | ^^ mutable borrow occurs here -LL | | v[1] = 4; - | | - second borrow occurs due to use of `v` in closure -LL | | }) - | |__________- borrow later used here +LL | takes_imm_elt( + | ------------- immutable borrow later used by call +LL | &v[0], + | - immutable borrow occurs here +LL | || { //~ ERROR cannot borrow `v` as mutable + | ^^ mutable borrow occurs here +LL | v[1] = 4; + | - second borrow occurs due to use of `v` in closure error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.ast.nll.stderr b/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.ast.nll.stderr index 19ec9cf7ded..5301ee7a403 100644 --- a/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.ast.nll.stderr @@ -4,7 +4,7 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time LL | 1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] | ---- ^^^^^^ second mutable borrow occurs here | | - | borrow used here, in later iteration of loop + | first borrow used here, in later iteration of loop ... LL | _ => { addr.push(&mut x); } //[ast]~ ERROR [E0499] | ------ first mutable borrow occurs here @@ -13,7 +13,7 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/borrowck-mut-borrow-linear-errors.rs:25:30 | LL | 1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] - | ---- borrow used here, in later iteration of loop + | ---- first borrow used here, in later iteration of loop LL | //[mir]~^ ERROR [E0499] LL | 2 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] | ^^^^^^ second mutable borrow occurs here diff --git a/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.mir.stderr b/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.mir.stderr index 19ec9cf7ded..5301ee7a403 100644 --- a/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.mir.stderr +++ b/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.mir.stderr @@ -4,7 +4,7 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time LL | 1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] | ---- ^^^^^^ second mutable borrow occurs here | | - | borrow used here, in later iteration of loop + | first borrow used here, in later iteration of loop ... LL | _ => { addr.push(&mut x); } //[ast]~ ERROR [E0499] | ------ first mutable borrow occurs here @@ -13,7 +13,7 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/borrowck-mut-borrow-linear-errors.rs:25:30 | LL | 1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] - | ---- borrow used here, in later iteration of loop + | ---- first borrow used here, in later iteration of loop LL | //[mir]~^ ERROR [E0499] LL | 2 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] | ^^^^^^ second mutable borrow occurs here diff --git a/src/test/ui/borrowck/borrowck-mut-borrow-of-mut-base-ptr.nll.stderr b/src/test/ui/borrowck/borrowck-mut-borrow-of-mut-base-ptr.nll.stderr index 0684e787bae..57f9a2c1778 100644 --- a/src/test/ui/borrowck/borrowck-mut-borrow-of-mut-base-ptr.nll.stderr +++ b/src/test/ui/borrowck/borrowck-mut-borrow-of-mut-base-ptr.nll.stderr @@ -7,7 +7,7 @@ LL | let mut t2 = &mut t0; //~ ERROR cannot borrow `t0` | ^^^^^^^ mutable borrow occurs here LL | **t2 += 1; // Mutates `*t0` LL | p.use_ref(); - | - borrow later used here + | - immutable borrow later used here error[E0499]: cannot borrow `t0` as mutable more than once at a time --> $DIR/borrowck-mut-borrow-of-mut-base-ptr.rs:29:18 @@ -18,7 +18,7 @@ LL | let mut t2 = &mut t0; //~ ERROR cannot borrow `t0` | ^^^^^^^ second mutable borrow occurs here LL | **t2 += 1; // Mutates `*t0` but not through `*p` LL | p.use_mut(); - | - borrow later used here + | - first borrow later used here error: aborting due to 2 previous errors diff --git a/src/test/ui/borrowck/borrowck-object-lifetime.nll.stderr b/src/test/ui/borrowck/borrowck-object-lifetime.nll.stderr index e4e2dfe86bd..8a9aaa9d895 100644 --- a/src/test/ui/borrowck/borrowck-object-lifetime.nll.stderr +++ b/src/test/ui/borrowck/borrowck-object-lifetime.nll.stderr @@ -6,7 +6,7 @@ LL | let y = x.borrowed(); LL | let z = x.mut_borrowed(); //~ ERROR cannot borrow | ^^^^^^^^^^^^^^^^ mutable borrow occurs here LL | y.use_ref(); - | - borrow later used here + | - immutable borrow later used here error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable --> $DIR/borrowck-object-lifetime.rs:36:13 @@ -16,7 +16,7 @@ LL | let y = x.borrowed(); LL | let z = &mut x; //~ ERROR cannot borrow | ^^^^^^ mutable borrow occurs here LL | y.use_ref(); - | - borrow later used here + | - immutable borrow later used here error: aborting due to 2 previous errors diff --git a/src/test/ui/borrowck/borrowck-overloaded-index-autoderef.nll.stderr b/src/test/ui/borrowck/borrowck-overloaded-index-autoderef.nll.stderr index 994492d8575..fd4c380ea05 100644 --- a/src/test/ui/borrowck/borrowck-overloaded-index-autoderef.nll.stderr +++ b/src/test/ui/borrowck/borrowck-overloaded-index-autoderef.nll.stderr @@ -6,7 +6,7 @@ LL | let p = &mut f[&s]; LL | let q = &f[&s]; //~ ERROR cannot borrow | ^ immutable borrow occurs here LL | p.use_mut(); - | - borrow later used here + | - mutable borrow later used here error[E0499]: cannot borrow `*f` as mutable more than once at a time --> $DIR/borrowck-overloaded-index-autoderef.rs:53:18 @@ -16,7 +16,7 @@ LL | let p = &mut f[&s]; LL | let q = &mut f[&s]; //~ ERROR cannot borrow | ^ second mutable borrow occurs here LL | p.use_mut(); - | - borrow later used here + | - first borrow later used here error[E0499]: cannot borrow `f.foo` as mutable more than once at a time --> $DIR/borrowck-overloaded-index-autoderef.rs:63:18 @@ -26,7 +26,7 @@ LL | let p = &mut f.foo[&s]; LL | let q = &mut f.foo[&s]; //~ ERROR cannot borrow | ^^^^^ second mutable borrow occurs here LL | p.use_mut(); - | - borrow later used here + | - first borrow later used here error[E0502]: cannot borrow `f.foo` as mutable because it is also borrowed as immutable --> $DIR/borrowck-overloaded-index-autoderef.rs:75:18 @@ -36,7 +36,7 @@ LL | let p = &f.foo[&s]; LL | let q = &mut f.foo[&s]; //~ ERROR cannot borrow | ^^^^^ mutable borrow occurs here LL | p.use_ref(); - | - borrow later used here + | - immutable borrow later used here error[E0506]: cannot assign to `f.foo` because it is borrowed --> $DIR/borrowck-overloaded-index-autoderef.rs:81:5 diff --git a/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.ast.nll.stderr b/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.ast.nll.stderr index 3a2bfb18cb9..7ff9285bcc0 100644 --- a/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.ast.nll.stderr @@ -7,7 +7,7 @@ LL | println!("{}", f[&s]); | ^^ immutable borrow occurs here ... LL | drop(rs); - | -- borrow later used here + | -- mutable borrow later used here error[E0502]: cannot borrow `s` as immutable because it is also borrowed as mutable --> $DIR/borrowck-overloaded-index-ref-index.rs:65:7 @@ -19,7 +19,7 @@ LL | f[&s] = 10; | ^^ immutable borrow occurs here ... LL | drop(rs); - | -- borrow later used here + | -- mutable borrow later used here error[E0594]: cannot assign to data in a `&` reference --> $DIR/borrowck-overloaded-index-ref-index.rs:71:5 diff --git a/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.mir.stderr b/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.mir.stderr index 3a2bfb18cb9..7ff9285bcc0 100644 --- a/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.mir.stderr +++ b/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.mir.stderr @@ -7,7 +7,7 @@ LL | println!("{}", f[&s]); | ^^ immutable borrow occurs here ... LL | drop(rs); - | -- borrow later used here + | -- mutable borrow later used here error[E0502]: cannot borrow `s` as immutable because it is also borrowed as mutable --> $DIR/borrowck-overloaded-index-ref-index.rs:65:7 @@ -19,7 +19,7 @@ LL | f[&s] = 10; | ^^ immutable borrow occurs here ... LL | drop(rs); - | -- borrow later used here + | -- mutable borrow later used here error[E0594]: cannot assign to data in a `&` reference --> $DIR/borrowck-overloaded-index-ref-index.rs:71:5 diff --git a/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.nll.stderr b/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.nll.stderr index fa600f0559f..a089f6d90f8 100644 --- a/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.nll.stderr +++ b/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.nll.stderr @@ -8,7 +8,7 @@ LL | let z = &x; //~ ERROR cannot borrow | ^^ immutable borrow occurs here ... LL | y.use_mut(); - | - borrow later used here + | - mutable borrow later used here error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable --> $DIR/borrowck-report-with-custom-diagnostic.rs:30:21 @@ -20,7 +20,7 @@ LL | let z = &mut x; //~ ERROR cannot borrow | ^^^^^^ mutable borrow occurs here ... LL | y.use_ref(); - | - borrow later used here + | - immutable borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/borrowck-report-with-custom-diagnostic.rs:45:17 @@ -32,7 +32,7 @@ LL | let z = &mut x; //~ ERROR cannot borrow | ^^^^^^ second mutable borrow occurs here ... LL | y.use_mut(); - | - borrow later used here + | - first borrow later used here error: aborting due to 3 previous errors diff --git a/src/test/ui/borrowck/borrowck-slice-pattern-element-loan.stderr b/src/test/ui/borrowck/borrowck-slice-pattern-element-loan.stderr index 16d401ec7f9..7f260910ab8 100644 --- a/src/test/ui/borrowck/borrowck-slice-pattern-element-loan.stderr +++ b/src/test/ui/borrowck/borrowck-slice-pattern-element-loan.stderr @@ -6,7 +6,7 @@ LL | if let [ref first, ref second, ..] = *s { LL | if let [_, ref mut second2, ref mut third, ..] = *s { //~ERROR | ^^^^^^^^^^^^^^^^ mutable borrow occurs here LL | nop(&[first, second, second2, third]); - | ------ borrow later used here + | ------ immutable borrow later used here error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable --> $DIR/borrowck-slice-pattern-element-loan.rs:44:21 @@ -16,7 +16,7 @@ LL | if let [.., ref fourth, ref third, _, ref first] = *s { LL | if let [.., ref mut third2, _, _] = *s { //~ERROR | ^^^^^^^^^^^^^^ mutable borrow occurs here LL | nop(&[first, third, third2, fourth]); - | ----- borrow later used here + | ----- immutable borrow later used here error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable --> $DIR/borrowck-slice-pattern-element-loan.rs:55:20 @@ -27,7 +27,7 @@ LL | if let [.., _, ref from_end4, ref from_end3, _, ref from_end1] = *s { LL | if let [_, ref mut from_begin1, ..] = *s { //~ERROR | ^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here LL | nop(&[from_begin1, from_end1, from_end3, from_end4]); - | --------- borrow later used here + | --------- immutable borrow later used here error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable --> $DIR/borrowck-slice-pattern-element-loan.rs:58:23 @@ -38,7 +38,7 @@ LL | if let [.., _, ref from_end4, ref from_end3, _, ref from_end1] = *s { LL | if let [_, _, ref mut from_begin2, ..] = *s { //~ERROR | ^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here LL | nop(&[from_begin2, from_end1, from_end3, from_end4]); - | --------- borrow later used here + | --------- immutable borrow later used here error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable --> $DIR/borrowck-slice-pattern-element-loan.rs:61:26 @@ -49,7 +49,7 @@ LL | if let [.., _, ref from_end4, ref from_end3, _, ref from_end1] = *s { LL | if let [_, _, _, ref mut from_begin3, ..] = *s { //~ERROR | ^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here LL | nop(&[from_begin3, from_end1, from_end3, from_end4]); - | --------- borrow later used here + | --------- immutable borrow later used here error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable --> $DIR/borrowck-slice-pattern-element-loan.rs:69:21 @@ -60,7 +60,7 @@ LL | if let [ref from_begin0, ref from_begin1, _, ref from_begin3, _, ..] = LL | if let [.., ref mut from_end2, _] = *s { //~ERROR | ^^^^^^^^^^^^^^^^^ mutable borrow occurs here LL | nop(&[from_begin0, from_begin1, from_begin3, from_end2]); - | ----------- borrow later used here + | ----------- immutable borrow later used here error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable --> $DIR/borrowck-slice-pattern-element-loan.rs:72:21 @@ -71,7 +71,7 @@ LL | if let [ref from_begin0, ref from_begin1, _, ref from_begin3, _, ..] = LL | if let [.., ref mut from_end3, _, _] = *s { //~ERROR | ^^^^^^^^^^^^^^^^^ mutable borrow occurs here LL | nop(&[from_begin0, from_begin1, from_begin3, from_end3]); - | ----------- borrow later used here + | ----------- immutable borrow later used here error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable --> $DIR/borrowck-slice-pattern-element-loan.rs:75:21 @@ -82,7 +82,7 @@ LL | if let [ref from_begin0, ref from_begin1, _, ref from_begin3, _, ..] = LL | if let [.., ref mut from_end4, _, _, _] = *s { //~ERROR | ^^^^^^^^^^^^^^^^^ mutable borrow occurs here LL | nop(&[from_begin0, from_begin1, from_begin3, from_end4]); - | ----------- borrow later used here + | ----------- immutable borrow later used here error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable --> $DIR/borrowck-slice-pattern-element-loan.rs:92:20 @@ -92,7 +92,7 @@ LL | if let [ref first, ref second, ..] = *s { LL | if let [_, ref mut tail..] = *s { //~ERROR | ^^^^^^^^^^^^ mutable borrow occurs here LL | nop(&[first, second]); - | ------ borrow later used here + | ------ immutable borrow later used here error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable --> $DIR/borrowck-slice-pattern-element-loan.rs:110:17 @@ -102,7 +102,7 @@ LL | if let [.., ref second, ref first] = *s { LL | if let [ref mut tail.., _] = *s { //~ERROR | ^^^^^^^^^^^^ mutable borrow occurs here LL | nop(&[first, second]); - | ------ borrow later used here + | ------ immutable borrow later used here error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable --> $DIR/borrowck-slice-pattern-element-loan.rs:119:17 @@ -112,7 +112,7 @@ LL | if let [_, _, _, ref s1..] = *s { LL | if let [ref mut s2.., _, _, _] = *s { //~ERROR | ^^^^^^^^^^ mutable borrow occurs here LL | nop_subslice(s1); - | -- borrow later used here + | -- immutable borrow later used here error: aborting due to 11 previous errors diff --git a/src/test/ui/borrowck/borrowck-swap-mut-base-ptr.nll.stderr b/src/test/ui/borrowck/borrowck-swap-mut-base-ptr.nll.stderr index 5f605694c5b..4fad30fd40d 100644 --- a/src/test/ui/borrowck/borrowck-swap-mut-base-ptr.nll.stderr +++ b/src/test/ui/borrowck/borrowck-swap-mut-base-ptr.nll.stderr @@ -7,7 +7,7 @@ LL | swap(&mut t0, &mut t1); //~ ERROR cannot borrow `t0` | ^^^^^^^ mutable borrow occurs here LL | *t1 = 22; LL | p.use_ref(); - | - borrow later used here + | - immutable borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-union-borrow.ast.nll.stderr b/src/test/ui/borrowck/borrowck-union-borrow.ast.nll.stderr index 2f14826fa12..781d693d565 100644 --- a/src/test/ui/borrowck/borrowck-union-borrow.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-union-borrow.ast.nll.stderr @@ -7,7 +7,7 @@ LL | let rma = &mut u.a; //[ast]~ ERROR cannot borrow `u.a` as mutab | ^^^^^^^^ mutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `u.a` as mutable because it is also borrowed as immutable LL | drop(ra); - | -- borrow later used here + | -- immutable borrow later used here error[E0506]: cannot assign to `u.a` because it is borrowed --> $DIR/borrowck-union-borrow.rs:43:13 @@ -29,7 +29,7 @@ LL | let rmb = &mut u.b; //[ast]~ ERROR cannot borrow `u` (via `u.b` | ^^^^^^^^ mutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `u.b` as mutable because it is also borrowed as immutable LL | drop(ra); - | -- borrow later used here + | -- immutable borrow later used here error[E0506]: cannot assign to `u.b` because it is borrowed --> $DIR/borrowck-union-borrow.rs:66:13 @@ -51,7 +51,7 @@ LL | let ra = &u.a; //[ast]~ ERROR cannot borrow `u.a` as immutable | ^^^^ immutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `u.a` as immutable because it is also borrowed as mutable LL | drop(rma); - | --- borrow later used here + | --- mutable borrow later used here error[E0503]: cannot use `u.a` because it was mutably borrowed --> $DIR/borrowck-union-borrow.rs:79:21 @@ -73,7 +73,7 @@ LL | let rma2 = &mut u.a; //[ast]~ ERROR cannot borrow `u.a` as muta | ^^^^^^^^ second mutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `u.a` as mutable more than once at a time LL | drop(rma); - | --- borrow later used here + | --- first borrow later used here error[E0506]: cannot assign to `u.a` because it is borrowed --> $DIR/borrowck-union-borrow.rs:91:13 @@ -95,7 +95,7 @@ LL | let rb = &u.b; //[ast]~ ERROR cannot borrow `u` (via `u.b`) as | ^^^^ immutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `u.b` as immutable because it is also borrowed as mutable LL | drop(rma); - | --- borrow later used here + | --- mutable borrow later used here error[E0503]: cannot use `u.b` because it was mutably borrowed --> $DIR/borrowck-union-borrow.rs:104:21 @@ -117,7 +117,7 @@ LL | let rmb2 = &mut u.b; //[ast]~ ERROR cannot borrow `u` (via `u.b | ^^^^^^^^ second mutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `u.b` as mutable more than once at a time LL | drop(rma); - | --- borrow later used here + | --- first borrow later used here error[E0506]: cannot assign to `u.b` because it is borrowed --> $DIR/borrowck-union-borrow.rs:117:13 diff --git a/src/test/ui/borrowck/borrowck-union-borrow.mir.stderr b/src/test/ui/borrowck/borrowck-union-borrow.mir.stderr index 2f14826fa12..781d693d565 100644 --- a/src/test/ui/borrowck/borrowck-union-borrow.mir.stderr +++ b/src/test/ui/borrowck/borrowck-union-borrow.mir.stderr @@ -7,7 +7,7 @@ LL | let rma = &mut u.a; //[ast]~ ERROR cannot borrow `u.a` as mutab | ^^^^^^^^ mutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `u.a` as mutable because it is also borrowed as immutable LL | drop(ra); - | -- borrow later used here + | -- immutable borrow later used here error[E0506]: cannot assign to `u.a` because it is borrowed --> $DIR/borrowck-union-borrow.rs:43:13 @@ -29,7 +29,7 @@ LL | let rmb = &mut u.b; //[ast]~ ERROR cannot borrow `u` (via `u.b` | ^^^^^^^^ mutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `u.b` as mutable because it is also borrowed as immutable LL | drop(ra); - | -- borrow later used here + | -- immutable borrow later used here error[E0506]: cannot assign to `u.b` because it is borrowed --> $DIR/borrowck-union-borrow.rs:66:13 @@ -51,7 +51,7 @@ LL | let ra = &u.a; //[ast]~ ERROR cannot borrow `u.a` as immutable | ^^^^ immutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `u.a` as immutable because it is also borrowed as mutable LL | drop(rma); - | --- borrow later used here + | --- mutable borrow later used here error[E0503]: cannot use `u.a` because it was mutably borrowed --> $DIR/borrowck-union-borrow.rs:79:21 @@ -73,7 +73,7 @@ LL | let rma2 = &mut u.a; //[ast]~ ERROR cannot borrow `u.a` as muta | ^^^^^^^^ second mutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `u.a` as mutable more than once at a time LL | drop(rma); - | --- borrow later used here + | --- first borrow later used here error[E0506]: cannot assign to `u.a` because it is borrowed --> $DIR/borrowck-union-borrow.rs:91:13 @@ -95,7 +95,7 @@ LL | let rb = &u.b; //[ast]~ ERROR cannot borrow `u` (via `u.b`) as | ^^^^ immutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `u.b` as immutable because it is also borrowed as mutable LL | drop(rma); - | --- borrow later used here + | --- mutable borrow later used here error[E0503]: cannot use `u.b` because it was mutably borrowed --> $DIR/borrowck-union-borrow.rs:104:21 @@ -117,7 +117,7 @@ LL | let rmb2 = &mut u.b; //[ast]~ ERROR cannot borrow `u` (via `u.b | ^^^^^^^^ second mutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `u.b` as mutable more than once at a time LL | drop(rma); - | --- borrow later used here + | --- first borrow later used here error[E0506]: cannot assign to `u.b` because it is borrowed --> $DIR/borrowck-union-borrow.rs:117:13 diff --git a/src/test/ui/borrowck/borrowck-uniq-via-lend.nll.stderr b/src/test/ui/borrowck/borrowck-uniq-via-lend.nll.stderr index a918550fabf..29e079ee333 100644 --- a/src/test/ui/borrowck/borrowck-uniq-via-lend.nll.stderr +++ b/src/test/ui/borrowck/borrowck-uniq-via-lend.nll.stderr @@ -6,7 +6,7 @@ LL | let w = &mut v; LL | borrow(&*v); //~ ERROR cannot borrow `*v` | ^^^ immutable borrow occurs here LL | w.use_mut(); - | - borrow later used here + | - mutable borrow later used here error[E0502]: cannot borrow `*v` as immutable because it is also borrowed as mutable --> $DIR/borrowck-uniq-via-lend.rs:63:12 @@ -16,7 +16,7 @@ LL | x = &mut v; LL | borrow(&*v); //~ ERROR cannot borrow `*v` | ^^^ immutable borrow occurs here LL | x.use_mut(); - | - borrow later used here + | - mutable borrow later used here error: aborting due to 2 previous errors diff --git a/src/test/ui/borrowck/borrowck-vec-pattern-loan-from-mut.nll.stderr b/src/test/ui/borrowck/borrowck-vec-pattern-loan-from-mut.nll.stderr index 9b73991ce30..4614c5cf5a6 100644 --- a/src/test/ui/borrowck/borrowck-vec-pattern-loan-from-mut.nll.stderr +++ b/src/test/ui/borrowck/borrowck-vec-pattern-loan-from-mut.nll.stderr @@ -5,7 +5,7 @@ LL | let vb: &mut [isize] = &mut v; | ------ first mutable borrow occurs here ... LL | v.push(tail[0] + tail[1]); //~ ERROR cannot borrow - | ^ ------- borrow later used here + | ^ ------- first borrow later used here | | | second mutable borrow occurs here diff --git a/src/test/ui/borrowck/issue-51117.nll.stderr b/src/test/ui/borrowck/issue-51117.nll.stderr index 1ddca213202..71e96577797 100644 --- a/src/test/ui/borrowck/issue-51117.nll.stderr +++ b/src/test/ui/borrowck/issue-51117.nll.stderr @@ -6,7 +6,7 @@ LL | Some(baz) => { LL | bar.take(); //~ ERROR cannot borrow | ^^^ second mutable borrow occurs here LL | drop(baz); - | --- borrow later used here + | --- first borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/mut-borrow-in-loop.nll.stderr b/src/test/ui/borrowck/mut-borrow-in-loop.nll.stderr index 92225369c92..c6aa243b6cf 100644 --- a/src/test/ui/borrowck/mut-borrow-in-loop.nll.stderr +++ b/src/test/ui/borrowck/mut-borrow-in-loop.nll.stderr @@ -4,7 +4,7 @@ error[E0499]: cannot borrow `*arg` as mutable more than once at a time LL | (self.func)(arg) //~ ERROR cannot borrow | ^^^ mutable borrow starts here in previous iteration of loop | -note: borrowed value must be valid for the lifetime 'a as defined on the impl at 17:6... +note: first borrowed value must be valid for the lifetime 'a as defined on the impl at 17:6... --> $DIR/mut-borrow-in-loop.rs:17:6 | LL | impl<'a, T : 'a> FuncWrapper<'a, T> { @@ -16,7 +16,7 @@ error[E0499]: cannot borrow `*arg` as mutable more than once at a time LL | (self.func)(arg) //~ ERROR cannot borrow | ^^^ mutable borrow starts here in previous iteration of loop | -note: borrowed value must be valid for the lifetime 'a as defined on the impl at 17:6... +note: first borrowed value must be valid for the lifetime 'a as defined on the impl at 17:6... --> $DIR/mut-borrow-in-loop.rs:17:6 | LL | impl<'a, T : 'a> FuncWrapper<'a, T> { @@ -28,7 +28,7 @@ error[E0499]: cannot borrow `*arg` as mutable more than once at a time LL | (self.func)(arg) //~ ERROR cannot borrow | ^^^ mutable borrow starts here in previous iteration of loop | -note: borrowed value must be valid for the lifetime 'a as defined on the impl at 17:6... +note: first borrowed value must be valid for the lifetime 'a as defined on the impl at 17:6... --> $DIR/mut-borrow-in-loop.rs:17:6 | LL | impl<'a, T : 'a> FuncWrapper<'a, T> { diff --git a/src/test/ui/borrowck/mut-borrow-outside-loop.nll.stderr b/src/test/ui/borrowck/mut-borrow-outside-loop.nll.stderr index dd445c8c3a0..fd201d75106 100644 --- a/src/test/ui/borrowck/mut-borrow-outside-loop.nll.stderr +++ b/src/test/ui/borrowck/mut-borrow-outside-loop.nll.stderr @@ -6,7 +6,7 @@ LL | let first = &mut void; LL | let second = &mut void; //~ ERROR cannot borrow | ^^^^^^^^^ second mutable borrow occurs here LL | first.use_mut(); - | ----- borrow later used here + | ----- first borrow later used here error[E0499]: cannot borrow `inner_void` as mutable more than once at a time --> $DIR/mut-borrow-outside-loop.rs:25:28 @@ -17,7 +17,7 @@ LL | let inner_second = &mut inner_void; //~ ERROR cannot borrow | ^^^^^^^^^^^^^^^ second mutable borrow occurs here LL | inner_second.use_mut(); LL | inner_first.use_mut(); - | ----------- borrow used here, in later iteration of loop + | ----------- first borrow used here, in later iteration of loop error: aborting due to 2 previous errors diff --git a/src/test/ui/borrowck/two-phase-activation-sharing-interference.nll_target.stderr b/src/test/ui/borrowck/two-phase-activation-sharing-interference.nll_target.stderr index 5a7f33e5b56..ad1dc439c6d 100644 --- a/src/test/ui/borrowck/two-phase-activation-sharing-interference.nll_target.stderr +++ b/src/test/ui/borrowck/two-phase-activation-sharing-interference.nll_target.stderr @@ -7,7 +7,7 @@ LL | { let z = &x; read(z); } | ^^ immutable borrow occurs here LL | //[nll_target]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable LL | *y += 1; - | ------- borrow later used here + | ------- mutable borrow later used here error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable --> $DIR/two-phase-activation-sharing-interference.rs:50:13 @@ -18,7 +18,7 @@ LL | let z = &x; | ^^ immutable borrow occurs here LL | //[nll_target]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable LL | *y += 1; - | ------- borrow later used here + | ------- mutable borrow later used here error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable --> $DIR/two-phase-activation-sharing-interference.rs:61:13 @@ -29,7 +29,7 @@ LL | let z = &x; | ^^ immutable borrow occurs here ... LL | *y += 1; - | ------- borrow later used here + | ------- mutable borrow later used here error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable --> $DIR/two-phase-activation-sharing-interference.rs:72:14 @@ -40,7 +40,7 @@ LL | let _z = &x; | ^^ immutable borrow occurs here LL | //[nll_target]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable LL | *y += 1; - | ------- borrow later used here + | ------- mutable borrow later used here error: aborting due to 4 previous errors diff --git a/src/test/ui/borrowck/two-phase-cannot-nest-mut-self-calls.stderr b/src/test/ui/borrowck/two-phase-cannot-nest-mut-self-calls.stderr index 942a38febdd..a3d3da94d54 100644 --- a/src/test/ui/borrowck/two-phase-cannot-nest-mut-self-calls.stderr +++ b/src/test/ui/borrowck/two-phase-cannot-nest-mut-self-calls.stderr @@ -1,19 +1,13 @@ error[E0502]: cannot borrow `vec` as mutable because it is also borrowed as immutable --> $DIR/two-phase-cannot-nest-mut-self-calls.rs:26:9 | -LL | vec.get({ - | --- - | | - | _____immutable borrow occurs here - | | -LL | | -LL | | vec.push(2); - | | ^^^^^^^^^^^ mutable borrow occurs here -LL | | //~^ ERROR cannot borrow `vec` as mutable because it is also borrowed as immutable -LL | | -LL | | 0 -LL | | }); - | |______- borrow later used here +LL | vec.get({ + | --- --- immutable borrow later used by call + | | + | immutable borrow occurs here +LL | +LL | vec.push(2); + | ^^^^^^^^^^^ mutable borrow occurs here error: aborting due to previous error diff --git a/src/test/ui/borrowck/two-phase-multi-mut.stderr b/src/test/ui/borrowck/two-phase-multi-mut.stderr index a7e1dd95364..a6d311a7b1d 100644 --- a/src/test/ui/borrowck/two-phase-multi-mut.stderr +++ b/src/test/ui/borrowck/two-phase-multi-mut.stderr @@ -2,21 +2,20 @@ error[E0499]: cannot borrow `foo` as mutable more than once at a time --> $DIR/two-phase-multi-mut.rs:23:5 | LL | foo.method(&mut foo); - | ^^^^^^^^^^^--------^ - | | | - | | first mutable borrow occurs here + | ^^^^------^--------^ + | | | | + | | | first mutable borrow occurs here + | | first borrow later used by call | second mutable borrow occurs here - | borrow later used here error[E0499]: cannot borrow `foo` as mutable more than once at a time --> $DIR/two-phase-multi-mut.rs:23:16 | LL | foo.method(&mut foo); - | -----------^^^^^^^^- - | | | - | | second mutable borrow occurs here + | --- ------ ^^^^^^^^ second mutable borrow occurs here + | | | + | | first borrow later used by call | first mutable borrow occurs here - | borrow later used here error: aborting due to 2 previous errors diff --git a/src/test/ui/borrowck/two-phase-nonrecv-autoref.ast.nll.stderr b/src/test/ui/borrowck/two-phase-nonrecv-autoref.ast.nll.stderr index a8651c0e741..a272d2cf019 100644 --- a/src/test/ui/borrowck/two-phase-nonrecv-autoref.ast.nll.stderr +++ b/src/test/ui/borrowck/two-phase-nonrecv-autoref.ast.nll.stderr @@ -2,11 +2,10 @@ error[E0499]: cannot borrow `*f` as mutable more than once at a time --> $DIR/two-phase-nonrecv-autoref.rs:70:11 | LL | f(f(10)); - | --^----- - | | | - | | second mutable borrow occurs here + | - ^ second mutable borrow occurs here + | | | first mutable borrow occurs here - | borrow later used here + | first borrow later used by call error[E0382]: use of moved value: `*f` --> $DIR/two-phase-nonrecv-autoref.rs:79:11 @@ -20,11 +19,10 @@ error[E0499]: cannot borrow `*f` as mutable more than once at a time --> $DIR/two-phase-nonrecv-autoref.rs:86:11 | LL | f(f(10)); - | --^----- - | | | - | | second mutable borrow occurs here + | - ^ second mutable borrow occurs here + | | | first mutable borrow occurs here - | borrow later used here + | first borrow later used by call error[E0161]: cannot move a value of type dyn std::ops::FnOnce(i32) -> i32: the size of dyn std::ops::FnOnce(i32) -> i32 cannot be statically determined --> $DIR/two-phase-nonrecv-autoref.rs:95:9 @@ -50,11 +48,10 @@ error[E0502]: cannot borrow `a` as immutable because it is also borrowed as muta --> $DIR/two-phase-nonrecv-autoref.rs:139:27 | LL | double_access(&mut a, &a); - | ----------------------^^- - | | | | - | | | immutable borrow occurs here + | ------------- ------ ^^ immutable borrow occurs here + | | | | | mutable borrow occurs here - | borrow later used here + | mutable borrow later used by call error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable --> $DIR/two-phase-nonrecv-autoref.rs:167:7 @@ -64,7 +61,7 @@ LL | i[i[3]] = 4; | | | | | immutable borrow occurs here | mutable borrow occurs here - | borrow later used here + | mutable borrow later used here error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable --> $DIR/two-phase-nonrecv-autoref.rs:173:7 @@ -74,7 +71,7 @@ LL | i[i[3]] = i[4]; | | | | | immutable borrow occurs here | mutable borrow occurs here - | borrow later used here + | mutable borrow later used here error: aborting due to 9 previous errors diff --git a/src/test/ui/borrowck/two-phase-nonrecv-autoref.nll.stderr b/src/test/ui/borrowck/two-phase-nonrecv-autoref.nll.stderr index a8651c0e741..a272d2cf019 100644 --- a/src/test/ui/borrowck/two-phase-nonrecv-autoref.nll.stderr +++ b/src/test/ui/borrowck/two-phase-nonrecv-autoref.nll.stderr @@ -2,11 +2,10 @@ error[E0499]: cannot borrow `*f` as mutable more than once at a time --> $DIR/two-phase-nonrecv-autoref.rs:70:11 | LL | f(f(10)); - | --^----- - | | | - | | second mutable borrow occurs here + | - ^ second mutable borrow occurs here + | | | first mutable borrow occurs here - | borrow later used here + | first borrow later used by call error[E0382]: use of moved value: `*f` --> $DIR/two-phase-nonrecv-autoref.rs:79:11 @@ -20,11 +19,10 @@ error[E0499]: cannot borrow `*f` as mutable more than once at a time --> $DIR/two-phase-nonrecv-autoref.rs:86:11 | LL | f(f(10)); - | --^----- - | | | - | | second mutable borrow occurs here + | - ^ second mutable borrow occurs here + | | | first mutable borrow occurs here - | borrow later used here + | first borrow later used by call error[E0161]: cannot move a value of type dyn std::ops::FnOnce(i32) -> i32: the size of dyn std::ops::FnOnce(i32) -> i32 cannot be statically determined --> $DIR/two-phase-nonrecv-autoref.rs:95:9 @@ -50,11 +48,10 @@ error[E0502]: cannot borrow `a` as immutable because it is also borrowed as muta --> $DIR/two-phase-nonrecv-autoref.rs:139:27 | LL | double_access(&mut a, &a); - | ----------------------^^- - | | | | - | | | immutable borrow occurs here + | ------------- ------ ^^ immutable borrow occurs here + | | | | | mutable borrow occurs here - | borrow later used here + | mutable borrow later used by call error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable --> $DIR/two-phase-nonrecv-autoref.rs:167:7 @@ -64,7 +61,7 @@ LL | i[i[3]] = 4; | | | | | immutable borrow occurs here | mutable borrow occurs here - | borrow later used here + | mutable borrow later used here error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable --> $DIR/two-phase-nonrecv-autoref.rs:173:7 @@ -74,7 +71,7 @@ LL | i[i[3]] = i[4]; | | | | | immutable borrow occurs here | mutable borrow occurs here - | borrow later used here + | mutable borrow later used here error: aborting due to 9 previous errors diff --git a/src/test/ui/borrowck/two-phase-reservation-sharing-interference.nll_target.stderr b/src/test/ui/borrowck/two-phase-reservation-sharing-interference.nll_target.stderr index 62a548af62b..21f54881b00 100644 --- a/src/test/ui/borrowck/two-phase-reservation-sharing-interference.nll_target.stderr +++ b/src/test/ui/borrowck/two-phase-reservation-sharing-interference.nll_target.stderr @@ -8,7 +8,7 @@ LL | delay = &mut vec; | ^^^^^^^^ mutable borrow occurs here ... LL | shared[0]; - | ------ borrow later used here + | ------ immutable borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/two-phase-sneaky.nll.stderr b/src/test/ui/borrowck/two-phase-sneaky.nll.stderr index 26a6271bbde..4847f6cec86 100644 --- a/src/test/ui/borrowck/two-phase-sneaky.nll.stderr +++ b/src/test/ui/borrowck/two-phase-sneaky.nll.stderr @@ -1,19 +1,13 @@ error[E0499]: cannot borrow `v` as mutable more than once at a time --> $DIR/two-phase-sneaky.rs:22:9 | -LL | v[0].push_str({ - | - - | | - | _____first mutable borrow occurs here - | | -LL | | -LL | | v.push(format!("foo")); - | | ^ second mutable borrow occurs here -LL | | //~^ ERROR cannot borrow `v` as mutable more than once at a time [E0499] -LL | | -LL | | "World!" -LL | | }); - | |______- borrow later used here +LL | v[0].push_str({ + | - -------- first borrow later used by call + | | + | first mutable borrow occurs here +LL | +LL | v.push(format!("foo")); + | ^ second mutable borrow occurs here error: aborting due to previous error diff --git a/src/test/ui/borrowck/two-phase-surprise-no-conflict.nll.stderr b/src/test/ui/borrowck/two-phase-surprise-no-conflict.nll.stderr index 1fcd9021341..b1f947aceb5 100644 --- a/src/test/ui/borrowck/two-phase-surprise-no-conflict.nll.stderr +++ b/src/test/ui/borrowck/two-phase-surprise-no-conflict.nll.stderr @@ -13,61 +13,57 @@ error[E0502]: cannot borrow `*self` as mutable because it is also borrowed as im --> $DIR/two-phase-surprise-no-conflict.rs:79:17 | LL | self.hash_expr(&self.cx_mut.body(eid).value); - | ^^^^^^^^^^^^^^^^-----------^^^^^^^^^^^^^^^^^ - | | | - | | immutable borrow occurs here + | ^^^^^---------^^-----------^^^^^^^^^^^^^^^^^ + | | | | + | | | immutable borrow occurs here + | | immutable borrow later used by call | mutable borrow occurs here - | borrow later used here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:151:51 | LL | reg.register_static(Box::new(TrivialPass::new(&mut reg.sess_mut))); - | ----------------------------------------------^^^^^^^^^^^^^^^^^--- - | | | - | | second mutable borrow occurs here + | --- --------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | | | + | | first borrow later used by call | first mutable borrow occurs here - | borrow later used here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:156:54 | LL | reg.register_bound(Box::new(TrivialPass::new_mut(&mut reg.sess_mut))); - | -------------------------------------------------^^^^^^^^^^^^^^^^^--- - | | | - | | second mutable borrow occurs here + | --- -------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | | | + | | first borrow later used by call | first mutable borrow occurs here - | borrow later used here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:161:53 | LL | reg.register_univ(Box::new(TrivialPass::new_mut(&mut reg.sess_mut))); - | ------------------------------------------------^^^^^^^^^^^^^^^^^--- - | | | - | | second mutable borrow occurs here + | --- ------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | | | + | | first borrow later used by call | first mutable borrow occurs here - | borrow later used here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:166:44 | LL | reg.register_ref(&TrivialPass::new_mut(&mut reg.sess_mut)); - | ---------------------------------------^^^^^^^^^^^^^^^^^-- - | | | - | | second mutable borrow occurs here + | --- ------------ ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | | | + | | first borrow later used by call | first mutable borrow occurs here - | borrow later used here error[E0502]: cannot borrow `*reg` as mutable because it is also borrowed as immutable --> $DIR/two-phase-surprise-no-conflict.rs:178:5 | LL | reg.register_bound(Box::new(CapturePass::new(®.sess_mut))); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------^^^ - | | | - | | immutable borrow occurs here + | ^^^^--------------^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------^^^ + | | | | + | | | immutable borrow occurs here + | | immutable borrow later used by call | mutable borrow occurs here - | borrow later used here error[E0502]: cannot borrow `*reg` as mutable because it is also borrowed as immutable --> $DIR/two-phase-surprise-no-conflict.rs:183:5 @@ -78,7 +74,7 @@ LL | reg.register_univ(Box::new(CapturePass::new(®.sess_mut))); | | immutable borrow occurs here | mutable borrow occurs here | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 122:21... +note: immutable borrowed value must be valid for the lifetime 'a as defined on the function body at 122:21... --> $DIR/two-phase-surprise-no-conflict.rs:122:21 | LL | fn register_plugins<'a>(mk_reg: impl Fn() -> &'a mut Registry<'a>) { @@ -88,31 +84,30 @@ error[E0502]: cannot borrow `*reg` as mutable because it is also borrowed as imm --> $DIR/two-phase-surprise-no-conflict.rs:188:5 | LL | reg.register_ref(&CapturePass::new(®.sess_mut)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------^^ - | | | - | | immutable borrow occurs here + | ^^^^------------^^^^^^^^^^^^^^^^^^^-------------^^ + | | | | + | | | immutable borrow occurs here + | | immutable borrow later used by call | mutable borrow occurs here - | borrow later used here error[E0499]: cannot borrow `*reg` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:200:5 | LL | reg.register_bound(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------^^^ - | | | - | | first mutable borrow occurs here + | ^^^^--------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------^^^ + | | | | + | | | first mutable borrow occurs here + | | first borrow later used by call | second mutable borrow occurs here - | borrow later used here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:200:54 | LL | reg.register_bound(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); - | -------------------------------------------------^^^^^^^^^^^^^^^^^--- - | | | - | | second mutable borrow occurs here + | --- -------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | | | + | | first borrow later used by call | first mutable borrow occurs here - | borrow later used here error[E0499]: cannot borrow `*reg` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:206:5 @@ -123,7 +118,7 @@ LL | reg.register_univ(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); | | first mutable borrow occurs here | second mutable borrow occurs here | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 122:21... +note: first borrowed value must be valid for the lifetime 'a as defined on the function body at 122:21... --> $DIR/two-phase-surprise-no-conflict.rs:122:21 | LL | fn register_plugins<'a>(mk_reg: impl Fn() -> &'a mut Registry<'a>) { @@ -133,31 +128,29 @@ error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:206:53 | LL | reg.register_univ(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); - | ------------------------------------------------^^^^^^^^^^^^^^^^^--- - | | | - | | second mutable borrow occurs here + | --- ------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | | | + | | first borrow later used by call | first mutable borrow occurs here - | borrow later used here error[E0499]: cannot borrow `*reg` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:212:5 | LL | reg.register_ref(&CapturePass::new_mut(&mut reg.sess_mut)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------^^ - | | | - | | first mutable borrow occurs here + | ^^^^------------^^^^^^^^^^^^^^^^^^^^^^^-----------------^^ + | | | | + | | | first mutable borrow occurs here + | | first borrow later used by call | second mutable borrow occurs here - | borrow later used here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:212:44 | LL | reg.register_ref(&CapturePass::new_mut(&mut reg.sess_mut)); - | ---------------------------------------^^^^^^^^^^^^^^^^^-- - | | | - | | second mutable borrow occurs here + | --- ------------ ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | | | + | | first borrow later used by call | first mutable borrow occurs here - | borrow later used here error: aborting due to 15 previous errors diff --git a/src/test/ui/borrowck/two-phase-surprise-no-conflict.no2pb.stderr b/src/test/ui/borrowck/two-phase-surprise-no-conflict.no2pb.stderr index f4fc7e54f80..06ac92b18e1 100644 --- a/src/test/ui/borrowck/two-phase-surprise-no-conflict.no2pb.stderr +++ b/src/test/ui/borrowck/two-phase-surprise-no-conflict.no2pb.stderr @@ -13,161 +13,145 @@ error[E0502]: cannot borrow `*self.cx` as immutable because it is also borrowed --> $DIR/two-phase-surprise-no-conflict.rs:64:33 | LL | self.hash_expr(&self.cx.body(eid).value); - | ----------------^^^^^^^----------------- - | | | - | | immutable borrow occurs here + | ---- --------- ^^^^^^^ immutable borrow occurs here + | | | + | | mutable borrow later used by call | mutable borrow occurs here - | borrow later used here error[E0502]: cannot borrow `*self.cx_mut` as immutable because it is also borrowed as mutable --> $DIR/two-phase-surprise-no-conflict.rs:79:33 | LL | self.hash_expr(&self.cx_mut.body(eid).value); - | ----------------^^^^^^^^^^^----------------- - | | | - | | immutable borrow occurs here + | ---- --------- ^^^^^^^^^^^ immutable borrow occurs here + | | | + | | mutable borrow later used by call | mutable borrow occurs here - | borrow later used here error[E0502]: cannot borrow `reg.sess_mut` as immutable because it is also borrowed as mutable --> $DIR/two-phase-surprise-no-conflict.rs:131:51 | LL | reg.register_static(Box::new(TrivialPass::new(®.sess_mut))); - | ----------------------------------------------^^^^^^^^^^^^^--- - | | | - | | immutable borrow occurs here + | --- --------------- ^^^^^^^^^^^^^ immutable borrow occurs here + | | | + | | mutable borrow later used by call | mutable borrow occurs here - | borrow later used here error[E0502]: cannot borrow `reg.sess_mut` as immutable because it is also borrowed as mutable --> $DIR/two-phase-surprise-no-conflict.rs:135:50 | LL | reg.register_bound(Box::new(TrivialPass::new(®.sess_mut))); - | ---------------------------------------------^^^^^^^^^^^^^--- - | | | - | | immutable borrow occurs here + | --- -------------- ^^^^^^^^^^^^^ immutable borrow occurs here + | | | + | | mutable borrow later used by call | mutable borrow occurs here - | borrow later used here error[E0502]: cannot borrow `reg.sess_mut` as immutable because it is also borrowed as mutable --> $DIR/two-phase-surprise-no-conflict.rs:139:49 | LL | reg.register_univ(Box::new(TrivialPass::new(®.sess_mut))); - | --------------------------------------------^^^^^^^^^^^^^--- - | | | - | | immutable borrow occurs here + | --- ------------- ^^^^^^^^^^^^^ immutable borrow occurs here + | | | + | | mutable borrow later used by call | mutable borrow occurs here - | borrow later used here error[E0502]: cannot borrow `reg.sess_mut` as immutable because it is also borrowed as mutable --> $DIR/two-phase-surprise-no-conflict.rs:143:40 | LL | reg.register_ref(&TrivialPass::new(®.sess_mut)); - | -----------------------------------^^^^^^^^^^^^^-- - | | | - | | immutable borrow occurs here + | --- ------------ ^^^^^^^^^^^^^ immutable borrow occurs here + | | | + | | mutable borrow later used by call | mutable borrow occurs here - | borrow later used here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:151:51 | LL | reg.register_static(Box::new(TrivialPass::new(&mut reg.sess_mut))); - | ----------------------------------------------^^^^^^^^^^^^^^^^^--- - | | | - | | second mutable borrow occurs here + | --- --------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | | | + | | first borrow later used by call | first mutable borrow occurs here - | borrow later used here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:156:54 | LL | reg.register_bound(Box::new(TrivialPass::new_mut(&mut reg.sess_mut))); - | -------------------------------------------------^^^^^^^^^^^^^^^^^--- - | | | - | | second mutable borrow occurs here + | --- -------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | | | + | | first borrow later used by call | first mutable borrow occurs here - | borrow later used here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:161:53 | LL | reg.register_univ(Box::new(TrivialPass::new_mut(&mut reg.sess_mut))); - | ------------------------------------------------^^^^^^^^^^^^^^^^^--- - | | | - | | second mutable borrow occurs here + | --- ------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | | | + | | first borrow later used by call | first mutable borrow occurs here - | borrow later used here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:166:44 | LL | reg.register_ref(&TrivialPass::new_mut(&mut reg.sess_mut)); - | ---------------------------------------^^^^^^^^^^^^^^^^^-- - | | | - | | second mutable borrow occurs here + | --- ------------ ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | | | + | | first borrow later used by call | first mutable borrow occurs here - | borrow later used here error[E0502]: cannot borrow `reg.sess_mut` as immutable because it is also borrowed as mutable --> $DIR/two-phase-surprise-no-conflict.rs:178:50 | LL | reg.register_bound(Box::new(CapturePass::new(®.sess_mut))); - | ---------------------------------------------^^^^^^^^^^^^^--- - | | | - | | immutable borrow occurs here + | --- -------------- ^^^^^^^^^^^^^ immutable borrow occurs here + | | | + | | mutable borrow later used by call | mutable borrow occurs here - | borrow later used here error[E0502]: cannot borrow `reg.sess_mut` as immutable because it is also borrowed as mutable --> $DIR/two-phase-surprise-no-conflict.rs:183:49 | LL | reg.register_univ(Box::new(CapturePass::new(®.sess_mut))); - | --------------------------------------------^^^^^^^^^^^^^--- - | | | - | | immutable borrow occurs here + | --- ------------- ^^^^^^^^^^^^^ immutable borrow occurs here + | | | + | | mutable borrow later used by call | mutable borrow occurs here - | borrow later used here error[E0502]: cannot borrow `reg.sess_mut` as immutable because it is also borrowed as mutable --> $DIR/two-phase-surprise-no-conflict.rs:188:40 | LL | reg.register_ref(&CapturePass::new(®.sess_mut)); - | -----------------------------------^^^^^^^^^^^^^-- - | | | - | | immutable borrow occurs here + | --- ------------ ^^^^^^^^^^^^^ immutable borrow occurs here + | | | + | | mutable borrow later used by call | mutable borrow occurs here - | borrow later used here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:200:54 | LL | reg.register_bound(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); - | -------------------------------------------------^^^^^^^^^^^^^^^^^--- - | | | - | | second mutable borrow occurs here + | --- -------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | | | + | | first borrow later used by call | first mutable borrow occurs here - | borrow later used here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:206:53 | LL | reg.register_univ(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); - | ------------------------------------------------^^^^^^^^^^^^^^^^^--- - | | | - | | second mutable borrow occurs here + | --- ------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | | | + | | first borrow later used by call | first mutable borrow occurs here - | borrow later used here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:212:44 | LL | reg.register_ref(&CapturePass::new_mut(&mut reg.sess_mut)); - | ---------------------------------------^^^^^^^^^^^^^^^^^-- - | | | - | | second mutable borrow occurs here + | --- ------------ ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | | | + | | first borrow later used by call | first mutable borrow occurs here - | borrow later used here error: aborting due to 17 previous errors diff --git a/src/test/ui/codemap_tests/issue-11715.nll.stderr b/src/test/ui/codemap_tests/issue-11715.nll.stderr index c0eeb63447d..76ed3bc3137 100644 --- a/src/test/ui/codemap_tests/issue-11715.nll.stderr +++ b/src/test/ui/codemap_tests/issue-11715.nll.stderr @@ -7,7 +7,7 @@ LL | let z = &mut x; //~ ERROR cannot borrow | ^^^^^^ second mutable borrow occurs here LL | z.use_mut(); LL | y.use_mut(); - | - borrow later used here + | - first borrow later used here error: aborting due to previous error diff --git a/src/test/ui/codemap_tests/one_line.nll.stderr b/src/test/ui/codemap_tests/one_line.nll.stderr index 52ce3787f58..d79405e9a59 100644 --- a/src/test/ui/codemap_tests/one_line.nll.stderr +++ b/src/test/ui/codemap_tests/one_line.nll.stderr @@ -2,11 +2,10 @@ error[E0499]: cannot borrow `v` as mutable more than once at a time --> $DIR/one_line.rs:13:12 | LL | v.push(v.pop().unwrap()); //~ ERROR cannot borrow - | -------^---------------- - | | | - | | second mutable borrow occurs here + | - ---- ^ second mutable borrow occurs here + | | | + | | first borrow later used by call | first mutable borrow occurs here - | borrow later used here error: aborting due to previous error diff --git a/src/test/ui/coercion/coerce-overloaded-autoderef.ast.nll.stderr b/src/test/ui/coercion/coerce-overloaded-autoderef.ast.nll.stderr index 29b6f057562..60584e481c1 100644 --- a/src/test/ui/coercion/coerce-overloaded-autoderef.ast.nll.stderr +++ b/src/test/ui/coercion/coerce-overloaded-autoderef.ast.nll.stderr @@ -7,7 +7,7 @@ LL | let z = borrow_mut(x); | ^ second mutable borrow occurs here ... LL | drop((y, z)); - | - borrow later used here + | - first borrow later used here error[E0506]: cannot assign to `**x` because it is borrowed --> $DIR/coerce-overloaded-autoderef.rs:31:5 @@ -25,21 +25,20 @@ error[E0499]: cannot borrow `*x` as mutable more than once at a time --> $DIR/coerce-overloaded-autoderef.rs:38:20 | LL | borrow_mut2(x, x); - | ---------------^- - | | | | - | | | second mutable borrow occurs here + | ----------- - ^ second mutable borrow occurs here + | | | | | first mutable borrow occurs here - | borrow later used here + | first borrow later used by call error[E0502]: cannot borrow `*x` as mutable because it is also borrowed as immutable --> $DIR/coerce-overloaded-autoderef.rs:44:5 | LL | borrow2(x, x); - | ^^^^^^^^^^^-^ + | -------^^^^-^ | | | | | immutable borrow occurs here | mutable borrow occurs here - | borrow later used here + | immutable borrow later used by call error: aborting due to 4 previous errors diff --git a/src/test/ui/coercion/coerce-overloaded-autoderef.mir.nll.stderr b/src/test/ui/coercion/coerce-overloaded-autoderef.mir.nll.stderr index 29b6f057562..60584e481c1 100644 --- a/src/test/ui/coercion/coerce-overloaded-autoderef.mir.nll.stderr +++ b/src/test/ui/coercion/coerce-overloaded-autoderef.mir.nll.stderr @@ -7,7 +7,7 @@ LL | let z = borrow_mut(x); | ^ second mutable borrow occurs here ... LL | drop((y, z)); - | - borrow later used here + | - first borrow later used here error[E0506]: cannot assign to `**x` because it is borrowed --> $DIR/coerce-overloaded-autoderef.rs:31:5 @@ -25,21 +25,20 @@ error[E0499]: cannot borrow `*x` as mutable more than once at a time --> $DIR/coerce-overloaded-autoderef.rs:38:20 | LL | borrow_mut2(x, x); - | ---------------^- - | | | | - | | | second mutable borrow occurs here + | ----------- - ^ second mutable borrow occurs here + | | | | | first mutable borrow occurs here - | borrow later used here + | first borrow later used by call error[E0502]: cannot borrow `*x` as mutable because it is also borrowed as immutable --> $DIR/coerce-overloaded-autoderef.rs:44:5 | LL | borrow2(x, x); - | ^^^^^^^^^^^-^ + | -------^^^^-^ | | | | | immutable borrow occurs here | mutable borrow occurs here - | borrow later used here + | immutable borrow later used by call error: aborting due to 4 previous errors diff --git a/src/test/ui/coercion/coerce-overloaded-autoderef.mir.stderr b/src/test/ui/coercion/coerce-overloaded-autoderef.mir.stderr index fbc49a7e91f..0ca752b5ff9 100644 --- a/src/test/ui/coercion/coerce-overloaded-autoderef.mir.stderr +++ b/src/test/ui/coercion/coerce-overloaded-autoderef.mir.stderr @@ -7,7 +7,7 @@ LL | let z = borrow_mut(x); | ^ second mutable borrow occurs here ... LL | drop((y, z)); - | - borrow later used here + | - first borrow later used here error[E0506]: cannot assign to `**x` because it is borrowed --> $DIR/coerce-overloaded-autoderef.rs:31:5 @@ -25,21 +25,19 @@ error[E0499]: cannot borrow `*x` as mutable more than once at a time --> $DIR/coerce-overloaded-autoderef.rs:38:20 | LL | borrow_mut2(x, x); - | ---------------^- - | | | | - | | | second mutable borrow occurs here + | ----------- - ^ second mutable borrow occurs here + | | | | | first mutable borrow occurs here - | borrow later used here + | first borrow later used by call error[E0502]: cannot borrow `*x` as immutable because it is also borrowed as mutable --> $DIR/coerce-overloaded-autoderef.rs:44:16 | LL | borrow2(x, x); - | -----------^- - | | | | - | | | immutable borrow occurs here + | ------- - ^ immutable borrow occurs here + | | | | | mutable borrow occurs here - | borrow later used here + | mutable borrow later used by call error: aborting due to 4 previous errors diff --git a/src/test/ui/did_you_mean/issue-34126.nll.stderr b/src/test/ui/did_you_mean/issue-34126.nll.stderr index 004c43a7343..8e29dccb8a7 100644 --- a/src/test/ui/did_you_mean/issue-34126.nll.stderr +++ b/src/test/ui/did_you_mean/issue-34126.nll.stderr @@ -11,11 +11,10 @@ error[E0502]: cannot borrow `self` as mutable because it is also borrowed as imm --> $DIR/issue-34126.rs:16:18 | LL | self.run(&mut self); //~ ERROR cannot borrow - | ---------^^^^^^^^^- - | | | - | | mutable borrow occurs here + | ---- --- ^^^^^^^^^ mutable borrow occurs here + | | | + | | immutable borrow later used by call | immutable borrow occurs here - | borrow later used here error: aborting due to 2 previous errors diff --git a/src/test/ui/error-codes/E0499.nll.stderr b/src/test/ui/error-codes/E0499.nll.stderr index 89801693b76..39815ac6f17 100644 --- a/src/test/ui/error-codes/E0499.nll.stderr +++ b/src/test/ui/error-codes/E0499.nll.stderr @@ -7,7 +7,7 @@ LL | let mut a = &mut i; //~ ERROR E0499 | ^^^^^^ second mutable borrow occurs here LL | a.use_mut(); LL | x.use_mut(); - | - borrow later used here + | - first borrow later used here error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0502.nll.stderr b/src/test/ui/error-codes/E0502.nll.stderr index 565f73616b9..ce082710246 100644 --- a/src/test/ui/error-codes/E0502.nll.stderr +++ b/src/test/ui/error-codes/E0502.nll.stderr @@ -6,7 +6,7 @@ LL | let ref y = a; LL | bar(a); //~ ERROR E0502 | ^^^^^^ mutable borrow occurs here LL | y.use_ref(); - | - borrow later used here + | - immutable borrow later used here error: aborting due to previous error diff --git a/src/test/ui/generator/yield-while-iterating.nll.stderr b/src/test/ui/generator/yield-while-iterating.nll.stderr index af79eb7ac05..d332df6e4ba 100644 --- a/src/test/ui/generator/yield-while-iterating.nll.stderr +++ b/src/test/ui/generator/yield-while-iterating.nll.stderr @@ -19,7 +19,7 @@ LL | | }; LL | println!("{}", x[0]); //~ ERROR | ^ immutable borrow occurs here LL | b.resume(); - | - borrow later used here + | - mutable borrow later used here error: aborting due to 2 previous errors diff --git a/src/test/ui/generator/yield-while-ref-reborrowed.nll.stderr b/src/test/ui/generator/yield-while-ref-reborrowed.nll.stderr index 14989079527..b5c392c51ec 100644 --- a/src/test/ui/generator/yield-while-ref-reborrowed.nll.stderr +++ b/src/test/ui/generator/yield-while-ref-reborrowed.nll.stderr @@ -11,7 +11,7 @@ LL | | }; LL | println!("{}", x); //~ ERROR | ^ borrow occurs here LL | b.resume(); - | - borrow later used here + | - first borrow later used here error: aborting due to previous error diff --git a/src/test/ui/hashmap-iter-value-lifetime.nll.stderr b/src/test/ui/hashmap-iter-value-lifetime.nll.stderr index ec52d19cd1c..61a28bfd17b 100644 --- a/src/test/ui/hashmap-iter-value-lifetime.nll.stderr +++ b/src/test/ui/hashmap-iter-value-lifetime.nll.stderr @@ -8,7 +8,7 @@ LL | my_stuff.clear(); //~ ERROR cannot borrow | ^^^^^^^^^^^^^^^^ mutable borrow occurs here LL | LL | println!("{}", *thing); - | ------ borrow later used here + | ------ immutable borrow later used here error: aborting due to previous error diff --git a/src/test/ui/hashmap-lifetimes.nll.stderr b/src/test/ui/hashmap-lifetimes.nll.stderr index 943b684fe8d..4cf87ee8dc7 100644 --- a/src/test/ui/hashmap-lifetimes.nll.stderr +++ b/src/test/ui/hashmap-lifetimes.nll.stderr @@ -6,7 +6,7 @@ LL | let mut it = my_stuff.iter(); LL | my_stuff.insert(1, 43); //~ ERROR cannot borrow | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here LL | it; - | -- borrow later used here + | -- immutable borrow later used here error: aborting due to previous error diff --git a/src/test/ui/hrtb/hrtb-debruijn-in-receiver.nll.stderr b/src/test/ui/hrtb/hrtb-debruijn-in-receiver.nll.stderr index 06970229325..10d028b05a7 100644 --- a/src/test/ui/hrtb/hrtb-debruijn-in-receiver.nll.stderr +++ b/src/test/ui/hrtb/hrtb-debruijn-in-receiver.nll.stderr @@ -7,7 +7,7 @@ LL | foo.insert(); //~ ERROR cannot borrow | ^^^ | | | second mutable borrow occurs here - | borrow later used here + | first borrow later used here error: aborting due to previous error diff --git a/src/test/ui/hygiene/fields-numeric-borrowck.nll.stderr b/src/test/ui/hygiene/fields-numeric-borrowck.nll.stderr index 56dfee1fe33..4130ad7639f 100644 --- a/src/test/ui/hygiene/fields-numeric-borrowck.nll.stderr +++ b/src/test/ui/hygiene/fields-numeric-borrowck.nll.stderr @@ -7,7 +7,7 @@ LL | let S { 0: ref mut borrow2 } = s; | ^^^^^^^^^^^^^^^ second mutable borrow occurs here ... LL | borrow1.use_mut(); - | ------- borrow later used here + | ------- first borrow later used here error: aborting due to previous error diff --git a/src/test/ui/issues/issue-11192.nll.stderr b/src/test/ui/issues/issue-11192.nll.stderr index a7e6c9f2b33..4d4320083e4 100644 --- a/src/test/ui/issues/issue-11192.nll.stderr +++ b/src/test/ui/issues/issue-11192.nll.stderr @@ -8,10 +8,9 @@ LL | ptr = box Foo { x: ptr.x + 1 }; | --- first borrow occurs due to use of `ptr` in closure ... LL | test(&*ptr); - | -----^^^^^- - | | | - | | immutable borrow occurs here - | borrow later used here + | ---- ^^^^^ immutable borrow occurs here + | | + | mutable borrow later used by call error: aborting due to previous error diff --git a/src/test/ui/issues/issue-18566.nll.stderr b/src/test/ui/issues/issue-18566.nll.stderr index b5ed33d07c5..c815ad9049f 100644 --- a/src/test/ui/issues/issue-18566.nll.stderr +++ b/src/test/ui/issues/issue-18566.nll.stderr @@ -2,11 +2,10 @@ error[E0499]: cannot borrow `*s` as mutable more than once at a time --> $DIR/issue-18566.rs:33:19 | LL | MyPtr(s).poke(s); - | --------------^- - | | | | - | | | second mutable borrow occurs here - | | first mutable borrow occurs here - | borrow later used here + | - ---- ^ second mutable borrow occurs here + | | | + | | first borrow later used by call + | first mutable borrow occurs here error: aborting due to previous error diff --git a/src/test/ui/issues/issue-18783.nll.stderr b/src/test/ui/issues/issue-18783.nll.stderr index 8acdc73bf0e..2531279f750 100644 --- a/src/test/ui/issues/issue-18783.nll.stderr +++ b/src/test/ui/issues/issue-18783.nll.stderr @@ -11,7 +11,7 @@ LL | c.push(Box::new(|| y = 0)); | second mutable borrow occurs here LL | //~^ ERROR cannot borrow `y` as mutable more than once at a time LL | } - | - borrow later used here, when `c` is dropped + | - first borrow later used here, when `c` is dropped error[E0499]: cannot borrow `y` as mutable more than once at a time --> $DIR/issue-18783.rs:26:29 @@ -26,7 +26,7 @@ LL | Push::push(&c, Box::new(|| y = 0)); | second mutable borrow occurs here LL | //~^ ERROR cannot borrow `y` as mutable more than once at a time LL | } - | - borrow later used here, when `c` is dropped + | - first borrow later used here, when `c` is dropped error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-25793.nll.stderr b/src/test/ui/issues/issue-25793.nll.stderr index bd48d0eeb7c..f3d855feca2 100644 --- a/src/test/ui/issues/issue-25793.nll.stderr +++ b/src/test/ui/issues/issue-25793.nll.stderr @@ -7,10 +7,9 @@ LL | $this.width.unwrap() LL | let r = &mut *self; | ---------- borrow of `*self` occurs here LL | r.get_size(width!(self)) - | ------------------------ - | | | - | | in this macro invocation - | borrow later used here + | -------- ------------ in this macro invocation + | | + | borrow later used by call error: aborting due to previous error diff --git a/src/test/ui/issues/issue-42106.nll.stderr b/src/test/ui/issues/issue-42106.nll.stderr index 39e3c218f40..5750b1761e5 100644 --- a/src/test/ui/issues/issue-42106.nll.stderr +++ b/src/test/ui/issues/issue-42106.nll.stderr @@ -6,7 +6,7 @@ LL | let _a = &collection; LL | collection.swap(1, 2); //~ ERROR also borrowed as immutable | ^^^^^^^^^^ mutable borrow occurs here LL | _a.use_ref(); - | -- borrow later used here + | -- immutable borrow later used here error: aborting due to previous error diff --git a/src/test/ui/issues/issue-45157.stderr b/src/test/ui/issues/issue-45157.stderr index e528a84ebd1..1512ea53a07 100644 --- a/src/test/ui/issues/issue-45157.stderr +++ b/src/test/ui/issues/issue-45157.stderr @@ -8,7 +8,7 @@ LL | let nref = &u.z.c; | ^^^^^^ immutable borrow occurs here LL | //~^ ERROR cannot borrow `u.z.c` as immutable because it is also borrowed as mutable [E0502] LL | println!("{} {}", mref, nref) - | ---- borrow later used here + | ---- mutable borrow later used here error: aborting due to previous error diff --git a/src/test/ui/methods/method-self-arg-2.nll.stderr b/src/test/ui/methods/method-self-arg-2.nll.stderr index f876aa281d1..df2902c0674 100644 --- a/src/test/ui/methods/method-self-arg-2.nll.stderr +++ b/src/test/ui/methods/method-self-arg-2.nll.stderr @@ -6,7 +6,7 @@ LL | let y = &mut x; LL | Foo::bar(&x); //~ERROR cannot borrow `x` | ^^ immutable borrow occurs here LL | y.use_mut(); - | - borrow later used here + | - mutable borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/method-self-arg-2.rs:30:14 @@ -16,7 +16,7 @@ LL | let y = &mut x; LL | Foo::baz(&mut x); //~ERROR cannot borrow `x` | ^^^^^^ second mutable borrow occurs here LL | y.use_mut(); - | - borrow later used here + | - first borrow later used here error: aborting due to 2 previous errors diff --git a/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.nll.stderr b/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.nll.stderr index e23a6beb87e..3fc4fa3cac8 100644 --- a/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.nll.stderr +++ b/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.nll.stderr @@ -2,11 +2,10 @@ error[E0499]: cannot borrow `*f` as mutable more than once at a time --> $DIR/moves-based-on-type-no-recursive-stack-closure.rs:30:27 | LL | (f.c)(f, true); - | ------^------- - | | | - | | second mutable borrow occurs here + | ----- ^ second mutable borrow occurs here + | | | first mutable borrow occurs here - | borrow later used here + | first borrow later used by call error[E0382]: borrow of moved value: `f` --> $DIR/moves-based-on-type-no-recursive-stack-closure.rs:42:5 diff --git a/src/test/ui/mut/mut-cant-alias.nll.stderr b/src/test/ui/mut/mut-cant-alias.nll.stderr index e2758f810db..7b5a63b267f 100644 --- a/src/test/ui/mut/mut-cant-alias.nll.stderr +++ b/src/test/ui/mut/mut-cant-alias.nll.stderr @@ -6,7 +6,7 @@ LL | let b1 = &mut *b; LL | let b2 = &mut *b; //~ ERROR cannot borrow | ^ second mutable borrow occurs here LL | b1.use_mut(); - | -- borrow later used here + | -- first borrow later used here error: aborting due to previous error diff --git a/src/test/ui/nll/borrowed-local-error.stderr b/src/test/ui/nll/borrowed-local-error.stderr index 28353a8bc2b..4da597791ef 100644 --- a/src/test/ui/nll/borrowed-local-error.stderr +++ b/src/test/ui/nll/borrowed-local-error.stderr @@ -1,16 +1,14 @@ error[E0597]: `v` does not live long enough --> $DIR/borrowed-local-error.rs:20:9 | -LL | let x = gimme({ - | _____________- -LL | | let v = (22,); -LL | | &v - | | ^^ borrowed value does not live long enough -LL | | //~^ ERROR `v` does not live long enough [E0597] -LL | | }); - | |_____-- borrow later used here - | | - | `v` dropped here while still borrowed +LL | let x = gimme({ + | ----- borrow later used by call +LL | let v = (22,); +LL | &v + | ^^ borrowed value does not live long enough +LL | //~^ ERROR `v` does not live long enough [E0597] +LL | }); + | - `v` dropped here while still borrowed error: aborting due to previous error diff --git a/src/test/ui/nll/borrowed-referent-issue-38899.stderr b/src/test/ui/nll/borrowed-referent-issue-38899.stderr index 5c5a66e7e21..ff8a83024f1 100644 --- a/src/test/ui/nll/borrowed-referent-issue-38899.stderr +++ b/src/test/ui/nll/borrowed-referent-issue-38899.stderr @@ -8,7 +8,7 @@ LL | let p: &'a u8 = &*block.current; | ^^^^^^^^^^^^^^^ immutable borrow occurs here LL | //~^ ERROR cannot borrow `*block.current` as immutable because it is also borrowed as mutable LL | drop(x); - | - borrow later used here + | - mutable borrow later used here error: aborting due to previous error diff --git a/src/test/ui/nll/closure-access-spans.stderr b/src/test/ui/nll/closure-access-spans.stderr index 0042b5d7d52..9306926bf38 100644 --- a/src/test/ui/nll/closure-access-spans.stderr +++ b/src/test/ui/nll/closure-access-spans.stderr @@ -8,7 +8,7 @@ LL | || x; //~ ERROR | | | immutable borrow occurs here LL | r.use_mut(); - | - borrow later used here + | - mutable borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/closure-access-spans.rs:23:5 @@ -20,7 +20,7 @@ LL | || x = 2; //~ ERROR | | | second mutable borrow occurs here LL | r.use_mut(); - | - borrow later used here + | - first borrow later used here error[E0500]: closure requires unique access to `x` but it is already borrowed --> $DIR/closure-access-spans.rs:29:5 @@ -32,7 +32,7 @@ LL | || *x = 2; //~ ERROR | | | closure construction occurs here LL | r.use_mut(); - | - borrow later used here + | - first borrow later used here error[E0503]: cannot use `x` because it was mutably borrowed --> $DIR/closure-access-spans.rs:35:13 diff --git a/src/test/ui/nll/closure-borrow-spans.stderr b/src/test/ui/nll/closure-borrow-spans.stderr index 1b9420b3c0b..3e423dadd19 100644 --- a/src/test/ui/nll/closure-borrow-spans.stderr +++ b/src/test/ui/nll/closure-borrow-spans.stderr @@ -20,7 +20,7 @@ LL | let f = || x; LL | let y = &mut x; //~ ERROR | ^^^^^^ mutable borrow occurs here LL | f.use_ref(); - | - borrow later used here + | - immutable borrow later used here error[E0597]: `x` does not live long enough --> $DIR/closure-borrow-spans.rs:31:16 @@ -68,7 +68,7 @@ LL | let f = || x = 0; LL | let y = &x; //~ ERROR | ^^ immutable borrow occurs here LL | f.use_ref(); - | - borrow later used here + | - mutable borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/closure-borrow-spans.rs:56:13 @@ -80,7 +80,7 @@ LL | let f = || x = 0; LL | let y = &mut x; //~ ERROR | ^^^^^^ second mutable borrow occurs here LL | f.use_ref(); - | - borrow later used here + | - first borrow later used here error[E0597]: `x` does not live long enough --> $DIR/closure-borrow-spans.rs:64:16 @@ -128,7 +128,7 @@ LL | let f = || *x = 0; LL | let y = &x; //~ ERROR | ^^ borrow occurs here LL | f.use_ref(); - | - borrow later used here + | - first borrow later used here error[E0501]: cannot borrow `x` as mutable because previous closure requires unique access --> $DIR/closure-borrow-spans.rs:89:13 @@ -140,7 +140,7 @@ LL | let f = || *x = 0; LL | let y = &mut x; //~ ERROR | ^^^^^^ borrow occurs here LL | f.use_ref(); - | - borrow later used here + | - first borrow later used here error[E0597]: `x` does not live long enough --> $DIR/closure-borrow-spans.rs:98:17 diff --git a/src/test/ui/nll/get_default.nll.stderr b/src/test/ui/nll/get_default.nll.stderr index 580dce3c0fe..a22f3032f30 100644 --- a/src/test/ui/nll/get_default.nll.stderr +++ b/src/test/ui/nll/get_default.nll.stderr @@ -43,7 +43,7 @@ LL | match map.get() { LL | map.set(String::new()); // Ideally, this would not error. | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here | -note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 26:1... +note: immutable borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 26:1... --> $DIR/get_default.rs:26:1 | LL | / fn ok(map: &mut Map) -> &String { @@ -64,7 +64,7 @@ LL | Some(v) => { LL | map.set(String::new()); // Both AST and MIR error here | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here | -note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 41:1... +note: immutable borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 41:1... --> $DIR/get_default.rs:41:1 | LL | / fn err(map: &mut Map) -> &String { @@ -85,7 +85,7 @@ LL | match map.get() { LL | map.set(String::new()); // Ideally, just AST would error here | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here | -note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 41:1... +note: immutable borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 41:1... --> $DIR/get_default.rs:41:1 | LL | / fn err(map: &mut Map) -> &String { diff --git a/src/test/ui/nll/get_default.stderr b/src/test/ui/nll/get_default.stderr index 2f8eab907c7..8c93eb059e8 100644 --- a/src/test/ui/nll/get_default.stderr +++ b/src/test/ui/nll/get_default.stderr @@ -43,7 +43,7 @@ LL | match map.get() { LL | map.set(String::new()); // Ideally, this would not error. | ^^^ mutable borrow occurs here | -note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 26:1... +note: immutable borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 26:1... --> $DIR/get_default.rs:26:1 | LL | / fn ok(map: &mut Map) -> &String { @@ -64,7 +64,7 @@ LL | Some(v) => { LL | map.set(String::new()); // Both AST and MIR error here | ^^^ mutable borrow occurs here | -note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 41:1... +note: immutable borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 41:1... --> $DIR/get_default.rs:41:1 | LL | / fn err(map: &mut Map) -> &String { @@ -85,7 +85,7 @@ LL | match map.get() { LL | map.set(String::new()); // Ideally, just AST would error here | ^^^ mutable borrow occurs here | -note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 41:1... +note: immutable borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 41:1... --> $DIR/get_default.rs:41:1 | LL | / fn err(map: &mut Map) -> &String { diff --git a/src/test/ui/nll/issue-51268.stderr b/src/test/ui/nll/issue-51268.stderr index 2ecfe03e7de..44f7c52d257 100644 --- a/src/test/ui/nll/issue-51268.stderr +++ b/src/test/ui/nll/issue-51268.stderr @@ -1,19 +1,16 @@ error[E0502]: cannot borrow `self.thing` as mutable because it is also borrowed as immutable --> $DIR/issue-51268.rs:28:9 | -LL | self.thing.bar(|| { - | ^ -- immutable borrow occurs here - | _________| - | |_________| - | || -LL | || //~^ ERROR cannot borrow `self.thing` as mutable because it is also borrowed as immutable [E0502] -LL | || &self.number; - | || ---- first borrow occurs due to use of `self` in closure -LL | || }); - | || ^ - | ||__________| - | |___________mutable borrow occurs here - | borrow later used here +LL | self.thing.bar(|| { + | ^ --- -- immutable borrow occurs here + | | | + | _________| immutable borrow later used by call + | | +LL | | //~^ ERROR cannot borrow `self.thing` as mutable because it is also borrowed as immutable [E0502] +LL | | &self.number; + | | ---- first borrow occurs due to use of `self` in closure +LL | | }); + | |__________^ mutable borrow occurs here error: aborting due to previous error diff --git a/src/test/ui/nll/loan_ends_mid_block_vec.stderr b/src/test/ui/nll/loan_ends_mid_block_vec.stderr index 4c739cfe978..2869035c3f3 100644 --- a/src/test/ui/nll/loan_ends_mid_block_vec.stderr +++ b/src/test/ui/nll/loan_ends_mid_block_vec.stderr @@ -80,7 +80,7 @@ LL | data.push('d'); | ^^^^ second mutable borrow occurs here ... LL | capitalize(slice); - | ----- borrow later used here + | ----- first borrow later used here error[E0499]: cannot borrow `data` as mutable more than once at a time (Mir) --> $DIR/loan_ends_mid_block_vec.rs:27:5 @@ -92,7 +92,7 @@ LL | data.push('e'); | ^^^^ second mutable borrow occurs here ... LL | capitalize(slice); - | ----- borrow later used here + | ----- first borrow later used here error[E0499]: cannot borrow `data` as mutable more than once at a time (Mir) --> $DIR/loan_ends_mid_block_vec.rs:30:5 @@ -104,7 +104,7 @@ LL | data.push('f'); | ^^^^ second mutable borrow occurs here ... LL | capitalize(slice); - | ----- borrow later used here + | ----- first borrow later used here error: aborting due to 9 previous errors diff --git a/src/test/ui/nll/region-ends-after-if-condition.nll.stderr b/src/test/ui/nll/region-ends-after-if-condition.nll.stderr index fa3a5e0c0d7..c1bfa4bffc0 100644 --- a/src/test/ui/nll/region-ends-after-if-condition.nll.stderr +++ b/src/test/ui/nll/region-ends-after-if-condition.nll.stderr @@ -32,7 +32,7 @@ LL | my_struct.field.push_str("Hello, world!"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here ... LL | drop(value); - | ----- borrow later used here + | ----- immutable borrow later used here error: aborting due to 3 previous errors diff --git a/src/test/ui/nll/region-ends-after-if-condition.stderr b/src/test/ui/nll/region-ends-after-if-condition.stderr index d966c62c85f..eaa5e815de8 100644 --- a/src/test/ui/nll/region-ends-after-if-condition.stderr +++ b/src/test/ui/nll/region-ends-after-if-condition.stderr @@ -32,7 +32,7 @@ LL | my_struct.field.push_str("Hello, world!"); | ^^^^^^^^^^^^^^^ mutable borrow occurs here ... LL | drop(value); - | ----- borrow later used here + | ----- immutable borrow later used here error: aborting due to 3 previous errors diff --git a/src/test/ui/nll/return_from_loop.stderr b/src/test/ui/nll/return_from_loop.stderr index 7130aa64dab..d631bb58af6 100644 --- a/src/test/ui/nll/return_from_loop.stderr +++ b/src/test/ui/nll/return_from_loop.stderr @@ -32,7 +32,7 @@ LL | my_struct.field.push_str("Hello, world!"); | ^^^^^^^^^^^^^^^ second mutable borrow occurs here ... LL | value.len(); - | ----- borrow later used here + | ----- first borrow later used here error: aborting due to 3 previous errors diff --git a/src/test/ui/regions/region-bound-on-closure-outlives-call.nll.stderr b/src/test/ui/regions/region-bound-on-closure-outlives-call.nll.stderr index da6ebaaefad..f11cc77bbea 100644 --- a/src/test/ui/regions/region-bound-on-closure-outlives-call.nll.stderr +++ b/src/test/ui/regions/region-bound-on-closure-outlives-call.nll.stderr @@ -2,12 +2,11 @@ error[E0505]: cannot move out of `f` because it is borrowed --> $DIR/region-bound-on-closure-outlives-call.rs:12:25 | LL | (|x| f(x))(call_rec(f)) //~ ERROR cannot move out of `f` - | --------------------^-- - | || | | - | || | move out of `f` occurs here + | ---------- ^ move out of `f` occurs here + | || | | || borrow occurs due to use in closure | |borrow of `f` occurs here - | borrow later used here + | borrow later used by call error: aborting due to previous error diff --git a/src/test/ui/regions/regions-adjusted-lvalue-op.nll.stderr b/src/test/ui/regions/regions-adjusted-lvalue-op.nll.stderr index f342155c8b1..fa963714849 100644 --- a/src/test/ui/regions/regions-adjusted-lvalue-op.nll.stderr +++ b/src/test/ui/regions/regions-adjusted-lvalue-op.nll.stderr @@ -2,21 +2,19 @@ error[E0502]: cannot borrow `v` as immutable because it is also borrowed as muta --> $DIR/regions-adjusted-lvalue-op.rs:24:16 | LL | v[0].oh_no(&v); //~ ERROR cannot borrow `v` as immutable because - | -----------^^- - | | | - | | immutable borrow occurs here + | - ----- ^^ immutable borrow occurs here + | | | + | | mutable borrow later used by call | mutable borrow occurs here - | borrow later used here error[E0502]: cannot borrow `v` as immutable because it is also borrowed as mutable --> $DIR/regions-adjusted-lvalue-op.rs:25:16 | LL | (*v).oh_no(&v); //~ ERROR cannot borrow `v` as immutable because - | -----------^^- - | | | | - | | | immutable borrow occurs here - | | mutable borrow occurs here - | borrow later used here + | - ----- ^^ immutable borrow occurs here + | | | + | | mutable borrow later used by call + | mutable borrow occurs here error: aborting due to 2 previous errors diff --git a/src/test/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.nll.stderr b/src/test/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.nll.stderr index 626ffad5ba7..84cd097e33c 100644 --- a/src/test/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.nll.stderr +++ b/src/test/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.nll.stderr @@ -7,7 +7,7 @@ LL | foo.mutate(); | ^^^^^^^^^^^^ mutable borrow occurs here LL | //~^ ERROR cannot borrow `foo` as mutable LL | println!("foo={:?}", *string); - | ------- borrow used here, in later iteration of loop + | ------- immutable borrow used here, in later iteration of loop error: aborting due to previous error diff --git a/src/test/ui/span/borrowck-call-is-borrow-issue-12224.nll.stderr b/src/test/ui/span/borrowck-call-is-borrow-issue-12224.nll.stderr index a05a3911aa7..978ca66a089 100644 --- a/src/test/ui/span/borrowck-call-is-borrow-issue-12224.nll.stderr +++ b/src/test/ui/span/borrowck-call-is-borrow-issue-12224.nll.stderr @@ -1,16 +1,14 @@ error[E0499]: cannot borrow `f` as mutable more than once at a time --> $DIR/borrowck-call-is-borrow-issue-12224.rs:22:16 | -LL | f(Box::new(|| { - | - ^^ second mutable borrow occurs here - | | - | _____first mutable borrow occurs here - | | -LL | | //~^ ERROR: cannot borrow `f` as mutable more than once -LL | | f((Box::new(|| {}))) - | | - second borrow occurs due to use of `f` in closure -LL | | })); - | |_______- borrow later used here +LL | f(Box::new(|| { + | - ^^ second mutable borrow occurs here + | | + | first mutable borrow occurs here + | first borrow later used by call +LL | //~^ ERROR: cannot borrow `f` as mutable more than once +LL | f((Box::new(|| {}))) + | - second borrow occurs due to use of `f` in closure error[E0596]: cannot borrow `*f` as mutable, as it is behind a `&` reference --> $DIR/borrowck-call-is-borrow-issue-12224.rs:35:5 @@ -40,17 +38,13 @@ LL | foo(f); error[E0505]: cannot move out of `f` because it is borrowed --> $DIR/borrowck-call-is-borrow-issue-12224.rs:65:16 | -LL | f(Box::new(|a| { - | - ^^^ move out of `f` occurs here - | | - | _____borrow of `f` occurs here - | | -LL | | foo(f); - | | - move occurs due to use in closure -LL | | //~^ ERROR cannot move `f` into closure because it is borrowed -LL | | //~| ERROR cannot move out of captured outer variable in an `FnMut` closure -LL | | }), 3); - | |__________- borrow later used here +LL | f(Box::new(|a| { + | - ^^^ move out of `f` occurs here + | | + | borrow of `f` occurs here + | borrow later used by call +LL | foo(f); + | - move occurs due to use in closure error: aborting due to 5 previous errors diff --git a/src/test/ui/unboxed-closures/unboxed-closures-recursive-fn-using-fn-mut.nll.stderr b/src/test/ui/unboxed-closures/unboxed-closures-recursive-fn-using-fn-mut.nll.stderr index e2747e1bb62..652a93e610f 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-recursive-fn-using-fn-mut.nll.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-recursive-fn-using-fn-mut.nll.stderr @@ -2,11 +2,10 @@ error[E0499]: cannot borrow `*self` as mutable more than once at a time --> $DIR/unboxed-closures-recursive-fn-using-fn-mut.rs:32:21 | LL | (self.func)(self, arg) - | ------------^^^^------ - | | | - | | second mutable borrow occurs here + | ----------- ^^^^ second mutable borrow occurs here + | | | first mutable borrow occurs here - | borrow later used here + | first borrow later used by call error: aborting due to previous error diff --git a/src/test/ui/vec/vec-mut-iter-borrow.nll.stderr b/src/test/ui/vec/vec-mut-iter-borrow.nll.stderr index cff263231dd..a5c6e5f1110 100644 --- a/src/test/ui/vec/vec-mut-iter-borrow.nll.stderr +++ b/src/test/ui/vec/vec-mut-iter-borrow.nll.stderr @@ -5,7 +5,7 @@ LL | for x in &mut xs { | ------- | | | first mutable borrow occurs here - | borrow used here, in later iteration of loop + | first borrow used here, in later iteration of loop LL | xs.push(1) //~ ERROR cannot borrow `xs` | ^^ second mutable borrow occurs here |
