From 656db98bd99caf7e5c5e81ad11ed8922e28c46fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 15 Jan 2023 03:06:44 +0000 Subject: [PATCH 1/5] Tweak E0597 CC #99430 --- .../rustc_borrowck/src/borrowck_errors.rs | 6 +- .../src/diagnostics/conflict_errors.rs | 2 +- .../src/diagnostics/explain_borrow.rs | 28 +++++ .../src/diagnostics/move_errors.rs | 2 +- .../src/traits/error_reporting/mod.rs | 2 +- tests/ui/asm/type-check-4.stderr | 6 +- .../associated-types-outlives.stderr | 3 + ...sue-74072-lifetime-name-annotations.stderr | 16 +-- .../issue-75785-confusing-named-region.stderr | 4 +- .../multiple-lifetimes/ret-ref.stderr | 12 +- tests/ui/augmented-assignments.rs | 2 +- tests/ui/augmented-assignments.stderr | 2 + tests/ui/binop/binop-move-semantics.stderr | 5 + .../borrowck-anon-fields-variant.stderr | 4 +- tests/ui/borrowck/borrowck-assign-comp.stderr | 12 +- ...ck-assign-to-andmut-in-borrowed-loc.stderr | 6 +- .../borrowck-closures-mut-and-imm.stderr | 16 +-- .../borrowck/borrowck-describe-lvalue.stderr | 42 +++---- ...m-ref-to-mut-rec-field-issue-3162-c.stderr | 4 +- tests/ui/borrowck/borrowck-issue-14498.stderr | 32 +++--- .../borrowck/borrowck-lend-flow-match.stderr | 4 +- .../borrowck-loan-blocks-move-cc.stderr | 4 + .../borrowck/borrowck-loan-blocks-move.stderr | 2 + ...wck-loan-of-static-data-issue-27616.stderr | 4 +- .../borrowck-loan-rcvr-overloaded-op.stderr | 2 +- .../borrowck-match-already-borrowed.stderr | 8 +- .../borrowck/borrowck-move-by-capture.stderr | 2 +- ...-move-from-subpath-of-borrowed-path.stderr | 2 + .../borrowck-move-subcomponent.stderr | 2 + .../borrowck-multiple-captures.stderr | 6 + ...erloaded-index-and-overloaded-deref.stderr | 4 +- ...borrowck-overloaded-index-autoderef.stderr | 16 +-- ...orrowck-overloaded-index-move-index.stderr | 4 + .../borrowck-pat-reassign-binding.stderr | 4 +- .../borrowck-union-borrow-nested.stderr | 2 +- .../ui/borrowck/borrowck-union-borrow.stderr | 20 ++-- .../borrowck/borrowck-use-mut-borrow.stderr | 18 +-- .../borrowck-vec-pattern-move-tail.stderr | 4 +- .../borrowck/borrowck-vec-pattern-nesting.rs | 8 +- .../borrowck-vec-pattern-nesting.stderr | 8 +- tests/ui/borrowck/issue-25793.stderr | 2 +- tests/ui/borrowck/issue-52713-bug.stderr | 4 +- ...issue-58776-borrowck-scans-children.stderr | 4 +- tests/ui/borrowck/issue-81365-1.stderr | 4 +- tests/ui/borrowck/issue-81365-10.stderr | 4 +- tests/ui/borrowck/issue-81365-11.stderr | 4 +- tests/ui/borrowck/issue-81365-2.stderr | 4 +- tests/ui/borrowck/issue-81365-3.stderr | 4 +- tests/ui/borrowck/issue-81365-4.stderr | 4 +- tests/ui/borrowck/issue-81365-5.stderr | 4 +- tests/ui/borrowck/issue-81365-6.stderr | 4 +- tests/ui/borrowck/issue-81365-7.stderr | 4 +- tests/ui/borrowck/issue-81365-8.stderr | 4 +- tests/ui/borrowck/issue-81365-9.stderr | 4 +- ...ccess-during-reservation.nll_target.stderr | 4 +- .../two-phase-surprise-no-conflict.stderr | 2 +- tests/ui/btreemap/btreemap_dropck.stderr | 2 + tests/ui/c-variadic/variadic-ffi-4.stderr | 4 +- .../diagnostics/arrays.stderr | 14 +-- .../diagnostics/box.stderr | 8 +- .../diagnostics/union.rs | 4 +- .../diagnostics/union.stderr | 4 +- .../coerce-overloaded-autoderef-fail.stderr | 4 +- tests/ui/consts/promote_const_let.stderr | 1 + .../dropck-eyepatch-extern-crate.stderr | 6 + .../ui/dropck/dropck-eyepatch-reorder.stderr | 6 + tests/ui/dropck/dropck-eyepatch.stderr | 6 + tests/ui/dropck/dropck-union.stderr | 2 + .../dropck/dropck_trait_cycle_checked.stderr | 12 +- tests/ui/dst/dst-bad-coerce3.stderr | 10 +- tests/ui/error-codes/E0503.stderr | 2 +- tests/ui/error-codes/E0504.stderr | 2 + tests/ui/error-codes/E0505.stderr | 3 + tests/ui/error-codes/E0506.stderr | 4 +- tests/ui/error-codes/E0597.stderr | 2 + ...ied-bounds-unnorm-associated-type-4.stderr | 2 + ...plied-bounds-unnorm-associated-type.stderr | 2 + .../issue-74684-1.stderr | 1 + .../hrtb-identity-fn-borrows.stderr | 4 +- .../feature-self-return-type.stderr | 3 + .../assoc-ty-wf-used-to-get-assoc-ty.stderr | 2 + .../const-expr-lifetime-err.stderr | 1 + tests/ui/issues/issue-40288.stderr | 4 +- tests/ui/issues/issue-45697-1.stderr | 6 +- tests/ui/issues/issue-45697.stderr | 6 +- tests/ui/issues/issue-46471-1.stderr | 7 +- ...600-expected-return-static-indirect.stderr | 2 + .../mut-pattern-internal-mutability.stderr | 4 +- tests/ui/nll/borrowed-local-error.stderr | 1 + .../ui/nll/borrowed-match-issue-45045.stderr | 2 +- tests/ui/nll/capture-ref-in-struct.stderr | 3 + tests/ui/nll/closure-access-spans.stderr | 4 +- tests/ui/nll/closure-borrow-spans.stderr | 14 +-- .../escape-argument.stderr | 3 + ...er-to-static-comparing-against-free.stderr | 2 + tests/ui/nll/closure-use-spans.stderr | 12 +- ...ignore-lifetime-bounds-in-copy-proj.stderr | 2 + ...-not-ignore-lifetime-bounds-in-copy.stderr | 2 + tests/ui/nll/dont-print-desugared.stderr | 1 + tests/ui/nll/drop-no-may-dangle.stderr | 8 +- tests/ui/nll/guarantor-issue-46974.stderr | 4 +- ...issue-27282-move-ref-mut-into-guard.stderr | 4 +- .../nll/issue-27282-mutation-in-guard.stderr | 4 +- tests/ui/nll/issue-27868.stderr | 4 +- tests/ui/nll/issue-46036.stderr | 2 + tests/ui/nll/issue-48803.stderr | 4 +- tests/ui/nll/issue-52534-2.stderr | 2 + tests/ui/nll/issue-52663-trait-object.stderr | 2 + ...sue-54382-use-span-of-tail-of-block.stderr | 3 + tests/ui/nll/issue-54556-stephaneyfx.stderr | 2 + ...ssue-54556-temps-in-tail-diagnostic.stderr | 3 + .../issue-54556-used-vs-unused-tails.stderr | 103 ++++++++++-------- tests/ui/nll/issue-54556-wrap-it-up.stderr | 4 +- tests/ui/nll/issue-55511.stderr | 2 + tests/ui/nll/issue-57989.stderr | 4 +- tests/ui/nll/issue-68550.stderr | 4 +- tests/ui/nll/issue-69114-static-mut-ty.stderr | 6 + tests/ui/nll/issue-69114-static-ty.stderr | 2 + tests/ui/nll/loan_ends_mid_block_pair.stderr | 4 +- .../nll/local-outlives-static-via-hrtb.stderr | 5 + tests/ui/nll/match-cfg-fake-edges2.stderr | 2 +- .../ui/nll/match-guards-always-borrow.stderr | 4 +- .../nll/match-guards-partially-borrow.stderr | 8 +- tests/ui/nll/match-on-borrowed.stderr | 6 +- ...ialized-drop-implicit-fragment-drop.stderr | 4 +- ...aybe-initialized-drop-with-fragment.stderr | 4 +- ...d-drop-with-uninitialized-fragments.stderr | 4 +- tests/ui/nll/maybe-initialized-drop.stderr | 4 +- .../nll/polonius/polonius-smoke-test.stderr | 2 +- tests/ui/nll/promoted-bounds.stderr | 1 + ...erence-carried-through-struct-field.stderr | 2 +- .../nll/relate_tys/var-appears-twice.stderr | 3 + .../user-annotations/adt-brace-enums.stderr | 3 + .../user-annotations/adt-brace-structs.stderr | 3 + .../user-annotations/adt-nullary-enums.stderr | 6 +- .../user-annotations/adt-tuple-enums.stderr | 3 + .../adt-tuple-struct-calls.stderr | 7 +- .../user-annotations/adt-tuple-struct.stderr | 3 + .../cast_static_lifetime.stderr | 2 + .../constant-in-expr-inherent-2.stderr | 11 ++ tests/ui/nll/user-annotations/fns.stderr | 3 + .../nll/user-annotations/method-call.stderr | 4 + .../nll/user-annotations/method-ufcs-1.stderr | 5 + .../nll/user-annotations/method-ufcs-2.stderr | 8 +- .../nll/user-annotations/method-ufcs-3.stderr | 4 + .../method-ufcs-inherent-1.stderr | 1 + .../method-ufcs-inherent-2.stderr | 2 + .../method-ufcs-inherent-3.stderr | 1 + .../method-ufcs-inherent-4.stderr | 2 + .../nll/user-annotations/normalization.stderr | 4 + ...attern_substs_on_brace_enum_variant.stderr | 4 + .../pattern_substs_on_brace_struct.stderr | 4 + ...attern_substs_on_tuple_enum_variant.stderr | 4 + .../pattern_substs_on_tuple_struct.stderr | 4 + tests/ui/nll/user-annotations/patterns.stderr | 24 ++++ .../promoted-annotation.stderr | 1 + .../type_ascription_static_lifetime.stderr | 2 + .../borrowck-move-ref-pattern.stderr | 2 + ...suggest-adding-bound-to-opaque-type.stderr | 2 + tests/ui/regions/regions-addr-of-arg.stderr | 2 + ...egions-free-region-ordering-caller1.stderr | 2 + .../regions-infer-proc-static-upvar.stderr | 2 + tests/ui/regions/regions-nested-fns.stderr | 2 + .../regions-pattern-typing-issue-19552.stderr | 2 + .../regions-pattern-typing-issue-19997.stderr | 4 +- .../borrowck-non-exhaustive.stderr | 2 +- .../lifetime-update.stderr | 3 + tests/ui/self/issue-61882-2.stderr | 2 + ...borrowck-call-is-borrow-issue-12224.stderr | 3 + tests/ui/span/dropck_arr_cycle_checked.stderr | 9 ++ .../span/dropck_direct_cycle_with_drop.stderr | 5 + tests/ui/span/dropck_misc_variants.stderr | 6 + tests/ui/span/dropck_vec_cycle_checked.stderr | 9 ++ ...5-dropck-child-has-items-via-parent.stderr | 3 + .../issue-24805-dropck-trait-has-items.stderr | 9 ++ .../span/issue-24895-copy-clone-dropck.stderr | 3 + tests/ui/span/issue-25199.stderr | 2 + tests/ui/span/issue-26656.stderr | 3 + tests/ui/span/issue-29106.stderr | 6 + tests/ui/span/issue-36537.stderr | 2 + tests/ui/span/issue-40157.stderr | 8 +- .../issue28498-reject-lifetime-param.stderr | 3 + .../issue28498-reject-passed-to-fn.stderr | 3 + .../span/issue28498-reject-trait-bound.stderr | 3 + tests/ui/span/mut-ptr-cant-outlive-ref.stderr | 2 + tests/ui/span/range-2.stderr | 8 +- .../regionck-unboxed-closure-lifetimes.stderr | 2 + ...regions-close-over-type-parameter-2.stderr | 2 + .../regions-escape-loop-via-variable.stderr | 4 +- .../span/regions-escape-loop-via-vec.stderr | 13 +-- .../send-is-not-static-ensures-scoping.stderr | 1 + .../span/send-is-not-static-std-sync-2.stderr | 6 +- .../span/send-is-not-static-std-sync.stderr | 6 + .../vec-must-not-hide-type-from-dropck.stderr | 6 + .../vec_refs_data_with_early_death.stderr | 6 + .../span/wf-method-late-bound-regions.stderr | 1 + tests/ui/static/static-lifetime-bound.stderr | 2 + .../suggestions/borrow-for-loop-head.stderr | 2 + .../suggestions/option-content-move2.stderr | 2 +- .../check-trait-object-bounds-3.stderr | 2 + .../ui/traits/coercion-generic-regions.stderr | 2 + tests/ui/traits/vtable/issue-97381.stderr | 3 + .../try-block/try-block-bad-lifetime.stderr | 9 +- .../try-block-maybe-bad-lifetime.stderr | 8 +- .../unboxed-closures-borrow-conflict.stderr | 2 +- ...oxed-closures-failed-recursive-fn-1.stderr | 8 +- tests/ui/unop-move-semantics.stderr | 5 + tests/ui/variance/variance-issue-20533.stderr | 6 + 208 files changed, 772 insertions(+), 349 deletions(-) diff --git a/compiler/rustc_borrowck/src/borrowck_errors.rs b/compiler/rustc_borrowck/src/borrowck_errors.rs index a4943d11204..2bbb9618dbf 100644 --- a/compiler/rustc_borrowck/src/borrowck_errors.rs +++ b/compiler/rustc_borrowck/src/borrowck_errors.rs @@ -37,7 +37,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { desc, ); - err.span_label(borrow_span, format!("borrow of {} occurs here", borrow_desc)); + err.span_label(borrow_span, format!("{} is borrowed here", borrow_desc)); err.span_label(span, format!("use of borrowed {}", borrow_desc)); err } @@ -250,8 +250,8 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { desc, ); - err.span_label(borrow_span, format!("borrow of {} occurs here", desc)); - err.span_label(span, format!("assignment to borrowed {} occurs here", desc)); + err.span_label(borrow_span, format!("{} is borrowed here", desc)); + err.span_label(span, format!("{} is assigned to here but it was already borrowed", desc)); err } diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index 968c1f49b95..0ab8aabd63b 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -1742,7 +1742,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { &self.local_names, &mut err, "", - None, + Some(borrow_span), None, ); } diff --git a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs index 2095747097b..e4f45c53aef 100644 --- a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs +++ b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs @@ -1,6 +1,8 @@ //! Print diagnostics to explain why values are borrowed. use rustc_errors::{Applicability, Diagnostic}; +use rustc_hir as hir; +use rustc_hir::intravisit::Visitor; use rustc_index::vec::IndexVec; use rustc_infer::infer::NllRegionVariableOrigin; use rustc_middle::mir::{ @@ -11,6 +13,7 @@ use rustc_middle::ty::adjustment::PointerCast; use rustc_middle::ty::{self, RegionVid, TyCtxt}; use rustc_span::symbol::{kw, Symbol}; use rustc_span::{sym, DesugaringKind, Span}; +use rustc_trait_selection::traits::error_reporting::FindExprBySpan; use crate::region_infer::{BlameConstraint, ExtraConstraintInfo}; use crate::{ @@ -63,6 +66,31 @@ impl<'tcx> BorrowExplanation<'tcx> { borrow_span: Option, multiple_borrow_span: Option<(Span, Span)>, ) { + if let Some(span) = borrow_span { + let def_id = body.source.def_id(); + if let Some(node) = tcx.hir().get_if_local(def_id) + && let Some(body_id) = node.body_id() + { + let body = tcx.hir().body(body_id); + let mut expr_finder = FindExprBySpan::new(span); + expr_finder.visit_expr(body.value); + if let Some(mut expr) = expr_finder.result { + while let hir::ExprKind::AddrOf(_, _, inner) = &expr.kind { + expr = inner; + } + if let hir::ExprKind::Path(hir::QPath::Resolved(None, p)) = expr.kind + && let [hir::PathSegment { ident, args: None, .. }] = p.segments + && let hir::def::Res::Local(hir_id) = p.res + && let Some(hir::Node::Pat(pat)) = tcx.hir().find(hir_id) + { + err.span_label( + pat.span, + &format!("binding `{ident}` declared here"), + ); + } + } + } + } match *self { BorrowExplanation::UsedLater(later_use_kind, var_or_use_span, path_span) => { let message = match later_use_kind { diff --git a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs index 6db3c858ae7..ea58ad5ae3e 100644 --- a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs @@ -448,7 +448,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { }; self.note_type_does_not_implement_copy(err, &place_desc, place_ty, Some(span), ""); - use_spans.args_span_label(err, format!("move out of {place_desc} occurs here")); + use_spans.args_span_label(err, format!("{place_desc} is moved here")); } } } diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index edd187b8dec..c3d097b5d75 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -2827,7 +2827,7 @@ pub struct FindExprBySpan<'hir> { } impl<'hir> FindExprBySpan<'hir> { - fn new(span: Span) -> Self { + pub fn new(span: Span) -> Self { Self { span, result: None, ty_result: None } } } diff --git a/tests/ui/asm/type-check-4.stderr b/tests/ui/asm/type-check-4.stderr index c97cd171b1e..b5ecb3e1b56 100644 --- a/tests/ui/asm/type-check-4.stderr +++ b/tests/ui/asm/type-check-4.stderr @@ -2,9 +2,9 @@ error[E0506]: cannot assign to `a` because it is borrowed --> $DIR/type-check-4.rs:14:9 | LL | let p = &a; - | -- borrow of `a` occurs here + | -- `a` is borrowed here LL | asm!("{}", out(reg) a); - | ^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `a` occurs here + | ^^^^^^^^^^^^^^^^^^^^^^ `a` is assigned to here but it was already borrowed LL | LL | println!("{}", p); | - borrow later used here @@ -13,7 +13,7 @@ error[E0503]: cannot use `a` because it was mutably borrowed --> $DIR/type-check-4.rs:22:28 | LL | let p = &mut a; - | ------ borrow of `a` occurs here + | ------ `a` is borrowed here LL | asm!("{}", in(reg) a); | ^ use of borrowed `a` LL | diff --git a/tests/ui/associated-types/associated-types-outlives.stderr b/tests/ui/associated-types/associated-types-outlives.stderr index 840e33b4b8a..2fe3f2d4a02 100644 --- a/tests/ui/associated-types/associated-types-outlives.stderr +++ b/tests/ui/associated-types/associated-types-outlives.stderr @@ -1,6 +1,9 @@ error[E0505]: cannot move out of `x` because it is borrowed --> $DIR/associated-types-outlives.rs:22:14 | +LL | F: for<'a> FnOnce(>::Bar)>(x: T, f: F) { + | - binding `x` declared here +... LL | 's: loop { y = denormalise(&x); break } | -- borrow of `x` occurs here LL | drop(x); diff --git a/tests/ui/async-await/issue-74072-lifetime-name-annotations.stderr b/tests/ui/async-await/issue-74072-lifetime-name-annotations.stderr index b96cab9f0f5..628ba1a4818 100644 --- a/tests/ui/async-await/issue-74072-lifetime-name-annotations.stderr +++ b/tests/ui/async-await/issue-74072-lifetime-name-annotations.stderr @@ -4,9 +4,9 @@ error[E0506]: cannot assign to `*x` because it is borrowed LL | pub async fn async_fn(x: &mut i32) -> &i32 { | - let's call the lifetime of this reference `'1` LL | let y = &*x; - | --- borrow of `*x` occurs here + | --- `*x` is borrowed here LL | *x += 1; - | ^^^^^^^ assignment to borrowed `*x` occurs here + | ^^^^^^^ `*x` is assigned to here but it was already borrowed LL | y | - returning this value requires that `*x` is borrowed for `'1` @@ -14,9 +14,9 @@ error[E0506]: cannot assign to `*x` because it is borrowed --> $DIR/issue-74072-lifetime-name-annotations.rs:16:9 | LL | let y = &*x; - | --- borrow of `*x` occurs here + | --- `*x` is borrowed here LL | *x += 1; - | ^^^^^^^ assignment to borrowed `*x` occurs here + | ^^^^^^^ `*x` is assigned to here but it was already borrowed LL | y | - returning this value requires that `*x` is borrowed for `'1` LL | })() @@ -28,9 +28,9 @@ error[E0506]: cannot assign to `*x` because it is borrowed LL | (async move || -> &i32 { | - let's call the lifetime of this reference `'1` LL | let y = &*x; - | --- borrow of `*x` occurs here + | --- `*x` is borrowed here LL | *x += 1; - | ^^^^^^^ assignment to borrowed `*x` occurs here + | ^^^^^^^ `*x` is assigned to here but it was already borrowed LL | y | - returning this value requires that `*x` is borrowed for `'1` @@ -38,9 +38,9 @@ error[E0506]: cannot assign to `*x` because it is borrowed --> $DIR/issue-74072-lifetime-name-annotations.rs:32:9 | LL | let y = &*x; - | --- borrow of `*x` occurs here + | --- `*x` is borrowed here LL | *x += 1; - | ^^^^^^^ assignment to borrowed `*x` occurs here + | ^^^^^^^ `*x` is assigned to here but it was already borrowed LL | y | - returning this value requires that `*x` is borrowed for `'1` LL | } diff --git a/tests/ui/async-await/issue-75785-confusing-named-region.stderr b/tests/ui/async-await/issue-75785-confusing-named-region.stderr index 3b731d9c60a..b69033a0eda 100644 --- a/tests/ui/async-await/issue-75785-confusing-named-region.stderr +++ b/tests/ui/async-await/issue-75785-confusing-named-region.stderr @@ -4,9 +4,9 @@ error[E0506]: cannot assign to `*x` because it is borrowed LL | pub async fn async_fn(x: &mut i32) -> (&i32, &i32) { | - let's call the lifetime of this reference `'1` LL | let y = &*x; - | --- borrow of `*x` occurs here + | --- `*x` is borrowed here LL | *x += 1; - | ^^^^^^^ assignment to borrowed `*x` occurs here + | ^^^^^^^ `*x` is assigned to here but it was already borrowed LL | (&32, y) | -------- returning this value requires that `*x` is borrowed for `'1` diff --git a/tests/ui/async-await/multiple-lifetimes/ret-ref.stderr b/tests/ui/async-await/multiple-lifetimes/ret-ref.stderr index d86e84033b8..a599ac1d92f 100644 --- a/tests/ui/async-await/multiple-lifetimes/ret-ref.stderr +++ b/tests/ui/async-await/multiple-lifetimes/ret-ref.stderr @@ -2,9 +2,9 @@ error[E0506]: cannot assign to `a` because it is borrowed --> $DIR/ret-ref.rs:16:5 | LL | let future = multiple_named_lifetimes(&a, &b); - | -- borrow of `a` occurs here + | -- `a` is borrowed here LL | a += 1; - | ^^^^^^ assignment to borrowed `a` occurs here + | ^^^^^^ `a` is assigned to here but it was already borrowed LL | b += 1; LL | let p = future.await; | ------ borrow later used here @@ -13,10 +13,10 @@ error[E0506]: cannot assign to `b` because it is borrowed --> $DIR/ret-ref.rs:17:5 | LL | let future = multiple_named_lifetimes(&a, &b); - | -- borrow of `b` occurs here + | -- `b` is borrowed here LL | a += 1; LL | b += 1; - | ^^^^^^ assignment to borrowed `b` occurs here + | ^^^^^^ `b` is assigned to here but it was already borrowed LL | let p = future.await; | ------ borrow later used here @@ -24,10 +24,10 @@ error[E0506]: cannot assign to `a` because it is borrowed --> $DIR/ret-ref.rs:28:5 | LL | let future = multiple_named_lifetimes(&a, &b); - | -- borrow of `a` occurs here + | -- `a` is borrowed here LL | let p = future.await; LL | a += 1; - | ^^^^^^ assignment to borrowed `a` occurs here + | ^^^^^^ `a` is assigned to here but it was already borrowed LL | b += 1; LL | drop(p); | - borrow later used here diff --git a/tests/ui/augmented-assignments.rs b/tests/ui/augmented-assignments.rs index 20c7fb3a983..bd2435a78bf 100644 --- a/tests/ui/augmented-assignments.rs +++ b/tests/ui/augmented-assignments.rs @@ -9,7 +9,7 @@ impl AddAssign for Int { } fn main() { - let mut x = Int(1); + let mut x = Int(1); //~ NOTE binding `x` declared here x //~^ NOTE borrow of `x` occurs here += diff --git a/tests/ui/augmented-assignments.stderr b/tests/ui/augmented-assignments.stderr index 2910c910d55..d1096aea279 100644 --- a/tests/ui/augmented-assignments.stderr +++ b/tests/ui/augmented-assignments.stderr @@ -1,6 +1,8 @@ error[E0505]: cannot move out of `x` because it is borrowed --> $DIR/augmented-assignments.rs:16:5 | +LL | let mut x = Int(1); + | ----- binding `x` declared here LL | x | - borrow of `x` occurs here ... diff --git a/tests/ui/binop/binop-move-semantics.stderr b/tests/ui/binop/binop-move-semantics.stderr index dae267da05d..8645169b98a 100644 --- a/tests/ui/binop/binop-move-semantics.stderr +++ b/tests/ui/binop/binop-move-semantics.stderr @@ -41,6 +41,8 @@ LL | fn move_then_borrow + Clone + Copy>(x: T) { error[E0505]: cannot move out of `x` because it is borrowed --> $DIR/binop-move-semantics.rs:21:5 | +LL | fn move_borrowed>(x: T, mut y: T) { + | - binding `x` declared here LL | let m = &x; | -- borrow of `x` occurs here ... @@ -53,6 +55,9 @@ LL | use_mut(n); use_imm(m); error[E0505]: cannot move out of `y` because it is borrowed --> $DIR/binop-move-semantics.rs:23:5 | +LL | fn move_borrowed>(x: T, mut y: T) { + | ----- binding `y` declared here +LL | let m = &x; LL | let n = &mut y; | ------ borrow of `y` occurs here ... diff --git a/tests/ui/borrowck/borrowck-anon-fields-variant.stderr b/tests/ui/borrowck/borrowck-anon-fields-variant.stderr index 98f6f00a7d4..c1d668f74ef 100644 --- a/tests/ui/borrowck/borrowck-anon-fields-variant.stderr +++ b/tests/ui/borrowck/borrowck-anon-fields-variant.stderr @@ -2,7 +2,7 @@ error[E0503]: cannot use `y` because it was mutably borrowed --> $DIR/borrowck-anon-fields-variant.rs:16:19 | LL | Foo::Y(ref mut a, _) => a, - | --------- borrow of `y.0` occurs here + | --------- `y.0` is borrowed here ... LL | let b = match y { | ^ use of borrowed `y.0` @@ -14,7 +14,7 @@ error[E0503]: cannot use `y` because it was mutably borrowed --> $DIR/borrowck-anon-fields-variant.rs:34:19 | LL | Foo::Y(ref mut a, _) => a, - | --------- borrow of `y.0` occurs here + | --------- `y.0` is borrowed here ... LL | let b = match y { | ^ use of borrowed `y.0` diff --git a/tests/ui/borrowck/borrowck-assign-comp.stderr b/tests/ui/borrowck/borrowck-assign-comp.stderr index 2b7cef7b325..d35f2331a76 100644 --- a/tests/ui/borrowck/borrowck-assign-comp.stderr +++ b/tests/ui/borrowck/borrowck-assign-comp.stderr @@ -2,10 +2,10 @@ error[E0506]: cannot assign to `p.x` because it is borrowed --> $DIR/borrowck-assign-comp.rs:10:5 | LL | let q = &p; - | -- borrow of `p.x` occurs here + | -- `p.x` is borrowed here ... LL | p.x = 5; - | ^^^^^^^ assignment to borrowed `p.x` occurs here + | ^^^^^^^ `p.x` is assigned to here but it was already borrowed LL | q.x; | --- borrow later used here @@ -13,9 +13,9 @@ error[E0506]: cannot assign to `p` because it is borrowed --> $DIR/borrowck-assign-comp.rs:20:5 | LL | let q = &p.y; - | ---- borrow of `p` occurs here + | ---- `p` is borrowed here LL | p = Point {x: 5, y: 7}; - | ^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `p` occurs here + | ^^^^^^^^^^^^^^^^^^^^^^ `p` is assigned to here but it was already borrowed LL | p.x; // silence warning LL | *q; // stretch loan | -- borrow later used here @@ -24,9 +24,9 @@ error[E0506]: cannot assign to `p.y` because it is borrowed --> $DIR/borrowck-assign-comp.rs:31:5 | LL | let q = &p.y; - | ---- borrow of `p.y` occurs here + | ---- `p.y` is borrowed here LL | p.y = 5; - | ^^^^^^^ assignment to borrowed `p.y` occurs here + | ^^^^^^^ `p.y` is assigned to here but it was already borrowed LL | *q; | -- borrow later used here diff --git a/tests/ui/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.stderr b/tests/ui/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.stderr index 0b21d113f74..8c0a8efcc18 100644 --- a/tests/ui/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.stderr +++ b/tests/ui/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.stderr @@ -2,7 +2,7 @@ error[E0503]: cannot use `*y.pointer` because it was mutably borrowed --> $DIR/borrowck-assign-to-andmut-in-borrowed-loc.rs:18:9 | LL | let z = copy_borrowed_ptr(&mut y); - | ------ borrow of `y` occurs here + | ------ `y` is borrowed here LL | *y.pointer += 1; | ^^^^^^^^^^^^^^^ use of borrowed `y` ... @@ -13,9 +13,9 @@ error[E0506]: cannot assign to `*y.pointer` because it is borrowed --> $DIR/borrowck-assign-to-andmut-in-borrowed-loc.rs:18:9 | LL | let z = copy_borrowed_ptr(&mut y); - | ------ borrow of `*y.pointer` occurs here + | ------ `*y.pointer` is borrowed here LL | *y.pointer += 1; - | ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here + | ^^^^^^^^^^^^^^^ `*y.pointer` is assigned to here but it was already borrowed ... LL | *z.pointer += 1; | --------------- borrow later used here diff --git a/tests/ui/borrowck/borrowck-closures-mut-and-imm.stderr b/tests/ui/borrowck/borrowck-closures-mut-and-imm.stderr index fadcd11a592..8a7870e0c44 100644 --- a/tests/ui/borrowck/borrowck-closures-mut-and-imm.stderr +++ b/tests/ui/borrowck/borrowck-closures-mut-and-imm.stderr @@ -49,9 +49,9 @@ error[E0506]: cannot assign to `x` because it is borrowed LL | let c2 = || x * 5; | -- - borrow occurs due to use in closure | | - | borrow of `x` occurs here + | `x` is borrowed here LL | x = 5; - | ^^^^^ assignment to borrowed `x` occurs here + | ^^^^^ `x` is assigned to here but it was already borrowed LL | LL | drop(c2); | -- borrow later used here @@ -62,9 +62,9 @@ error[E0506]: cannot assign to `x` because it is borrowed LL | let c1 = || get(&x); | -- - borrow occurs due to use in closure | | - | borrow of `x` occurs here + | `x` is borrowed here LL | x = 5; - | ^^^^^ assignment to borrowed `x` occurs here + | ^^^^^ `x` is assigned to here but it was already borrowed LL | LL | drop(c1); | -- borrow later used here @@ -75,9 +75,9 @@ error[E0506]: cannot assign to `*x` because it is borrowed LL | let c1 = || get(&*x); | -- -- borrow occurs due to use in closure | | - | borrow of `*x` occurs here + | `*x` is borrowed here LL | *x = 5; - | ^^^^^^ assignment to borrowed `*x` occurs here + | ^^^^^^ `*x` is assigned to here but it was already borrowed LL | LL | drop(c1); | -- borrow later used here @@ -88,9 +88,9 @@ error[E0506]: cannot assign to `*x.f` because it is borrowed LL | let c1 = || get(&*x.f); | -- ---- borrow occurs due to use in closure | | - | borrow of `*x.f` occurs here + | `*x.f` is borrowed here LL | *x.f = 5; - | ^^^^^^^^ assignment to borrowed `*x.f` occurs here + | ^^^^^^^^ `*x.f` is assigned to here but it was already borrowed LL | LL | drop(c1); | -- borrow later used here diff --git a/tests/ui/borrowck/borrowck-describe-lvalue.stderr b/tests/ui/borrowck/borrowck-describe-lvalue.stderr index 2c1b9c10d46..cb29c9fdac3 100644 --- a/tests/ui/borrowck/borrowck-describe-lvalue.stderr +++ b/tests/ui/borrowck/borrowck-describe-lvalue.stderr @@ -45,7 +45,7 @@ error[E0503]: cannot use `f.x` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:37:9 | LL | let x = f.x(); - | ----- borrow of `f` occurs here + | ----- `f` is borrowed here LL | f.x; | ^^^ use of borrowed `f` LL | drop(x); @@ -55,7 +55,7 @@ error[E0503]: cannot use `g.0` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:44:9 | LL | let x = g.x(); - | ----- borrow of `g` occurs here + | ----- `g` is borrowed here LL | g.0; | ^^^ use of borrowed `g` LL | drop(x); @@ -65,7 +65,7 @@ error[E0503]: cannot use `h.0` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:51:9 | LL | let x = &mut h.0; - | -------- borrow of `h.0` occurs here + | -------- `h.0` is borrowed here LL | h.0; | ^^^ use of borrowed `h.0` LL | drop(x); @@ -75,7 +75,7 @@ error[E0503]: cannot use `e.0` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:59:20 | LL | let x = e.x(); - | ----- borrow of `e` occurs here + | ----- `e` is borrowed here LL | match e { LL | Baz::X(value) => value | ^^^^^ use of borrowed `e` @@ -87,7 +87,7 @@ error[E0503]: cannot use `u.a` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:67:9 | LL | let x = &mut u.a; - | -------- borrow of `u.a` occurs here + | -------- `u.a` is borrowed here LL | u.a; | ^^^ use of borrowed `u.a` LL | drop(x); @@ -97,7 +97,7 @@ error[E0503]: cannot use `f.x` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:74:9 | LL | let x = f.x(); - | ----- borrow of `*f` occurs here + | ----- `*f` is borrowed here LL | f.x; | ^^^ use of borrowed `*f` LL | drop(x); @@ -107,7 +107,7 @@ error[E0503]: cannot use `g.0` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:81:9 | LL | let x = g.x(); - | ----- borrow of `*g` occurs here + | ----- `*g` is borrowed here LL | g.0; | ^^^ use of borrowed `*g` LL | drop(x); @@ -117,7 +117,7 @@ error[E0503]: cannot use `h.0` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:88:9 | LL | let x = &mut h.0; - | -------- borrow of `h.0` occurs here + | -------- `h.0` is borrowed here LL | h.0; | ^^^ use of borrowed `h.0` LL | drop(x); @@ -127,7 +127,7 @@ error[E0503]: cannot use `e.0` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:96:20 | LL | let x = e.x(); - | ----- borrow of `*e` occurs here + | ----- `*e` is borrowed here LL | match *e { LL | Baz::X(value) => value | ^^^^^ use of borrowed `*e` @@ -139,7 +139,7 @@ error[E0503]: cannot use `u.a` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:105:9 | LL | let x = &mut u.a; - | -------- borrow of `u.a` occurs here + | -------- `u.a` is borrowed here LL | u.a; | ^^^ use of borrowed `u.a` LL | drop(x); @@ -149,7 +149,7 @@ error[E0503]: cannot use `v[..]` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:113:15 | LL | let x = &mut v; - | ------ borrow of `v` occurs here + | ------ `v` is borrowed here LL | match v { LL | &[x, _, .., _, _] => println!("{}", x), | ^ use of borrowed `v` @@ -161,7 +161,7 @@ error[E0503]: cannot use `v[..]` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:118:18 | LL | let x = &mut v; - | ------ borrow of `v` occurs here + | ------ `v` is borrowed here ... LL | &[_, x, .., _, _] => println!("{}", x), | ^ use of borrowed `v` @@ -173,7 +173,7 @@ error[E0503]: cannot use `v[..]` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:123:25 | LL | let x = &mut v; - | ------ borrow of `v` occurs here + | ------ `v` is borrowed here ... LL | &[_, _, .., x, _] => println!("{}", x), | ^ use of borrowed `v` @@ -185,7 +185,7 @@ error[E0503]: cannot use `v[..]` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:128:28 | LL | let x = &mut v; - | ------ borrow of `v` occurs here + | ------ `v` is borrowed here ... LL | &[_, _, .., _, x] => println!("{}", x), | ^ use of borrowed `v` @@ -197,7 +197,7 @@ error[E0503]: cannot use `v[..]` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:139:15 | LL | let x = &mut v; - | ------ borrow of `v` occurs here + | ------ `v` is borrowed here LL | match v { LL | &[x @ ..] => println!("{:?}", x), | ^ use of borrowed `v` @@ -209,7 +209,7 @@ error[E0503]: cannot use `v[..]` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:144:18 | LL | let x = &mut v; - | ------ borrow of `v` occurs here + | ------ `v` is borrowed here ... LL | &[_, x @ ..] => println!("{:?}", x), | ^ use of borrowed `v` @@ -221,7 +221,7 @@ error[E0503]: cannot use `v[..]` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:149:15 | LL | let x = &mut v; - | ------ borrow of `v` occurs here + | ------ `v` is borrowed here ... LL | &[x @ .., _] => println!("{:?}", x), | ^ use of borrowed `v` @@ -233,7 +233,7 @@ error[E0503]: cannot use `v[..]` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:154:18 | LL | let x = &mut v; - | ------ borrow of `v` occurs here + | ------ `v` is borrowed here ... LL | &[_, x @ .., _] => println!("{:?}", x), | ^ use of borrowed `v` @@ -245,7 +245,7 @@ error[E0503]: cannot use `e` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:166:15 | LL | let x = &mut e; - | ------ borrow of `e` occurs here + | ------ `e` is borrowed here LL | match e { | ^ use of borrowed `e` ... @@ -304,7 +304,7 @@ error[E0503]: cannot use `*v` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:232:9 | LL | let x = &mut v; - | ------ borrow of `v` occurs here + | ------ `v` is borrowed here LL | v[0].y; | ^^^^ use of borrowed `v` ... @@ -315,7 +315,7 @@ error[E0503]: cannot use `v[_].y` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:232:9 | LL | let x = &mut v; - | ------ borrow of `v` occurs here + | ------ `v` is borrowed here LL | v[0].y; | ^^^^^^ use of borrowed `v` ... diff --git a/tests/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.stderr b/tests/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.stderr index a66db05ccc5..1a20ec85fc0 100644 --- a/tests/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.stderr +++ b/tests/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.stderr @@ -2,10 +2,10 @@ error[E0506]: cannot assign to `_a` because it is borrowed --> $DIR/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs:6:9 | LL | let b = &mut _a; - | ------- borrow of `_a` occurs here + | ------- `_a` is borrowed here ... LL | _a = 4; - | ^^^^^^ assignment to borrowed `_a` occurs here + | ^^^^^^ `_a` is assigned to here but it was already borrowed ... LL | drop(b); | - borrow later used here diff --git a/tests/ui/borrowck/borrowck-issue-14498.stderr b/tests/ui/borrowck/borrowck-issue-14498.stderr index 42a55b7a854..374c5ee3ed2 100644 --- a/tests/ui/borrowck/borrowck-issue-14498.stderr +++ b/tests/ui/borrowck/borrowck-issue-14498.stderr @@ -13,10 +13,10 @@ error[E0506]: cannot assign to `**y` because it is borrowed --> $DIR/borrowck-issue-14498.rs:25:5 | LL | let p = &y; - | -- borrow of `**y` occurs here + | -- `**y` is borrowed here LL | let q = &***p; LL | **y = 2; - | ^^^^^^^ assignment to borrowed `**y` occurs here + | ^^^^^^^ `**y` is assigned to here but it was already borrowed LL | drop(p); | - borrow later used here @@ -24,10 +24,10 @@ error[E0506]: cannot assign to `**y` because it is borrowed --> $DIR/borrowck-issue-14498.rs:35:5 | LL | let p = &y; - | -- borrow of `**y` occurs here + | -- `**y` is borrowed here LL | let q = &***p; LL | **y = 2; - | ^^^^^^^ assignment to borrowed `**y` occurs here + | ^^^^^^^ `**y` is assigned to here but it was already borrowed LL | drop(p); | - borrow later used here @@ -35,10 +35,10 @@ error[E0506]: cannot assign to `**y` because it is borrowed --> $DIR/borrowck-issue-14498.rs:45:5 | LL | let p = &y; - | -- borrow of `**y` occurs here + | -- `**y` is borrowed here LL | let q = &***p; LL | **y = 2; - | ^^^^^^^ assignment to borrowed `**y` occurs here + | ^^^^^^^ `**y` is assigned to here but it was already borrowed LL | drop(p); | - borrow later used here @@ -46,10 +46,10 @@ error[E0506]: cannot assign to `**y` because it is borrowed --> $DIR/borrowck-issue-14498.rs:55:5 | LL | let p = &y; - | -- borrow of `**y` occurs here + | -- `**y` is borrowed here LL | let q = &***p; LL | **y = 2; - | ^^^^^^^ assignment to borrowed `**y` occurs here + | ^^^^^^^ `**y` is assigned to here but it was already borrowed LL | drop(p); | - borrow later used here @@ -57,10 +57,10 @@ error[E0506]: cannot assign to `**y.a` because it is borrowed --> $DIR/borrowck-issue-14498.rs:65:5 | LL | let p = &y.a; - | ---- borrow of `**y.a` occurs here + | ---- `**y.a` is borrowed here LL | let q = &***p; LL | **y.a = 2; - | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here + | ^^^^^^^^^ `**y.a` is assigned to here but it was already borrowed LL | drop(p); | - borrow later used here @@ -68,10 +68,10 @@ error[E0506]: cannot assign to `**y.a` because it is borrowed --> $DIR/borrowck-issue-14498.rs:75:5 | LL | let p = &y.a; - | ---- borrow of `**y.a` occurs here + | ---- `**y.a` is borrowed here LL | let q = &***p; LL | **y.a = 2; - | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here + | ^^^^^^^^^ `**y.a` is assigned to here but it was already borrowed LL | drop(p); | - borrow later used here @@ -79,10 +79,10 @@ error[E0506]: cannot assign to `**y.a` because it is borrowed --> $DIR/borrowck-issue-14498.rs:85:5 | LL | let p = &y.a; - | ---- borrow of `**y.a` occurs here + | ---- `**y.a` is borrowed here LL | let q = &***p; LL | **y.a = 2; - | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here + | ^^^^^^^^^ `**y.a` is assigned to here but it was already borrowed LL | drop(p); | - borrow later used here @@ -90,10 +90,10 @@ error[E0506]: cannot assign to `**y.a` because it is borrowed --> $DIR/borrowck-issue-14498.rs:95:5 | LL | let p = &y.a; - | ---- borrow of `**y.a` occurs here + | ---- `**y.a` is borrowed here LL | let q = &***p; LL | **y.a = 2; - | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here + | ^^^^^^^^^ `**y.a` is assigned to here but it was already borrowed LL | drop(p); | - borrow later used here diff --git a/tests/ui/borrowck/borrowck-lend-flow-match.stderr b/tests/ui/borrowck/borrowck-lend-flow-match.stderr index 66f1cd9bd56..6cdce7bee88 100644 --- a/tests/ui/borrowck/borrowck-lend-flow-match.stderr +++ b/tests/ui/borrowck/borrowck-lend-flow-match.stderr @@ -2,9 +2,9 @@ error[E0506]: cannot assign to `x` because it is borrowed --> $DIR/borrowck-lend-flow-match.rs:12:13 | LL | Some(ref r) => { - | ----- borrow of `x` occurs here + | ----- `x` is borrowed here LL | x = Some(1); - | ^^^^^^^^^^^ assignment to borrowed `x` occurs here + | ^^^^^^^^^^^ `x` is assigned to here but it was already borrowed LL | drop(r); | - borrow later used here diff --git a/tests/ui/borrowck/borrowck-loan-blocks-move-cc.stderr b/tests/ui/borrowck/borrowck-loan-blocks-move-cc.stderr index 3548da35b61..6eabfff9054 100644 --- a/tests/ui/borrowck/borrowck-loan-blocks-move-cc.stderr +++ b/tests/ui/borrowck/borrowck-loan-blocks-move-cc.stderr @@ -1,6 +1,8 @@ error[E0505]: cannot move out of `v` because it is borrowed --> $DIR/borrowck-loan-blocks-move-cc.rs:14:19 | +LL | let v: Box<_> = Box::new(3); + | - binding `v` declared here LL | let w = &v; | -- borrow of `v` occurs here LL | thread::spawn(move|| { @@ -15,6 +17,8 @@ LL | w.use_ref(); error[E0505]: cannot move out of `v` because it is borrowed --> $DIR/borrowck-loan-blocks-move-cc.rs:24:19 | +LL | let v: Box<_> = Box::new(3); + | - binding `v` declared here LL | let w = &v; | -- borrow of `v` occurs here LL | thread::spawn(move|| { diff --git a/tests/ui/borrowck/borrowck-loan-blocks-move.stderr b/tests/ui/borrowck/borrowck-loan-blocks-move.stderr index b5c6b101f76..38e06fa0187 100644 --- a/tests/ui/borrowck/borrowck-loan-blocks-move.stderr +++ b/tests/ui/borrowck/borrowck-loan-blocks-move.stderr @@ -1,6 +1,8 @@ error[E0505]: cannot move out of `v` because it is borrowed --> $DIR/borrowck-loan-blocks-move.rs:11:10 | +LL | let v = Box::new(3); + | - binding `v` declared here LL | let w = &v; | -- borrow of `v` occurs here LL | take(v); diff --git a/tests/ui/borrowck/borrowck-loan-of-static-data-issue-27616.stderr b/tests/ui/borrowck/borrowck-loan-of-static-data-issue-27616.stderr index 6994c837dfc..311369a260d 100644 --- a/tests/ui/borrowck/borrowck-loan-of-static-data-issue-27616.stderr +++ b/tests/ui/borrowck/borrowck-loan-of-static-data-issue-27616.stderr @@ -2,12 +2,12 @@ error[E0506]: cannot assign to `*s` because it is borrowed --> $DIR/borrowck-loan-of-static-data-issue-27616.rs:16:5 | LL | let alias: &'static mut String = s; - | ------------------- - borrow of `*s` occurs here + | ------------------- - `*s` is borrowed here | | | type annotation requires that `*s` is borrowed for `'static` ... LL | *s = String::new(); - | ^^ assignment to borrowed `*s` occurs here + | ^^ `*s` is assigned to here but it was already borrowed error: aborting due to previous error diff --git a/tests/ui/borrowck/borrowck-loan-rcvr-overloaded-op.stderr b/tests/ui/borrowck/borrowck-loan-rcvr-overloaded-op.stderr index 24cc4933ef1..f1640d3b777 100644 --- a/tests/ui/borrowck/borrowck-loan-rcvr-overloaded-op.stderr +++ b/tests/ui/borrowck/borrowck-loan-rcvr-overloaded-op.stderr @@ -2,7 +2,7 @@ error[E0503]: cannot use `p` because it was mutably borrowed --> $DIR/borrowck-loan-rcvr-overloaded-op.rs:38:5 | LL | let q = &mut p; - | ------ borrow of `p` occurs here + | ------ `p` is borrowed here LL | LL | p + 3; | ^ use of borrowed `p` diff --git a/tests/ui/borrowck/borrowck-match-already-borrowed.stderr b/tests/ui/borrowck/borrowck-match-already-borrowed.stderr index 39047be9de6..e5c0ec960a4 100644 --- a/tests/ui/borrowck/borrowck-match-already-borrowed.stderr +++ b/tests/ui/borrowck/borrowck-match-already-borrowed.stderr @@ -2,7 +2,7 @@ error[E0503]: cannot use `foo` because it was mutably borrowed --> $DIR/borrowck-match-already-borrowed.rs:9:19 | LL | let p = &mut foo; - | -------- borrow of `foo` occurs here + | -------- `foo` is borrowed here LL | let _ = match foo { | ^^^ use of borrowed `foo` ... @@ -13,7 +13,7 @@ error[E0503]: cannot use `foo.0` because it was mutably borrowed --> $DIR/borrowck-match-already-borrowed.rs:12:16 | LL | let p = &mut foo; - | -------- borrow of `foo` occurs here + | -------- `foo` is borrowed here ... LL | Foo::A(x) => x | ^ use of borrowed `foo` @@ -25,7 +25,7 @@ error[E0503]: cannot use `x` because it was mutably borrowed --> $DIR/borrowck-match-already-borrowed.rs:22:9 | LL | let r = &mut x; - | ------ borrow of `x` occurs here + | ------ `x` is borrowed here LL | let _ = match x { LL | x => x + 1, | ^ use of borrowed `x` @@ -37,7 +37,7 @@ error[E0503]: cannot use `x` because it was mutably borrowed --> $DIR/borrowck-match-already-borrowed.rs:23:9 | LL | let r = &mut x; - | ------ borrow of `x` occurs here + | ------ `x` is borrowed here ... LL | y => y + 2, | ^ use of borrowed `x` diff --git a/tests/ui/borrowck/borrowck-move-by-capture.stderr b/tests/ui/borrowck/borrowck-move-by-capture.stderr index 8ddc48b2a99..6eaa1fa3169 100644 --- a/tests/ui/borrowck/borrowck-move-by-capture.stderr +++ b/tests/ui/borrowck/borrowck-move-by-capture.stderr @@ -10,7 +10,7 @@ LL | let _h = to_fn_once(move || -> isize { *bar }); | | | | | variable moved due to use in closure | | move occurs because `bar` has type `Box`, which does not implement the `Copy` trait - | move out of `bar` occurs here + | `bar` is moved here error: aborting due to previous error diff --git a/tests/ui/borrowck/borrowck-move-from-subpath-of-borrowed-path.stderr b/tests/ui/borrowck/borrowck-move-from-subpath-of-borrowed-path.stderr index f833abcc02a..bd94f1a4299 100644 --- a/tests/ui/borrowck/borrowck-move-from-subpath-of-borrowed-path.stderr +++ b/tests/ui/borrowck/borrowck-move-from-subpath-of-borrowed-path.stderr @@ -1,6 +1,8 @@ error[E0505]: cannot move out of `*a` because it is borrowed --> $DIR/borrowck-move-from-subpath-of-borrowed-path.rs:12:13 | +LL | let a: Box> = Box::new(Box::new(2)); + | - binding `a` declared here LL | let b = &a; | -- borrow of `a` occurs here LL | diff --git a/tests/ui/borrowck/borrowck-move-subcomponent.stderr b/tests/ui/borrowck/borrowck-move-subcomponent.stderr index 8c9083fcf13..341146bd18f 100644 --- a/tests/ui/borrowck/borrowck-move-subcomponent.stderr +++ b/tests/ui/borrowck/borrowck-move-subcomponent.stderr @@ -1,6 +1,8 @@ error[E0505]: cannot move out of `a.x` because it is borrowed --> $DIR/borrowck-move-subcomponent.rs:15:14 | +LL | let a : S = S { x : Box::new(1) }; + | - binding `a` declared here LL | let pb = &a; | -- borrow of `a` occurs here LL | let S { x: ax } = a; diff --git a/tests/ui/borrowck/borrowck-multiple-captures.stderr b/tests/ui/borrowck/borrowck-multiple-captures.stderr index f94cbc30db4..70abe7b346e 100644 --- a/tests/ui/borrowck/borrowck-multiple-captures.stderr +++ b/tests/ui/borrowck/borrowck-multiple-captures.stderr @@ -1,6 +1,8 @@ error[E0505]: cannot move out of `x1` because it is borrowed --> $DIR/borrowck-multiple-captures.rs:12:19 | +LL | let x1: Box<_> = Box::new(1); + | -- binding `x1` declared here LL | let p1 = &x1; | --- borrow of `x1` occurs here ... @@ -16,6 +18,8 @@ LL | borrow(&*p1); error[E0505]: cannot move out of `x2` because it is borrowed --> $DIR/borrowck-multiple-captures.rs:12:19 | +LL | let x2: Box<_> = Box::new(2); + | -- binding `x2` declared here LL | let p2 = &x2; | --- borrow of `x2` occurs here LL | thread::spawn(move|| { @@ -77,6 +81,8 @@ LL | drop(x); error[E0505]: cannot move out of `x` because it is borrowed --> $DIR/borrowck-multiple-captures.rs:38:19 | +LL | let x: Box<_> = Box::new(1); + | - binding `x` declared here LL | let p = &x; | -- borrow of `x` occurs here LL | thread::spawn(move|| { diff --git a/tests/ui/borrowck/borrowck-overloaded-index-and-overloaded-deref.stderr b/tests/ui/borrowck/borrowck-overloaded-index-and-overloaded-deref.stderr index 5d52e491918..7f42becd21c 100644 --- a/tests/ui/borrowck/borrowck-overloaded-index-and-overloaded-deref.stderr +++ b/tests/ui/borrowck/borrowck-overloaded-index-and-overloaded-deref.stderr @@ -2,9 +2,9 @@ error[E0506]: cannot assign to `v` because it is borrowed --> $DIR/borrowck-overloaded-index-and-overloaded-deref.rs:31:5 | LL | let i = &v[0].f; - | - borrow of `v` occurs here + | - `v` is borrowed here LL | v = MyVec { x: MyPtr { x: Foo { f: 23 } } }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `v` occurs here + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `v` is assigned to here but it was already borrowed LL | LL | read(*i); | -- borrow later used here diff --git a/tests/ui/borrowck/borrowck-overloaded-index-autoderef.stderr b/tests/ui/borrowck/borrowck-overloaded-index-autoderef.stderr index 087f2ac799e..fb7af50bcb5 100644 --- a/tests/ui/borrowck/borrowck-overloaded-index-autoderef.stderr +++ b/tests/ui/borrowck/borrowck-overloaded-index-autoderef.stderr @@ -42,9 +42,9 @@ error[E0506]: cannot assign to `f.foo` because it is borrowed --> $DIR/borrowck-overloaded-index-autoderef.rs:71:5 | LL | let p = &f.foo[&s]; - | ----- borrow of `f.foo` occurs here + | ----- `f.foo` is borrowed here LL | f.foo = g; - | ^^^^^^^^^ assignment to borrowed `f.foo` occurs here + | ^^^^^^^^^ `f.foo` is assigned to here but it was already borrowed LL | p.use_ref(); | ----------- borrow later used here @@ -52,9 +52,9 @@ error[E0506]: cannot assign to `*f` because it is borrowed --> $DIR/borrowck-overloaded-index-autoderef.rs:77:5 | LL | let p = &f.foo[&s]; - | ----- borrow of `*f` occurs here + | ----- `*f` is borrowed here LL | *f = g; - | ^^^^^^ assignment to borrowed `*f` occurs here + | ^^^^^^ `*f` is assigned to here but it was already borrowed LL | p.use_ref(); | ----------- borrow later used here @@ -62,9 +62,9 @@ error[E0506]: cannot assign to `f.foo` because it is borrowed --> $DIR/borrowck-overloaded-index-autoderef.rs:83:5 | LL | let p = &mut f.foo[&s]; - | ----- borrow of `f.foo` occurs here + | ----- `f.foo` is borrowed here LL | f.foo = g; - | ^^^^^^^^^ assignment to borrowed `f.foo` occurs here + | ^^^^^^^^^ `f.foo` is assigned to here but it was already borrowed LL | p.use_mut(); | ----------- borrow later used here @@ -72,9 +72,9 @@ error[E0506]: cannot assign to `*f` because it is borrowed --> $DIR/borrowck-overloaded-index-autoderef.rs:89:5 | LL | let p = &mut f.foo[&s]; - | ----- borrow of `*f` occurs here + | ----- `*f` is borrowed here LL | *f = g; - | ^^^^^^ assignment to borrowed `*f` occurs here + | ^^^^^^ `*f` is assigned to here but it was already borrowed LL | p.use_mut(); | ----------- borrow later used here diff --git a/tests/ui/borrowck/borrowck-overloaded-index-move-index.stderr b/tests/ui/borrowck/borrowck-overloaded-index-move-index.stderr index fb0e274c291..7f8cc74a715 100644 --- a/tests/ui/borrowck/borrowck-overloaded-index-move-index.stderr +++ b/tests/ui/borrowck/borrowck-overloaded-index-move-index.stderr @@ -1,6 +1,8 @@ error[E0505]: cannot move out of `s` because it is borrowed --> $DIR/borrowck-overloaded-index-move-index.rs:50:22 | +LL | let mut s = "hello".to_string(); + | ----- binding `s` declared here LL | let rs = &mut s; | ------ borrow of `s` occurs here LL | @@ -13,6 +15,8 @@ LL | use_mut(rs); error[E0505]: cannot move out of `s` because it is borrowed --> $DIR/borrowck-overloaded-index-move-index.rs:53:7 | +LL | let mut s = "hello".to_string(); + | ----- binding `s` declared here LL | let rs = &mut s; | ------ borrow of `s` occurs here ... diff --git a/tests/ui/borrowck/borrowck-pat-reassign-binding.stderr b/tests/ui/borrowck/borrowck-pat-reassign-binding.stderr index 9e65ccf5a19..b86a8693881 100644 --- a/tests/ui/borrowck/borrowck-pat-reassign-binding.stderr +++ b/tests/ui/borrowck/borrowck-pat-reassign-binding.stderr @@ -2,10 +2,10 @@ error[E0506]: cannot assign to `x` because it is borrowed --> $DIR/borrowck-pat-reassign-binding.rs:10:11 | LL | Some(ref i) => { - | ----- borrow of `x` occurs here + | ----- `x` is borrowed here LL | // But on this branch, `i` is an outstanding borrow LL | x = Some(*i+1); - | ^^^^^^^^^^^^^^ assignment to borrowed `x` occurs here + | ^^^^^^^^^^^^^^ `x` is assigned to here but it was already borrowed LL | drop(i); | - borrow later used here diff --git a/tests/ui/borrowck/borrowck-union-borrow-nested.stderr b/tests/ui/borrowck/borrowck-union-borrow-nested.stderr index 4bd7d54cffe..a87a14e7cab 100644 --- a/tests/ui/borrowck/borrowck-union-borrow-nested.stderr +++ b/tests/ui/borrowck/borrowck-union-borrow-nested.stderr @@ -2,7 +2,7 @@ error[E0503]: cannot use `u.c` because it was mutably borrowed --> $DIR/borrowck-union-borrow-nested.rs:24:21 | LL | let ra = &mut u.s.a; - | ---------- borrow of `u.s.a` occurs here + | ---------- `u.s.a` is borrowed here LL | let b = u.c; | ^^^ use of borrowed `u.s.a` LL | ra.use_mut(); diff --git a/tests/ui/borrowck/borrowck-union-borrow.stderr b/tests/ui/borrowck/borrowck-union-borrow.stderr index 090c7b6b51a..11a28f6744b 100644 --- a/tests/ui/borrowck/borrowck-union-borrow.stderr +++ b/tests/ui/borrowck/borrowck-union-borrow.stderr @@ -12,9 +12,9 @@ error[E0506]: cannot assign to `u.a` because it is borrowed --> $DIR/borrowck-union-borrow.rs:28:13 | LL | let ra = &u.a; - | ---- borrow of `u.a` occurs here + | ---- `u.a` is borrowed here LL | u.a = 1; - | ^^^^^^^ assignment to borrowed `u.a` occurs here + | ^^^^^^^ `u.a` is assigned to here but it was already borrowed LL | drop(ra); | -- borrow later used here @@ -34,9 +34,9 @@ error[E0506]: cannot assign to `u.b` because it is borrowed --> $DIR/borrowck-union-borrow.rs:49:13 | LL | let ra = &u.a; - | ---- borrow of `u.b` occurs here + | ---- `u.b` is borrowed here LL | u.b = 1; - | ^^^^^^^ assignment to borrowed `u.b` occurs here + | ^^^^^^^ `u.b` is assigned to here but it was already borrowed LL | drop(ra); | -- borrow later used here @@ -54,7 +54,7 @@ error[E0503]: cannot use `u.a` because it was mutably borrowed --> $DIR/borrowck-union-borrow.rs:60:21 | LL | let ra = &mut u.a; - | -------- borrow of `u.a` occurs here + | -------- `u.a` is borrowed here LL | let a = u.a; | ^^^ use of borrowed `u.a` LL | drop(ra); @@ -74,9 +74,9 @@ error[E0506]: cannot assign to `u.a` because it is borrowed --> $DIR/borrowck-union-borrow.rs:70:13 | LL | let rma = &mut u.a; - | -------- borrow of `u.a` occurs here + | -------- `u.a` is borrowed here LL | u.a = 1; - | ^^^^^^^ assignment to borrowed `u.a` occurs here + | ^^^^^^^ `u.a` is assigned to here but it was already borrowed LL | drop(rma); | --- borrow later used here @@ -96,7 +96,7 @@ error[E0503]: cannot use `u.b` because it was mutably borrowed --> $DIR/borrowck-union-borrow.rs:81:21 | LL | let ra = &mut u.a; - | -------- borrow of `u.a` occurs here + | -------- `u.a` is borrowed here LL | let b = u.b; | ^^^ use of borrowed `u.a` LL | @@ -119,9 +119,9 @@ error[E0506]: cannot assign to `u.b` because it is borrowed --> $DIR/borrowck-union-borrow.rs:92:13 | LL | let rma = &mut u.a; - | -------- borrow of `u.b` occurs here + | -------- `u.b` is borrowed here LL | u.b = 1; - | ^^^^^^^ assignment to borrowed `u.b` occurs here + | ^^^^^^^ `u.b` is assigned to here but it was already borrowed LL | drop(rma); | --- borrow later used here diff --git a/tests/ui/borrowck/borrowck-use-mut-borrow.stderr b/tests/ui/borrowck/borrowck-use-mut-borrow.stderr index 91d69c51e81..4d300ae3c52 100644 --- a/tests/ui/borrowck/borrowck-use-mut-borrow.stderr +++ b/tests/ui/borrowck/borrowck-use-mut-borrow.stderr @@ -2,7 +2,7 @@ error[E0503]: cannot use `x` because it was mutably borrowed --> $DIR/borrowck-use-mut-borrow.rs:11:10 | LL | let p = &mut x; - | ------ borrow of `x` occurs here + | ------ `x` is borrowed here LL | drop(x); | ^ use of borrowed `x` LL | *p = 2; @@ -12,7 +12,7 @@ error[E0503]: cannot use `x` because it was mutably borrowed --> $DIR/borrowck-use-mut-borrow.rs:18:10 | LL | let p = &mut x.a; - | -------- borrow of `x.a` occurs here + | -------- `x.a` is borrowed here LL | drop(x); | ^ use of borrowed `x.a` LL | *p = 3; @@ -22,7 +22,7 @@ error[E0503]: cannot use `x.a` because it was mutably borrowed --> $DIR/borrowck-use-mut-borrow.rs:25:10 | LL | let p = &mut x; - | ------ borrow of `x` occurs here + | ------ `x` is borrowed here LL | drop(x.a); | ^^^ use of borrowed `x` LL | p.a = 3; @@ -32,7 +32,7 @@ error[E0503]: cannot use `x.a` because it was mutably borrowed --> $DIR/borrowck-use-mut-borrow.rs:32:10 | LL | let p = &mut x.a; - | -------- borrow of `x.a` occurs here + | -------- `x.a` is borrowed here LL | drop(x.a); | ^^^ use of borrowed `x.a` LL | *p = 3; @@ -42,7 +42,7 @@ error[E0503]: cannot use `x.a` because it was mutably borrowed --> $DIR/borrowck-use-mut-borrow.rs:39:13 | LL | let p = &mut x; - | ------ borrow of `x` occurs here + | ------ `x` is borrowed here LL | let y = A { b: 3, .. x }; | ^^^^^^^^^^^^^^^^ use of borrowed `x` LL | drop(y); @@ -53,7 +53,7 @@ error[E0503]: cannot use `x.a` because it was mutably borrowed --> $DIR/borrowck-use-mut-borrow.rs:47:13 | LL | let p = &mut x.a; - | -------- borrow of `x.a` occurs here + | -------- `x.a` is borrowed here LL | let y = A { b: 3, .. x }; | ^^^^^^^^^^^^^^^^ use of borrowed `x.a` LL | drop(y); @@ -64,7 +64,7 @@ error[E0503]: cannot use `*x` because it was mutably borrowed --> $DIR/borrowck-use-mut-borrow.rs:55:10 | LL | let p = &mut x; - | ------ borrow of `x` occurs here + | ------ `x` is borrowed here LL | drop(*x); | ^^ use of borrowed `x` LL | **p = 2; @@ -74,7 +74,7 @@ error[E0503]: cannot use `*x.b` because it was mutably borrowed --> $DIR/borrowck-use-mut-borrow.rs:62:10 | LL | let p = &mut x; - | ------ borrow of `x` occurs here + | ------ `x` is borrowed here LL | drop(*x.b); | ^^^^ use of borrowed `x` LL | p.a = 3; @@ -84,7 +84,7 @@ error[E0503]: cannot use `*x.b` because it was mutably borrowed --> $DIR/borrowck-use-mut-borrow.rs:69:10 | LL | let p = &mut x.b; - | -------- borrow of `x.b` occurs here + | -------- `x.b` is borrowed here LL | drop(*x.b); | ^^^^ use of borrowed `x.b` LL | **p = 3; diff --git a/tests/ui/borrowck/borrowck-vec-pattern-move-tail.stderr b/tests/ui/borrowck/borrowck-vec-pattern-move-tail.stderr index 0ac7df944d7..494d8c351a1 100644 --- a/tests/ui/borrowck/borrowck-vec-pattern-move-tail.stderr +++ b/tests/ui/borrowck/borrowck-vec-pattern-move-tail.stderr @@ -2,10 +2,10 @@ error[E0506]: cannot assign to `a[_]` because it is borrowed --> $DIR/borrowck-vec-pattern-move-tail.rs:8:5 | LL | [1, 2, ref tail @ ..] => tail, - | -------- borrow of `a[_]` occurs here + | -------- `a[_]` is borrowed here ... LL | a[2] = 0; - | ^^^^^^^^ assignment to borrowed `a[_]` occurs here + | ^^^^^^^^ `a[_]` is assigned to here but it was already borrowed LL | println!("t[0]: {}", t[0]); | ---- borrow later used here diff --git a/tests/ui/borrowck/borrowck-vec-pattern-nesting.rs b/tests/ui/borrowck/borrowck-vec-pattern-nesting.rs index 0e9284a2cad..1bda7a49713 100644 --- a/tests/ui/borrowck/borrowck-vec-pattern-nesting.rs +++ b/tests/ui/borrowck/borrowck-vec-pattern-nesting.rs @@ -5,9 +5,9 @@ fn a() { let mut vec = [Box::new(1), Box::new(2), Box::new(3)]; match vec { [box ref _a, _, _] => { - //~^ NOTE borrow of `vec[_]` occurs here + //~^ NOTE `vec[_]` is borrowed here vec[0] = Box::new(4); //~ ERROR cannot assign - //~^ NOTE assignment to borrowed `vec[_]` occurs here + //~^ NOTE `vec[_]` is assigned to here _a.use_ref(); //~^ NOTE borrow later used here } @@ -19,9 +19,9 @@ fn b() { let vec: &mut [Box] = &mut vec; match vec { &mut [ref _b @ ..] => { - //~^ borrow of `vec[_]` occurs here + //~^ `vec[_]` is borrowed here vec[0] = Box::new(4); //~ ERROR cannot assign - //~^ NOTE assignment to borrowed `vec[_]` occurs here + //~^ NOTE `vec[_]` is assigned to here _b.use_ref(); //~^ NOTE borrow later used here } diff --git a/tests/ui/borrowck/borrowck-vec-pattern-nesting.stderr b/tests/ui/borrowck/borrowck-vec-pattern-nesting.stderr index 0dc5e64e4ff..70b9e4f4433 100644 --- a/tests/ui/borrowck/borrowck-vec-pattern-nesting.stderr +++ b/tests/ui/borrowck/borrowck-vec-pattern-nesting.stderr @@ -2,10 +2,10 @@ error[E0506]: cannot assign to `vec[_]` because it is borrowed --> $DIR/borrowck-vec-pattern-nesting.rs:9:13 | LL | [box ref _a, _, _] => { - | ------ borrow of `vec[_]` occurs here + | ------ `vec[_]` is borrowed here LL | LL | vec[0] = Box::new(4); - | ^^^^^^ assignment to borrowed `vec[_]` occurs here + | ^^^^^^ `vec[_]` is assigned to here but it was already borrowed LL | LL | _a.use_ref(); | ------------ borrow later used here @@ -14,10 +14,10 @@ error[E0506]: cannot assign to `vec[_]` because it is borrowed --> $DIR/borrowck-vec-pattern-nesting.rs:23:13 | LL | &mut [ref _b @ ..] => { - | ------ borrow of `vec[_]` occurs here + | ------ `vec[_]` is borrowed here LL | LL | vec[0] = Box::new(4); - | ^^^^^^ assignment to borrowed `vec[_]` occurs here + | ^^^^^^ `vec[_]` is assigned to here but it was already borrowed LL | LL | _b.use_ref(); | ------------ borrow later used here diff --git a/tests/ui/borrowck/issue-25793.stderr b/tests/ui/borrowck/issue-25793.stderr index da3412f112d..27dab53e48f 100644 --- a/tests/ui/borrowck/issue-25793.stderr +++ b/tests/ui/borrowck/issue-25793.stderr @@ -5,7 +5,7 @@ LL | $this.width.unwrap() | ^^^^^^^^^^^ use of borrowed `*self` ... LL | let r = &mut *self; - | ---------- borrow of `*self` occurs here + | ---------- `*self` is borrowed here LL | r.get_size(width!(self)) | -------- ------------ in this macro invocation | | diff --git a/tests/ui/borrowck/issue-52713-bug.stderr b/tests/ui/borrowck/issue-52713-bug.stderr index 4abb6fb2c71..3f7715645e6 100644 --- a/tests/ui/borrowck/issue-52713-bug.stderr +++ b/tests/ui/borrowck/issue-52713-bug.stderr @@ -2,10 +2,10 @@ error[E0506]: cannot assign to `x` because it is borrowed --> $DIR/issue-52713-bug.rs:12:5 | LL | let y = &x; - | -- borrow of `x` occurs here + | -- `x` is borrowed here ... LL | x += 1; - | ^^^^^^ assignment to borrowed `x` occurs here + | ^^^^^^ `x` is assigned to here but it was already borrowed LL | println!("{}", y); | - borrow later used here diff --git a/tests/ui/borrowck/issue-58776-borrowck-scans-children.stderr b/tests/ui/borrowck/issue-58776-borrowck-scans-children.stderr index 57803247ba8..0870b423769 100644 --- a/tests/ui/borrowck/issue-58776-borrowck-scans-children.stderr +++ b/tests/ui/borrowck/issue-58776-borrowck-scans-children.stderr @@ -4,10 +4,10 @@ error[E0506]: cannot assign to `greeting` because it is borrowed LL | let res = (|| (|| &greeting)())(); | -- -------- borrow occurs due to use in closure | | - | borrow of `greeting` occurs here + | `greeting` is borrowed here LL | LL | greeting = "DEALLOCATED".to_string(); - | ^^^^^^^^ assignment to borrowed `greeting` occurs here + | ^^^^^^^^ `greeting` is assigned to here but it was already borrowed ... LL | println!("thread result: {:?}", res); | --- borrow later used here diff --git a/tests/ui/borrowck/issue-81365-1.stderr b/tests/ui/borrowck/issue-81365-1.stderr index d79394834dc..0d803b0427a 100644 --- a/tests/ui/borrowck/issue-81365-1.stderr +++ b/tests/ui/borrowck/issue-81365-1.stderr @@ -2,9 +2,9 @@ error[E0506]: cannot assign to `self.container_field` because it is borrowed --> $DIR/issue-81365-1.rs:21:9 | LL | let first = &self.target_field; - | ---- borrow of `self.container_field` occurs here + | ---- `self.container_field` is borrowed here LL | self.container_field = true; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `self.container_field` occurs here + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `self.container_field` is assigned to here but it was already borrowed LL | first; | ----- borrow later used here | diff --git a/tests/ui/borrowck/issue-81365-10.stderr b/tests/ui/borrowck/issue-81365-10.stderr index 27123ef2be1..d0986e9f922 100644 --- a/tests/ui/borrowck/issue-81365-10.stderr +++ b/tests/ui/borrowck/issue-81365-10.stderr @@ -2,9 +2,9 @@ error[E0506]: cannot assign to `self.container_field` because it is borrowed --> $DIR/issue-81365-10.rs:21:9 | LL | let first = &self.deref().target_field; - | ------------ borrow of `self.container_field` occurs here + | ------------ `self.container_field` is borrowed here LL | self.container_field = true; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `self.container_field` occurs here + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `self.container_field` is assigned to here but it was already borrowed LL | first; | ----- borrow later used here diff --git a/tests/ui/borrowck/issue-81365-11.stderr b/tests/ui/borrowck/issue-81365-11.stderr index 0770c136632..5f7e86f11dc 100644 --- a/tests/ui/borrowck/issue-81365-11.stderr +++ b/tests/ui/borrowck/issue-81365-11.stderr @@ -2,9 +2,9 @@ error[E0506]: cannot assign to `self.container_field` because it is borrowed --> $DIR/issue-81365-11.rs:27:9 | LL | let first = &mut self.target_field; - | ---- borrow of `self.container_field` occurs here + | ---- `self.container_field` is borrowed here LL | self.container_field = true; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `self.container_field` occurs here + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `self.container_field` is assigned to here but it was already borrowed LL | first; | ----- borrow later used here diff --git a/tests/ui/borrowck/issue-81365-2.stderr b/tests/ui/borrowck/issue-81365-2.stderr index 764eaaa7cc7..d9aeaf15f20 100644 --- a/tests/ui/borrowck/issue-81365-2.stderr +++ b/tests/ui/borrowck/issue-81365-2.stderr @@ -2,9 +2,9 @@ error[E0506]: cannot assign to `self.container.container_field` because it is bo --> $DIR/issue-81365-2.rs:25:9 | LL | let first = &self.container.target_field; - | -------------- borrow of `self.container.container_field` occurs here + | -------------- `self.container.container_field` is borrowed here LL | self.container.container_field = true; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `self.container.container_field` occurs here + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `self.container.container_field` is assigned to here but it was already borrowed LL | first; | ----- borrow later used here | diff --git a/tests/ui/borrowck/issue-81365-3.stderr b/tests/ui/borrowck/issue-81365-3.stderr index 9447174fd21..0c0d1994baf 100644 --- a/tests/ui/borrowck/issue-81365-3.stderr +++ b/tests/ui/borrowck/issue-81365-3.stderr @@ -2,9 +2,9 @@ error[E0506]: cannot assign to `self.container.container_field` because it is bo --> $DIR/issue-81365-3.rs:32:9 | LL | let first = &self.target_field; - | ---- borrow of `self.container.container_field` occurs here + | ---- `self.container.container_field` is borrowed here LL | self.container.container_field = true; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `self.container.container_field` occurs here + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `self.container.container_field` is assigned to here but it was already borrowed LL | first; | ----- borrow later used here | diff --git a/tests/ui/borrowck/issue-81365-4.stderr b/tests/ui/borrowck/issue-81365-4.stderr index 0ab3fa92706..98093daa945 100644 --- a/tests/ui/borrowck/issue-81365-4.stderr +++ b/tests/ui/borrowck/issue-81365-4.stderr @@ -2,9 +2,9 @@ error[E0506]: cannot assign to `self.outer_field` because it is borrowed --> $DIR/issue-81365-4.rs:33:9 | LL | let first = &self.target_field; - | ---- borrow of `self.outer_field` occurs here + | ---- `self.outer_field` is borrowed here LL | self.outer_field = true; - | ^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `self.outer_field` occurs here + | ^^^^^^^^^^^^^^^^^^^^^^^ `self.outer_field` is assigned to here but it was already borrowed LL | first; | ----- borrow later used here | diff --git a/tests/ui/borrowck/issue-81365-5.stderr b/tests/ui/borrowck/issue-81365-5.stderr index 20ff229ffe7..c00e48288ba 100644 --- a/tests/ui/borrowck/issue-81365-5.stderr +++ b/tests/ui/borrowck/issue-81365-5.stderr @@ -2,9 +2,9 @@ error[E0506]: cannot assign to `self.container_field` because it is borrowed --> $DIR/issue-81365-5.rs:28:9 | LL | let first = self.get(); - | ---------- borrow of `self.container_field` occurs here + | ---------- `self.container_field` is borrowed here LL | self.container_field = true; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `self.container_field` occurs here + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `self.container_field` is assigned to here but it was already borrowed LL | first; | ----- borrow later used here | diff --git a/tests/ui/borrowck/issue-81365-6.stderr b/tests/ui/borrowck/issue-81365-6.stderr index 575aed73b46..e61dc95ecc8 100644 --- a/tests/ui/borrowck/issue-81365-6.stderr +++ b/tests/ui/borrowck/issue-81365-6.stderr @@ -2,9 +2,9 @@ error[E0506]: cannot assign to `self.container_field` because it is borrowed --> $DIR/issue-81365-6.rs:18:9 | LL | let first = &self[0]; - | ---- borrow of `self.container_field` occurs here + | ---- `self.container_field` is borrowed here LL | self.container_field = true; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `self.container_field` occurs here + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `self.container_field` is assigned to here but it was already borrowed LL | first; | ----- borrow later used here | diff --git a/tests/ui/borrowck/issue-81365-7.stderr b/tests/ui/borrowck/issue-81365-7.stderr index 52d2d9e75a9..0565127e387 100644 --- a/tests/ui/borrowck/issue-81365-7.stderr +++ b/tests/ui/borrowck/issue-81365-7.stderr @@ -2,9 +2,9 @@ error[E0506]: cannot assign to `c.container_field` because it is borrowed --> $DIR/issue-81365-7.rs:20:5 | LL | let first = &c.target_field; - | - borrow of `c.container_field` occurs here + | - `c.container_field` is borrowed here LL | c.container_field = true; - | ^^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `c.container_field` occurs here + | ^^^^^^^^^^^^^^^^^^^^^^^^ `c.container_field` is assigned to here but it was already borrowed LL | first; | ----- borrow later used here | diff --git a/tests/ui/borrowck/issue-81365-8.stderr b/tests/ui/borrowck/issue-81365-8.stderr index fd83e10a295..0ca732ff2ae 100644 --- a/tests/ui/borrowck/issue-81365-8.stderr +++ b/tests/ui/borrowck/issue-81365-8.stderr @@ -2,9 +2,9 @@ error[E0506]: cannot assign to `self.container_field` because it is borrowed --> $DIR/issue-81365-8.rs:21:9 | LL | let first = &(*self).target_field; - | ------- borrow of `self.container_field` occurs here + | ------- `self.container_field` is borrowed here LL | self.container_field = true; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `self.container_field` occurs here + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `self.container_field` is assigned to here but it was already borrowed LL | first; | ----- borrow later used here | diff --git a/tests/ui/borrowck/issue-81365-9.stderr b/tests/ui/borrowck/issue-81365-9.stderr index c7d48214fd4..4d305268a0b 100644 --- a/tests/ui/borrowck/issue-81365-9.stderr +++ b/tests/ui/borrowck/issue-81365-9.stderr @@ -2,9 +2,9 @@ error[E0506]: cannot assign to `self.container_field` because it is borrowed --> $DIR/issue-81365-9.rs:21:9 | LL | let first = &Deref::deref(self).target_field; - | ---- borrow of `self.container_field` occurs here + | ---- `self.container_field` is borrowed here LL | self.container_field = true; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `self.container_field` occurs here + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `self.container_field` is assigned to here but it was already borrowed LL | first; | ----- borrow later used here diff --git a/tests/ui/borrowck/two-phase-allow-access-during-reservation.nll_target.stderr b/tests/ui/borrowck/two-phase-allow-access-during-reservation.nll_target.stderr index a57ceb84739..1356c80493c 100644 --- a/tests/ui/borrowck/two-phase-allow-access-during-reservation.nll_target.stderr +++ b/tests/ui/borrowck/two-phase-allow-access-during-reservation.nll_target.stderr @@ -2,7 +2,7 @@ error[E0503]: cannot use `i` because it was mutably borrowed --> $DIR/two-phase-allow-access-during-reservation.rs:26:19 | LL | /*1*/ let p = &mut i; // (reservation of `i` starts here) - | ------ borrow of `i` occurs here + | ------ `i` is borrowed here LL | LL | /*2*/ let j = i; // OK: `i` is only reserved here | ^ use of borrowed `i` @@ -14,7 +14,7 @@ error[E0503]: cannot use `i` because it was mutably borrowed --> $DIR/two-phase-allow-access-during-reservation.rs:31:19 | LL | /*1*/ let p = &mut i; // (reservation of `i` starts here) - | ------ borrow of `i` occurs here + | ------ `i` is borrowed here ... LL | /*4*/ let k = i; | ^ use of borrowed `i` diff --git a/tests/ui/borrowck/two-phase-surprise-no-conflict.stderr b/tests/ui/borrowck/two-phase-surprise-no-conflict.stderr index 5a240d90011..e75094d4f13 100644 --- a/tests/ui/borrowck/two-phase-surprise-no-conflict.stderr +++ b/tests/ui/borrowck/two-phase-surprise-no-conflict.stderr @@ -2,7 +2,7 @@ error[E0503]: cannot use `self.cx` because it was mutably borrowed --> $DIR/two-phase-surprise-no-conflict.rs:21:23 | LL | let _mut_borrow = &mut *self; - | ---------- borrow of `*self` occurs here + | ---------- `*self` is borrowed here LL | let _access = self.cx; | ^^^^^^^ use of borrowed `*self` LL | diff --git a/tests/ui/btreemap/btreemap_dropck.stderr b/tests/ui/btreemap/btreemap_dropck.stderr index e953e7ae82b..d405e465aae 100644 --- a/tests/ui/btreemap/btreemap_dropck.stderr +++ b/tests/ui/btreemap/btreemap_dropck.stderr @@ -1,6 +1,8 @@ error[E0505]: cannot move out of `s` because it is borrowed --> $DIR/btreemap_dropck.rs:15:10 | +LL | let s = String::from("Hello World!"); + | - binding `s` declared here LL | let _map = BTreeMap::from_iter([((), PrintOnDrop(&s))]); | -- borrow of `s` occurs here LL | drop(s); diff --git a/tests/ui/c-variadic/variadic-ffi-4.stderr b/tests/ui/c-variadic/variadic-ffi-4.stderr index 6f8e53298ac..c9d90d73dea 100644 --- a/tests/ui/c-variadic/variadic-ffi-4.stderr +++ b/tests/ui/c-variadic/variadic-ffi-4.stderr @@ -107,7 +107,9 @@ error[E0597]: `ap1` does not live long enough --> $DIR/variadic-ffi-4.rs:28:11 | LL | pub unsafe extern "C" fn no_escape4(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) { - | - let's call the lifetime of this reference `'3` + | - ------- binding `ap1` declared here + | | + | let's call the lifetime of this reference `'3` LL | ap0 = &mut ap1; | ------^^^^^^^^ | | | diff --git a/tests/ui/closures/2229_closure_analysis/diagnostics/arrays.stderr b/tests/ui/closures/2229_closure_analysis/diagnostics/arrays.stderr index 4f41060dc98..9e5200ef34b 100644 --- a/tests/ui/closures/2229_closure_analysis/diagnostics/arrays.stderr +++ b/tests/ui/closures/2229_closure_analysis/diagnostics/arrays.stderr @@ -2,7 +2,7 @@ error[E0503]: cannot use `arr` because it was mutably borrowed --> $DIR/arrays.rs:14:5 | LL | let mut c = || { - | -- borrow of `arr` occurs here + | -- `arr` is borrowed here LL | arr[0] += 10; | --- borrow occurs due to use of `arr` in closure ... @@ -16,7 +16,7 @@ error[E0503]: cannot use `arr[_]` because it was mutably borrowed --> $DIR/arrays.rs:14:5 | LL | let mut c = || { - | -- borrow of `arr` occurs here + | -- `arr` is borrowed here LL | arr[0] += 10; | --- borrow occurs due to use of `arr` in closure ... @@ -30,12 +30,12 @@ error[E0506]: cannot assign to `arr[_]` because it is borrowed --> $DIR/arrays.rs:29:5 | LL | let c = || { - | -- borrow of `arr[_]` occurs here + | -- `arr[_]` is borrowed here LL | println!("{:#?}", &arr[3..4]); | --- borrow occurs due to use in closure ... LL | arr[1] += 10; - | ^^^^^^^^^^^^ assignment to borrowed `arr[_]` occurs here + | ^^^^^^^^^^^^ `arr[_]` is assigned to here but it was already borrowed LL | LL | c(); | - borrow later used here @@ -44,12 +44,12 @@ error[E0506]: cannot assign to `arr[_]` because it is borrowed --> $DIR/arrays.rs:43:5 | LL | let c = || { - | -- borrow of `arr[_]` occurs here + | -- `arr[_]` is borrowed here LL | println!("{}", arr[3]); | --- borrow occurs due to use in closure ... LL | arr[1] += 10; - | ^^^^^^^^^^^^ assignment to borrowed `arr[_]` occurs here + | ^^^^^^^^^^^^ `arr[_]` is assigned to here but it was already borrowed LL | LL | c(); | - borrow later used here @@ -58,7 +58,7 @@ error[E0503]: cannot use `arr` because it was mutably borrowed --> $DIR/arrays.rs:57:20 | LL | let mut c = || { - | -- borrow of `arr` occurs here + | -- `arr` is borrowed here LL | arr[1] += 10; | --- borrow occurs due to use of `arr` in closure ... diff --git a/tests/ui/closures/2229_closure_analysis/diagnostics/box.stderr b/tests/ui/closures/2229_closure_analysis/diagnostics/box.stderr index f8b17875235..2e3259e6405 100644 --- a/tests/ui/closures/2229_closure_analysis/diagnostics/box.stderr +++ b/tests/ui/closures/2229_closure_analysis/diagnostics/box.stderr @@ -2,12 +2,12 @@ error[E0506]: cannot assign to `e.0.0.m.x` because it is borrowed --> $DIR/box.rs:21:5 | LL | let mut c = || { - | -- borrow of `e.0.0.m.x` occurs here + | -- `e.0.0.m.x` is borrowed here LL | e.0.0.m.x = format!("not-x"); | --------- borrow occurs due to use in closure ... LL | e.0.0.m.x = format!("not-x"); - | ^^^^^^^^^ assignment to borrowed `e.0.0.m.x` occurs here + | ^^^^^^^^^ `e.0.0.m.x` is assigned to here but it was already borrowed LL | LL | c(); | - borrow later used here @@ -32,12 +32,12 @@ error[E0506]: cannot assign to `e.0.0.m.x` because it is borrowed --> $DIR/box.rs:55:5 | LL | let c = || { - | -- borrow of `e.0.0.m.x` occurs here + | -- `e.0.0.m.x` is borrowed here LL | println!("{}", e.0.0.m.x); | --------- borrow occurs due to use in closure ... LL | e.0.0.m.x = format!("not-x"); - | ^^^^^^^^^ assignment to borrowed `e.0.0.m.x` occurs here + | ^^^^^^^^^ `e.0.0.m.x` is assigned to here but it was already borrowed LL | LL | c(); | - borrow later used here diff --git a/tests/ui/closures/2229_closure_analysis/diagnostics/union.rs b/tests/ui/closures/2229_closure_analysis/diagnostics/union.rs index 46b54846e32..695337ea82c 100644 --- a/tests/ui/closures/2229_closure_analysis/diagnostics/union.rs +++ b/tests/ui/closures/2229_closure_analysis/diagnostics/union.rs @@ -11,7 +11,7 @@ union A { fn main() { let mut a = A { y: 1 }; let mut c = || { - //~^ borrow of `a.y` occurs here + //~^ `a.y` is borrowed here let _ = unsafe { &a.y }; let _ = &mut a; //~^ borrow occurs due to use in closure @@ -19,7 +19,7 @@ fn main() { }; a.y = 1; //~^ cannot assign to `a.y` because it is borrowed [E0506] - //~| assignment to borrowed `a.y` occurs here + //~| `a.y` is assigned to here c(); //~^ borrow later used here } diff --git a/tests/ui/closures/2229_closure_analysis/diagnostics/union.stderr b/tests/ui/closures/2229_closure_analysis/diagnostics/union.stderr index 7c34e2336c8..17834e61236 100644 --- a/tests/ui/closures/2229_closure_analysis/diagnostics/union.stderr +++ b/tests/ui/closures/2229_closure_analysis/diagnostics/union.stderr @@ -2,13 +2,13 @@ error[E0506]: cannot assign to `a.y` because it is borrowed --> $DIR/union.rs:20:5 | LL | let mut c = || { - | -- borrow of `a.y` occurs here + | -- `a.y` is borrowed here ... LL | let _ = &mut a; | - borrow occurs due to use in closure ... LL | a.y = 1; - | ^^^^^^^ assignment to borrowed `a.y` occurs here + | ^^^^^^^ `a.y` is assigned to here but it was already borrowed ... LL | c(); | - borrow later used here diff --git a/tests/ui/coercion/coerce-overloaded-autoderef-fail.stderr b/tests/ui/coercion/coerce-overloaded-autoderef-fail.stderr index d067c3b3a18..d412b8b08b7 100644 --- a/tests/ui/coercion/coerce-overloaded-autoderef-fail.stderr +++ b/tests/ui/coercion/coerce-overloaded-autoderef-fail.stderr @@ -13,10 +13,10 @@ error[E0506]: cannot assign to `**x` because it is borrowed --> $DIR/coerce-overloaded-autoderef-fail.rs:17:5 | LL | let y = borrow(x); - | - borrow of `**x` occurs here + | - `**x` is borrowed here LL | let z = borrow(x); LL | **x += 1; - | ^^^^^^^^ assignment to borrowed `**x` occurs here + | ^^^^^^^^ `**x` is assigned to here but it was already borrowed LL | LL | drop((y, z)); | - borrow later used here diff --git a/tests/ui/consts/promote_const_let.stderr b/tests/ui/consts/promote_const_let.stderr index 975a235a649..6e0349a4773 100644 --- a/tests/ui/consts/promote_const_let.stderr +++ b/tests/ui/consts/promote_const_let.stderr @@ -4,6 +4,7 @@ error[E0597]: `y` does not live long enough LL | let x: &'static u32 = { | ------------ type annotation requires that `y` is borrowed for `'static` LL | let y = 42; + | - binding `y` declared here LL | &y | ^^ borrowed value does not live long enough LL | }; diff --git a/tests/ui/dropck/dropck-eyepatch-extern-crate.stderr b/tests/ui/dropck/dropck-eyepatch-extern-crate.stderr index 5d53405579d..23d57634e8f 100644 --- a/tests/ui/dropck/dropck-eyepatch-extern-crate.stderr +++ b/tests/ui/dropck/dropck-eyepatch-extern-crate.stderr @@ -1,6 +1,9 @@ error[E0597]: `c_shortest` does not live long enough --> $DIR/dropck-eyepatch-extern-crate.rs:46:23 | +LL | let (mut dt, mut dr, c_shortest): (Dt<_>, Dr<_>, Cell<_>); + | ---------- binding `c_shortest` declared here +... LL | dt = Dt("dt", &c_shortest); | ^^^^^^^^^^^ borrowed value does not live long enough ... @@ -15,6 +18,9 @@ LL | } error[E0597]: `c_shortest` does not live long enough --> $DIR/dropck-eyepatch-extern-crate.rs:68:32 | +LL | let (mut pt, mut pr, c_shortest): (Pt<_, _>, Pr<_>, Cell<_>); + | ---------- binding `c_shortest` declared here +... LL | pt = Pt("pt", &c_long, &c_shortest); | ^^^^^^^^^^^ borrowed value does not live long enough ... diff --git a/tests/ui/dropck/dropck-eyepatch-reorder.stderr b/tests/ui/dropck/dropck-eyepatch-reorder.stderr index 5055cdd8b2b..a5d5136b5c5 100644 --- a/tests/ui/dropck/dropck-eyepatch-reorder.stderr +++ b/tests/ui/dropck/dropck-eyepatch-reorder.stderr @@ -1,6 +1,9 @@ error[E0597]: `c_shortest` does not live long enough --> $DIR/dropck-eyepatch-reorder.rs:64:23 | +LL | let (mut dt, mut dr, c_shortest): (Dt<_>, Dr<_>, Cell<_>); + | ---------- binding `c_shortest` declared here +... LL | dt = Dt("dt", &c_shortest); | ^^^^^^^^^^^ borrowed value does not live long enough ... @@ -15,6 +18,9 @@ LL | } error[E0597]: `c_shortest` does not live long enough --> $DIR/dropck-eyepatch-reorder.rs:86:32 | +LL | let (mut pt, mut pr, c_shortest): (Pt<_, _>, Pr<_>, Cell<_>); + | ---------- binding `c_shortest` declared here +... LL | pt = Pt("pt", &c_long, &c_shortest); | ^^^^^^^^^^^ borrowed value does not live long enough ... diff --git a/tests/ui/dropck/dropck-eyepatch.stderr b/tests/ui/dropck/dropck-eyepatch.stderr index 21295e6c601..dc3f8c05e73 100644 --- a/tests/ui/dropck/dropck-eyepatch.stderr +++ b/tests/ui/dropck/dropck-eyepatch.stderr @@ -1,6 +1,9 @@ error[E0597]: `c_shortest` does not live long enough --> $DIR/dropck-eyepatch.rs:88:23 | +LL | let (mut dt, mut dr, c_shortest): (Dt<_>, Dr<_>, Cell<_>); + | ---------- binding `c_shortest` declared here +... LL | dt = Dt("dt", &c_shortest); | ^^^^^^^^^^^ borrowed value does not live long enough ... @@ -15,6 +18,9 @@ LL | } error[E0597]: `c_shortest` does not live long enough --> $DIR/dropck-eyepatch.rs:110:32 | +LL | let (mut pt, mut pr, c_shortest): (Pt<_, _>, Pr<_>, Cell<_>); + | ---------- binding `c_shortest` declared here +... LL | pt = Pt("pt", &c_long, &c_shortest); | ^^^^^^^^^^^ borrowed value does not live long enough ... diff --git a/tests/ui/dropck/dropck-union.stderr b/tests/ui/dropck/dropck-union.stderr index 854e29385a8..7d48e9fdcee 100644 --- a/tests/ui/dropck/dropck-union.stderr +++ b/tests/ui/dropck/dropck-union.stderr @@ -1,6 +1,8 @@ error[E0597]: `v` does not live long enough --> $DIR/dropck-union.rs:37:18 | +LL | let v : Wrap = Wrap::new(C(Cell::new(None))); + | - binding `v` declared here LL | v.0.set(Some(&v)); | ^^ borrowed value does not live long enough LL | } diff --git a/tests/ui/dropck/dropck_trait_cycle_checked.stderr b/tests/ui/dropck/dropck_trait_cycle_checked.stderr index dc3fbed593b..4d4f7b9df11 100644 --- a/tests/ui/dropck/dropck_trait_cycle_checked.stderr +++ b/tests/ui/dropck/dropck_trait_cycle_checked.stderr @@ -2,7 +2,7 @@ error[E0597]: `o2` does not live long enough --> $DIR/dropck_trait_cycle_checked.rs:111:13 | LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); - | -------- cast requires that `o2` is borrowed for `'static` + | -- binding `o2` declared here -------- cast requires that `o2` is borrowed for `'static` LL | o1.set0(&o2); | ^^^ borrowed value does not live long enough ... @@ -13,7 +13,7 @@ error[E0597]: `o3` does not live long enough --> $DIR/dropck_trait_cycle_checked.rs:112:13 | LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); - | -------- cast requires that `o3` is borrowed for `'static` + | -- binding `o3` declared here -------- cast requires that `o3` is borrowed for `'static` LL | o1.set0(&o2); LL | o1.set1(&o3); | ^^^ borrowed value does not live long enough @@ -25,7 +25,7 @@ error[E0597]: `o2` does not live long enough --> $DIR/dropck_trait_cycle_checked.rs:113:13 | LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); - | -------- cast requires that `o2` is borrowed for `'static` + | -- binding `o2` declared here -------- cast requires that `o2` is borrowed for `'static` ... LL | o2.set0(&o2); | ^^^ borrowed value does not live long enough @@ -37,7 +37,7 @@ error[E0597]: `o3` does not live long enough --> $DIR/dropck_trait_cycle_checked.rs:114:13 | LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); - | -------- cast requires that `o3` is borrowed for `'static` + | -- binding `o3` declared here -------- cast requires that `o3` is borrowed for `'static` ... LL | o2.set1(&o3); | ^^^ borrowed value does not live long enough @@ -49,7 +49,7 @@ error[E0597]: `o1` does not live long enough --> $DIR/dropck_trait_cycle_checked.rs:115:13 | LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); - | -------- cast requires that `o1` is borrowed for `'static` + | -- binding `o1` declared here -------- cast requires that `o1` is borrowed for `'static` ... LL | o3.set0(&o1); | ^^^ borrowed value does not live long enough @@ -61,7 +61,7 @@ error[E0597]: `o2` does not live long enough --> $DIR/dropck_trait_cycle_checked.rs:116:13 | LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); - | -------- cast requires that `o2` is borrowed for `'static` + | -- binding `o2` declared here -------- cast requires that `o2` is borrowed for `'static` ... LL | o3.set1(&o2); | ^^^ borrowed value does not live long enough diff --git a/tests/ui/dst/dst-bad-coerce3.stderr b/tests/ui/dst/dst-bad-coerce3.stderr index 957e98bbeee..1254250bcbd 100644 --- a/tests/ui/dst/dst-bad-coerce3.stderr +++ b/tests/ui/dst/dst-bad-coerce3.stderr @@ -3,7 +3,9 @@ error[E0597]: `f1` does not live long enough | LL | fn baz<'a>() { | -- lifetime `'a` defined here -... +LL | // With a vec of ints. +LL | let f1 = Fat { ptr: [1, 2, 3] }; + | -- binding `f1` declared here LL | let f2: &Fat<[isize; 3]> = &f1; | ^^^ borrowed value does not live long enough LL | let f3: &'a Fat<[isize]> = f2; @@ -18,6 +20,8 @@ error[E0597]: `f1` does not live long enough LL | fn baz<'a>() { | -- lifetime `'a` defined here ... +LL | let f1 = Fat { ptr: Foo }; + | -- binding `f1` declared here LL | let f2: &Fat = &f1; | ^^^ borrowed value does not live long enough LL | let f3: &'a Fat = f2; @@ -32,6 +36,8 @@ error[E0597]: `f1` does not live long enough LL | fn baz<'a>() { | -- lifetime `'a` defined here ... +LL | let f1 = ([1, 2, 3],); + | -- binding `f1` declared here LL | let f2: &([isize; 3],) = &f1; | ^^^ borrowed value does not live long enough LL | let f3: &'a ([isize],) = f2; @@ -46,6 +52,8 @@ error[E0597]: `f1` does not live long enough LL | fn baz<'a>() { | -- lifetime `'a` defined here ... +LL | let f1 = (Foo,); + | -- binding `f1` declared here LL | let f2: &(Foo,) = &f1; | ^^^ borrowed value does not live long enough LL | let f3: &'a (dyn Bar,) = f2; diff --git a/tests/ui/error-codes/E0503.stderr b/tests/ui/error-codes/E0503.stderr index fafe363eb47..2f02e3b1a61 100644 --- a/tests/ui/error-codes/E0503.stderr +++ b/tests/ui/error-codes/E0503.stderr @@ -2,7 +2,7 @@ error[E0503]: cannot use `value` because it was mutably borrowed --> $DIR/E0503.rs:4:16 | LL | let _borrow = &mut value; - | ---------- borrow of `value` occurs here + | ---------- `value` is borrowed here LL | let _sum = value + 1; | ^^^^^ use of borrowed `value` LL | _borrow.use_mut(); diff --git a/tests/ui/error-codes/E0504.stderr b/tests/ui/error-codes/E0504.stderr index e677e891615..20e16a53810 100644 --- a/tests/ui/error-codes/E0504.stderr +++ b/tests/ui/error-codes/E0504.stderr @@ -1,6 +1,8 @@ error[E0505]: cannot move out of `fancy_num` because it is borrowed --> $DIR/E0504.rs:9:13 | +LL | let fancy_num = FancyNum { num: 5 }; + | --------- binding `fancy_num` declared here LL | let fancy_ref = &fancy_num; | ---------- borrow of `fancy_num` occurs here LL | diff --git a/tests/ui/error-codes/E0505.stderr b/tests/ui/error-codes/E0505.stderr index bd3f37f54e0..2ecb4a75c43 100644 --- a/tests/ui/error-codes/E0505.stderr +++ b/tests/ui/error-codes/E0505.stderr @@ -1,6 +1,9 @@ error[E0505]: cannot move out of `x` because it is borrowed --> $DIR/E0505.rs:9:13 | +LL | let x = Value{}; + | - binding `x` declared here +LL | { LL | let _ref_to_val: &Value = &x; | -- borrow of `x` occurs here LL | eat(x); diff --git a/tests/ui/error-codes/E0506.stderr b/tests/ui/error-codes/E0506.stderr index d70406b750a..17ad7c611f8 100644 --- a/tests/ui/error-codes/E0506.stderr +++ b/tests/ui/error-codes/E0506.stderr @@ -2,9 +2,9 @@ error[E0506]: cannot assign to `fancy_num` because it is borrowed --> $DIR/E0506.rs:8:5 | LL | let fancy_ref = &fancy_num; - | ---------- borrow of `fancy_num` occurs here + | ---------- `fancy_num` is borrowed here LL | fancy_num = FancyNum { num: 6 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `fancy_num` occurs here + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `fancy_num` is assigned to here but it was already borrowed LL | LL | println!("Num: {}, Ref: {}", fancy_num.num, fancy_ref.num); | ------------- borrow later used here diff --git a/tests/ui/error-codes/E0597.stderr b/tests/ui/error-codes/E0597.stderr index b4a1180ad54..82e3481b65a 100644 --- a/tests/ui/error-codes/E0597.stderr +++ b/tests/ui/error-codes/E0597.stderr @@ -1,6 +1,8 @@ error[E0597]: `y` does not live long enough --> $DIR/E0597.rs:8:16 | +LL | let y = 0; + | - binding `y` declared here LL | x.x = Some(&y); | ^^ borrowed value does not live long enough LL | diff --git a/tests/ui/fn/implied-bounds-unnorm-associated-type-4.stderr b/tests/ui/fn/implied-bounds-unnorm-associated-type-4.stderr index fcbaa91d19f..4df639232a3 100644 --- a/tests/ui/fn/implied-bounds-unnorm-associated-type-4.stderr +++ b/tests/ui/fn/implied-bounds-unnorm-associated-type-4.stderr @@ -1,6 +1,8 @@ error[E0505]: cannot move out of `x` because it is borrowed --> $DIR/implied-bounds-unnorm-associated-type-4.rs:21:10 | +LL | let x = String::from("Hello World!"); + | - binding `x` declared here LL | let y = f(&x, ()); | -- borrow of `x` occurs here LL | drop(x); diff --git a/tests/ui/fn/implied-bounds-unnorm-associated-type.stderr b/tests/ui/fn/implied-bounds-unnorm-associated-type.stderr index e35f46e4439..d417f288393 100644 --- a/tests/ui/fn/implied-bounds-unnorm-associated-type.stderr +++ b/tests/ui/fn/implied-bounds-unnorm-associated-type.stderr @@ -1,6 +1,8 @@ error[E0505]: cannot move out of `x` because it is borrowed --> $DIR/implied-bounds-unnorm-associated-type.rs:20:10 | +LL | let x = String::from("Hello World!"); + | - binding `x` declared here LL | let y = f(&x, ()); | -- borrow of `x` occurs here LL | drop(x); diff --git a/tests/ui/generic-associated-types/issue-74684-1.stderr b/tests/ui/generic-associated-types/issue-74684-1.stderr index cacc973077c..b93ee37987f 100644 --- a/tests/ui/generic-associated-types/issue-74684-1.stderr +++ b/tests/ui/generic-associated-types/issue-74684-1.stderr @@ -4,6 +4,7 @@ error[E0597]: `a` does not live long enough LL | fn bug<'a, T: ?Sized + Fun = [u8]>>(_ : Box) -> &'static T::F<'a> { | -- lifetime `'a` defined here LL | let a = [0; 1]; + | - binding `a` declared here LL | let _x = T::identity(&a); | ------------^^- | | | diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-identity-fn-borrows.stderr b/tests/ui/higher-rank-trait-bounds/hrtb-identity-fn-borrows.stderr index 4886a3c8bad..25af011e3fc 100644 --- a/tests/ui/higher-rank-trait-bounds/hrtb-identity-fn-borrows.stderr +++ b/tests/ui/higher-rank-trait-bounds/hrtb-identity-fn-borrows.stderr @@ -2,9 +2,9 @@ error[E0506]: cannot assign to `x` because it is borrowed --> $DIR/hrtb-identity-fn-borrows.rs:14:5 | LL | let y = f.call(&x); - | -- borrow of `x` occurs here + | -- `x` is borrowed here LL | x = 5; - | ^^^^^ assignment to borrowed `x` occurs here + | ^^^^^ `x` is assigned to here but it was already borrowed ... LL | drop(y); | - borrow later used here diff --git a/tests/ui/impl-trait/feature-self-return-type.stderr b/tests/ui/impl-trait/feature-self-return-type.stderr index 601e53b7694..b9b8d00ce30 100644 --- a/tests/ui/impl-trait/feature-self-return-type.stderr +++ b/tests/ui/impl-trait/feature-self-return-type.stderr @@ -4,6 +4,7 @@ error[E0597]: `bar` does not live long enough LL | let x = { | - borrow later stored here LL | let bar = 22; + | --- binding `bar` declared here LL | Foo::new(&bar).into() | ^^^^ borrowed value does not live long enough LL | @@ -16,6 +17,7 @@ error[E0597]: `y` does not live long enough LL | let x = { | - borrow later stored here LL | let y = (); + | - binding `y` declared here LL | foo(&y) | ^^ borrowed value does not live long enough LL | @@ -28,6 +30,7 @@ error[E0597]: `y` does not live long enough LL | let x = { | - borrow later stored here LL | let y = (); + | - binding `y` declared here LL | foo(&y) | ^^ borrowed value does not live long enough LL | diff --git a/tests/ui/implied-bounds/assoc-ty-wf-used-to-get-assoc-ty.stderr b/tests/ui/implied-bounds/assoc-ty-wf-used-to-get-assoc-ty.stderr index d0249e74f39..307899297bc 100644 --- a/tests/ui/implied-bounds/assoc-ty-wf-used-to-get-assoc-ty.stderr +++ b/tests/ui/implied-bounds/assoc-ty-wf-used-to-get-assoc-ty.stderr @@ -1,6 +1,8 @@ error[E0597]: `x` does not live long enough --> $DIR/assoc-ty-wf-used-to-get-assoc-ty.rs:24:31 | +LL | let x: u8 = 3; + | - binding `x` declared here LL | let _: &'static u8 = test(&x, &&3); | -----^^------ | | | diff --git a/tests/ui/inline-const/const-expr-lifetime-err.stderr b/tests/ui/inline-const/const-expr-lifetime-err.stderr index a23f7c9a796..443fcf89c4e 100644 --- a/tests/ui/inline-const/const-expr-lifetime-err.stderr +++ b/tests/ui/inline-const/const-expr-lifetime-err.stderr @@ -4,6 +4,7 @@ error[E0597]: `y` does not live long enough LL | fn foo<'a>() { | -- lifetime `'a` defined here LL | let y = (); + | - binding `y` declared here LL | equate(InvariantRef::new(&y), const { InvariantRef::<'a>::NEW }); | ------------------^^- | | | diff --git a/tests/ui/issues/issue-40288.stderr b/tests/ui/issues/issue-40288.stderr index fb4ecab362d..db5d064379a 100644 --- a/tests/ui/issues/issue-40288.stderr +++ b/tests/ui/issues/issue-40288.stderr @@ -2,10 +2,10 @@ error[E0506]: cannot assign to `*refr` because it is borrowed --> $DIR/issue-40288.rs:16:5 | LL | save_ref(&*refr, &mut out); - | ------ borrow of `*refr` occurs here + | ------ `*refr` is borrowed here ... LL | *refr = 3; - | ^^^^^^^^^ assignment to borrowed `*refr` occurs here + | ^^^^^^^^^ `*refr` is assigned to here but it was already borrowed ... LL | println!("{:?}", out[0]); | ------ borrow later used here diff --git a/tests/ui/issues/issue-45697-1.stderr b/tests/ui/issues/issue-45697-1.stderr index 30c69f19658..474313398e2 100644 --- a/tests/ui/issues/issue-45697-1.stderr +++ b/tests/ui/issues/issue-45697-1.stderr @@ -2,7 +2,7 @@ error[E0503]: cannot use `*y.pointer` because it was mutably borrowed --> $DIR/issue-45697-1.rs:20:9 | LL | let z = copy_borrowed_ptr(&mut y); - | ------ borrow of `y` occurs here + | ------ `y` is borrowed here LL | *y.pointer += 1; | ^^^^^^^^^^^^^^^ use of borrowed `y` ... @@ -13,9 +13,9 @@ error[E0506]: cannot assign to `*y.pointer` because it is borrowed --> $DIR/issue-45697-1.rs:20:9 | LL | let z = copy_borrowed_ptr(&mut y); - | ------ borrow of `*y.pointer` occurs here + | ------ `*y.pointer` is borrowed here LL | *y.pointer += 1; - | ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here + | ^^^^^^^^^^^^^^^ `*y.pointer` is assigned to here but it was already borrowed ... LL | *z.pointer += 1; | --------------- borrow later used here diff --git a/tests/ui/issues/issue-45697.stderr b/tests/ui/issues/issue-45697.stderr index 26749d36f0b..7986fd5c9df 100644 --- a/tests/ui/issues/issue-45697.stderr +++ b/tests/ui/issues/issue-45697.stderr @@ -2,7 +2,7 @@ error[E0503]: cannot use `*y.pointer` because it was mutably borrowed --> $DIR/issue-45697.rs:20:9 | LL | let z = copy_borrowed_ptr(&mut y); - | ------ borrow of `y` occurs here + | ------ `y` is borrowed here LL | *y.pointer += 1; | ^^^^^^^^^^^^^^^ use of borrowed `y` ... @@ -13,9 +13,9 @@ error[E0506]: cannot assign to `*y.pointer` because it is borrowed --> $DIR/issue-45697.rs:20:9 | LL | let z = copy_borrowed_ptr(&mut y); - | ------ borrow of `*y.pointer` occurs here + | ------ `*y.pointer` is borrowed here LL | *y.pointer += 1; - | ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here + | ^^^^^^^^^^^^^^^ `*y.pointer` is assigned to here but it was already borrowed ... LL | *z.pointer += 1; | --------------- borrow later used here diff --git a/tests/ui/issues/issue-46471-1.stderr b/tests/ui/issues/issue-46471-1.stderr index b09f31729a5..2ae6e709d5a 100644 --- a/tests/ui/issues/issue-46471-1.stderr +++ b/tests/ui/issues/issue-46471-1.stderr @@ -1,11 +1,10 @@ error[E0597]: `z` does not live long enough --> $DIR/issue-46471-1.rs:4:9 | +LL | let mut z = 0; + | ----- binding `z` declared here LL | &mut z - | ^^^^^^ - | | - | borrowed value does not live long enough - | borrow later used here + | ^^^^^^ borrowed value does not live long enough LL | }; | - `z` dropped here while still borrowed diff --git a/tests/ui/lifetimes/issue-90600-expected-return-static-indirect.stderr b/tests/ui/lifetimes/issue-90600-expected-return-static-indirect.stderr index 99e1e7217b4..3602de8dd95 100644 --- a/tests/ui/lifetimes/issue-90600-expected-return-static-indirect.stderr +++ b/tests/ui/lifetimes/issue-90600-expected-return-static-indirect.stderr @@ -1,6 +1,8 @@ error[E0597]: `foo` does not live long enough --> $DIR/issue-90600-expected-return-static-indirect.rs:7:32 | +LL | fn inner(mut foo: &[u8]) { + | ------- binding `foo` declared here LL | let refcell = RefCell::new(&mut foo); | ^^^^^^^^ borrowed value does not live long enough LL | diff --git a/tests/ui/mut/mut-pattern-internal-mutability.stderr b/tests/ui/mut/mut-pattern-internal-mutability.stderr index 6583546aa5c..5f2074edb12 100644 --- a/tests/ui/mut/mut-pattern-internal-mutability.stderr +++ b/tests/ui/mut/mut-pattern-internal-mutability.stderr @@ -13,9 +13,9 @@ error[E0506]: cannot assign to `*foo` because it is borrowed --> $DIR/mut-pattern-internal-mutability.rs:13:5 | LL | let &mut ref x = foo; - | ----- borrow of `*foo` occurs here + | ----- `*foo` is borrowed here LL | *foo += 1; - | ^^^^^^^^^ assignment to borrowed `*foo` occurs here + | ^^^^^^^^^ `*foo` is assigned to here but it was already borrowed LL | drop(x); | - borrow later used here diff --git a/tests/ui/nll/borrowed-local-error.stderr b/tests/ui/nll/borrowed-local-error.stderr index d629caa4353..1cca4077d82 100644 --- a/tests/ui/nll/borrowed-local-error.stderr +++ b/tests/ui/nll/borrowed-local-error.stderr @@ -4,6 +4,7 @@ error[E0597]: `v` does not live long enough LL | let x = gimme({ | ----- borrow later used by call LL | let v = (22,); + | - binding `v` declared here LL | &v | ^^ borrowed value does not live long enough LL | diff --git a/tests/ui/nll/borrowed-match-issue-45045.stderr b/tests/ui/nll/borrowed-match-issue-45045.stderr index 9d4682667dd..33e3eb79796 100644 --- a/tests/ui/nll/borrowed-match-issue-45045.stderr +++ b/tests/ui/nll/borrowed-match-issue-45045.stderr @@ -2,7 +2,7 @@ error[E0503]: cannot use `e` because it was mutably borrowed --> $DIR/borrowed-match-issue-45045.rs:12:11 | LL | let f = &mut e; - | ------ borrow of `e` occurs here + | ------ `e` is borrowed here LL | let g = f; LL | match e { | ^ use of borrowed `e` diff --git a/tests/ui/nll/capture-ref-in-struct.stderr b/tests/ui/nll/capture-ref-in-struct.stderr index cdfe7f6db82..84b7ecf2f7d 100644 --- a/tests/ui/nll/capture-ref-in-struct.stderr +++ b/tests/ui/nll/capture-ref-in-struct.stderr @@ -1,6 +1,9 @@ error[E0597]: `y` does not live long enough --> $DIR/capture-ref-in-struct.rs:18:16 | +LL | let y = 22; + | - binding `y` declared here +... LL | y: &y, | ^^ borrowed value does not live long enough ... diff --git a/tests/ui/nll/closure-access-spans.stderr b/tests/ui/nll/closure-access-spans.stderr index 0a09353b8ec..035dd5a5610 100644 --- a/tests/ui/nll/closure-access-spans.stderr +++ b/tests/ui/nll/closure-access-spans.stderr @@ -38,7 +38,7 @@ error[E0503]: cannot use `x` because it was mutably borrowed --> $DIR/closure-access-spans.rs:23:13 | LL | let r = &mut x; - | ------ borrow of `x` occurs here + | ------ `x` is borrowed here LL | move || x; | ^ use of borrowed `x` LL | r.use_ref(); @@ -47,6 +47,8 @@ LL | r.use_ref(); error[E0505]: cannot move out of `x` because it is borrowed --> $DIR/closure-access-spans.rs:29:5 | +LL | fn closure_move_capture_conflict(mut x: String) { + | ----- binding `x` declared here LL | let r = &x; | -- borrow of `x` occurs here LL | || x; diff --git a/tests/ui/nll/closure-borrow-spans.stderr b/tests/ui/nll/closure-borrow-spans.stderr index bada4e1b84b..cf0df5834cc 100644 --- a/tests/ui/nll/closure-borrow-spans.stderr +++ b/tests/ui/nll/closure-borrow-spans.stderr @@ -40,9 +40,9 @@ error[E0506]: cannot assign to `x` because it is borrowed LL | let f = || x; | -- - borrow occurs due to use in closure | | - | borrow of `x` occurs here + | `x` is borrowed here LL | x = 1; - | ^^^^^ assignment to borrowed `x` occurs here + | ^^^^^ `x` is assigned to here but it was already borrowed LL | f.use_ref(); | ----------- borrow later used here @@ -52,7 +52,7 @@ error[E0503]: cannot use `x` because it was mutably borrowed LL | let f = || x = 0; | -- - borrow occurs due to use of `x` in closure | | - | borrow of `x` occurs here + | `x` is borrowed here LL | let y = x; | ^ use of borrowed `x` LL | f.use_ref(); @@ -100,9 +100,9 @@ error[E0506]: cannot assign to `x` because it is borrowed LL | let f = || x = 0; | -- - borrow occurs due to use in closure | | - | borrow of `x` occurs here + | `x` is borrowed here LL | x = 1; - | ^^^^^ assignment to borrowed `x` occurs here + | ^^^^^ `x` is assigned to here but it was already borrowed LL | f.use_ref(); | ----------- borrow later used here @@ -160,9 +160,9 @@ error[E0506]: cannot assign to `*x` because it is borrowed LL | let f = || *x = 0; | -- -- borrow occurs due to use in closure | | - | borrow of `*x` occurs here + | `*x` is borrowed here LL | *x = 1; - | ^^^^^^ assignment to borrowed `*x` occurs here + | ^^^^^^ `*x` is assigned to here but it was already borrowed LL | f.use_ref(); | ----------- borrow later used here diff --git a/tests/ui/nll/closure-requirements/escape-argument.stderr b/tests/ui/nll/closure-requirements/escape-argument.stderr index f67c312b946..5a8462d4dc5 100644 --- a/tests/ui/nll/closure-requirements/escape-argument.stderr +++ b/tests/ui/nll/closure-requirements/escape-argument.stderr @@ -21,6 +21,9 @@ LL | fn test() { error[E0597]: `y` does not live long enough --> $DIR/escape-argument.rs:27:25 | +LL | let y = 22; + | - binding `y` declared here +LL | let mut closure = expect_sig(|p, y| *p = y); LL | closure(&mut p, &y); | ^^ borrowed value does not live long enough LL | diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr index 7991abeb7a8..721cd45ded9 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr +++ b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr @@ -53,6 +53,8 @@ LL | fn case2() { error[E0597]: `a` does not live long enough --> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:30:26 | +LL | let a = 0; + | - binding `a` declared here LL | let cell = Cell::new(&a); | ^^ borrowed value does not live long enough ... diff --git a/tests/ui/nll/closure-use-spans.stderr b/tests/ui/nll/closure-use-spans.stderr index ad928f1bbc9..0e27e5f5f7c 100644 --- a/tests/ui/nll/closure-use-spans.stderr +++ b/tests/ui/nll/closure-use-spans.stderr @@ -2,9 +2,9 @@ error[E0506]: cannot assign to `x` because it is borrowed --> $DIR/closure-use-spans.rs:5:5 | LL | let y = &x; - | -- borrow of `x` occurs here + | -- `x` is borrowed here LL | x = 0; - | ^^^^^ assignment to borrowed `x` occurs here + | ^^^^^ `x` is assigned to here but it was already borrowed LL | || *y; | -- borrow later captured here by closure @@ -12,9 +12,9 @@ error[E0506]: cannot assign to `x` because it is borrowed --> $DIR/closure-use-spans.rs:11:5 | LL | let y = &mut x; - | ------ borrow of `x` occurs here + | ------ `x` is borrowed here LL | x = 0; - | ^^^^^ assignment to borrowed `x` occurs here + | ^^^^^ `x` is assigned to here but it was already borrowed LL | || *y = 1; | -- borrow later captured here by closure @@ -22,9 +22,9 @@ error[E0506]: cannot assign to `x` because it is borrowed --> $DIR/closure-use-spans.rs:17:5 | LL | let y = &x; - | -- borrow of `x` occurs here + | -- `x` is borrowed here LL | x = 0; - | ^^^^^ assignment to borrowed `x` occurs here + | ^^^^^ `x` is assigned to here but it was already borrowed LL | move || *y; | -- borrow later captured here by closure diff --git a/tests/ui/nll/do-not-ignore-lifetime-bounds-in-copy-proj.stderr b/tests/ui/nll/do-not-ignore-lifetime-bounds-in-copy-proj.stderr index 65be3b37e0e..862c925b468 100644 --- a/tests/ui/nll/do-not-ignore-lifetime-bounds-in-copy-proj.stderr +++ b/tests/ui/nll/do-not-ignore-lifetime-bounds-in-copy-proj.stderr @@ -1,6 +1,8 @@ error[E0597]: `s` does not live long enough --> $DIR/do-not-ignore-lifetime-bounds-in-copy-proj.rs:9:18 | +LL | let s = 2; + | - binding `s` declared here LL | let a = (Foo(&s),); | ^^ borrowed value does not live long enough LL | drop(a.0); diff --git a/tests/ui/nll/do-not-ignore-lifetime-bounds-in-copy.stderr b/tests/ui/nll/do-not-ignore-lifetime-bounds-in-copy.stderr index b811ba4fd0c..ebaf6d1244d 100644 --- a/tests/ui/nll/do-not-ignore-lifetime-bounds-in-copy.stderr +++ b/tests/ui/nll/do-not-ignore-lifetime-bounds-in-copy.stderr @@ -1,6 +1,8 @@ error[E0597]: `s` does not live long enough --> $DIR/do-not-ignore-lifetime-bounds-in-copy.rs:8:17 | +LL | let s = 2; + | - binding `s` declared here LL | let a = Foo(&s); | ^^ borrowed value does not live long enough LL | drop(a); diff --git a/tests/ui/nll/dont-print-desugared.stderr b/tests/ui/nll/dont-print-desugared.stderr index fad6121cbca..289b246e663 100644 --- a/tests/ui/nll/dont-print-desugared.stderr +++ b/tests/ui/nll/dont-print-desugared.stderr @@ -10,6 +10,7 @@ error[E0597]: `y` does not live long enough LL | for ref mut d in v { | - a temporary with access to the borrow is created here ... LL | let y = (); + | - binding `y` declared here LL | *d = D(&y); | ^^ borrowed value does not live long enough LL | } diff --git a/tests/ui/nll/drop-no-may-dangle.stderr b/tests/ui/nll/drop-no-may-dangle.stderr index cb280880950..0ddb7adbb38 100644 --- a/tests/ui/nll/drop-no-may-dangle.stderr +++ b/tests/ui/nll/drop-no-may-dangle.stderr @@ -2,10 +2,10 @@ error[E0506]: cannot assign to `v[_]` because it is borrowed --> $DIR/drop-no-may-dangle.rs:18:9 | LL | let p: WrapMayNotDangle<&usize> = WrapMayNotDangle { value: &v[0] }; - | ----- borrow of `v[_]` occurs here + | ----- `v[_]` is borrowed here ... LL | v[0] += 1; - | ^^^^^^^^^ assignment to borrowed `v[_]` occurs here + | ^^^^^^^^^ `v[_]` is assigned to here but it was already borrowed ... LL | } | - borrow might be used here, when `p` is dropped and runs the `Drop` code for type `WrapMayNotDangle` @@ -14,10 +14,10 @@ error[E0506]: cannot assign to `v[_]` because it is borrowed --> $DIR/drop-no-may-dangle.rs:21:5 | LL | let p: WrapMayNotDangle<&usize> = WrapMayNotDangle { value: &v[0] }; - | ----- borrow of `v[_]` occurs here + | ----- `v[_]` is borrowed here ... LL | v[0] += 1; - | ^^^^^^^^^ assignment to borrowed `v[_]` occurs here + | ^^^^^^^^^ `v[_]` is assigned to here but it was already borrowed LL | } | - borrow might be used here, when `p` is dropped and runs the `Drop` code for type `WrapMayNotDangle` diff --git a/tests/ui/nll/guarantor-issue-46974.stderr b/tests/ui/nll/guarantor-issue-46974.stderr index 8854dd8d68c..7edc3dcc5cd 100644 --- a/tests/ui/nll/guarantor-issue-46974.stderr +++ b/tests/ui/nll/guarantor-issue-46974.stderr @@ -2,10 +2,10 @@ error[E0506]: cannot assign to `*s` because it is borrowed --> $DIR/guarantor-issue-46974.rs:7:5 | LL | let t = &mut *s; // this borrow should last for the entire function - | ------- borrow of `*s` occurs here + | ------- `*s` is borrowed here LL | let x = &t.0; LL | *s = (2,); - | ^^^^^^^^^ assignment to borrowed `*s` occurs here + | ^^^^^^^^^ `*s` is assigned to here but it was already borrowed LL | *x | -- borrow later used here diff --git a/tests/ui/nll/issue-27282-move-ref-mut-into-guard.stderr b/tests/ui/nll/issue-27282-move-ref-mut-into-guard.stderr index 45119018d4e..4a512560c87 100644 --- a/tests/ui/nll/issue-27282-move-ref-mut-into-guard.stderr +++ b/tests/ui/nll/issue-27282-move-ref-mut-into-guard.stderr @@ -4,7 +4,7 @@ error[E0507]: cannot move out of `foo` in pattern guard LL | if { (|| { let bar = foo; bar.take() })(); false } => {}, | ^^ --- move occurs because `foo` has type `&mut Option<&i32>`, which does not implement the `Copy` trait | | - | move out of `foo` occurs here + | `foo` is moved here | = note: variables bound in patterns cannot be moved from until after the end of the pattern guard @@ -14,7 +14,7 @@ error[E0507]: cannot move out of `foo` in pattern guard LL | if let Some(()) = { (|| { let bar = foo; bar.take() })(); None } => {}, | ^^ --- move occurs because `foo` has type `&mut Option<&i32>`, which does not implement the `Copy` trait | | - | move out of `foo` occurs here + | `foo` is moved here | = note: variables bound in patterns cannot be moved from until after the end of the pattern guard diff --git a/tests/ui/nll/issue-27282-mutation-in-guard.stderr b/tests/ui/nll/issue-27282-mutation-in-guard.stderr index 1ba696593af..0b5d723172c 100644 --- a/tests/ui/nll/issue-27282-mutation-in-guard.stderr +++ b/tests/ui/nll/issue-27282-mutation-in-guard.stderr @@ -4,7 +4,7 @@ error[E0507]: cannot move out of `foo` in pattern guard LL | (|| { let bar = foo; bar.take() })(); | ^^ --- move occurs because `foo` has type `&mut Option<&i32>`, which does not implement the `Copy` trait | | - | move out of `foo` occurs here + | `foo` is moved here | = note: variables bound in patterns cannot be moved from until after the end of the pattern guard @@ -14,7 +14,7 @@ error[E0507]: cannot move out of `foo` in pattern guard LL | (|| { let bar = foo; bar.take() })(); | ^^ --- move occurs because `foo` has type `&mut Option<&i32>`, which does not implement the `Copy` trait | | - | move out of `foo` occurs here + | `foo` is moved here | = note: variables bound in patterns cannot be moved from until after the end of the pattern guard diff --git a/tests/ui/nll/issue-27868.stderr b/tests/ui/nll/issue-27868.stderr index e0b3b5494d0..204eda3d267 100644 --- a/tests/ui/nll/issue-27868.stderr +++ b/tests/ui/nll/issue-27868.stderr @@ -4,10 +4,10 @@ error[E0506]: cannot assign to `vecvec` because it is borrowed LL | vecvec[0] += { | ------ | | - | _____borrow of `vecvec` occurs here + | _____`vecvec` is borrowed here | | LL | | vecvec = vec![]; - | | ^^^^^^ assignment to borrowed `vecvec` occurs here + | | ^^^^^^ `vecvec` is assigned to here but it was already borrowed LL | | LL | | 0 LL | | }; diff --git a/tests/ui/nll/issue-46036.stderr b/tests/ui/nll/issue-46036.stderr index e6e95ee6136..f337e234550 100644 --- a/tests/ui/nll/issue-46036.stderr +++ b/tests/ui/nll/issue-46036.stderr @@ -1,6 +1,8 @@ error[E0597]: `a` does not live long enough --> $DIR/issue-46036.rs:8:24 | +LL | let a = 3; + | - binding `a` declared here LL | let foo = Foo { x: &a }; | ^^ | | diff --git a/tests/ui/nll/issue-48803.stderr b/tests/ui/nll/issue-48803.stderr index 2f94039c0c3..e24606e0b53 100644 --- a/tests/ui/nll/issue-48803.stderr +++ b/tests/ui/nll/issue-48803.stderr @@ -2,10 +2,10 @@ error[E0506]: cannot assign to `x` because it is borrowed --> $DIR/issue-48803.rs:10:5 | LL | let y = &x; - | -- borrow of `x` occurs here + | -- `x` is borrowed here ... LL | x = "modified"; - | ^^^^^^^^^^^^^^ assignment to borrowed `x` occurs here + | ^^^^^^^^^^^^^^ `x` is assigned to here but it was already borrowed LL | LL | println!("{}", w); // prints "modified" | - borrow later used here diff --git a/tests/ui/nll/issue-52534-2.stderr b/tests/ui/nll/issue-52534-2.stderr index ac385e056b9..35d39bb6e90 100644 --- a/tests/ui/nll/issue-52534-2.stderr +++ b/tests/ui/nll/issue-52534-2.stderr @@ -1,6 +1,8 @@ error[E0597]: `x` does not live long enough --> $DIR/issue-52534-2.rs:6:13 | +LL | let x = 32; + | - binding `x` declared here LL | y = &x | ^^ borrowed value does not live long enough LL | diff --git a/tests/ui/nll/issue-52663-trait-object.stderr b/tests/ui/nll/issue-52663-trait-object.stderr index 5cedea6e665..338f6484132 100644 --- a/tests/ui/nll/issue-52663-trait-object.stderr +++ b/tests/ui/nll/issue-52663-trait-object.stderr @@ -1,6 +1,8 @@ error[E0597]: `tmp0` does not live long enough --> $DIR/issue-52663-trait-object.rs:12:20 | +LL | let tmp0 = 3; + | ---- binding `tmp0` declared here LL | let tmp1 = &tmp0; | ^^^^^ borrowed value does not live long enough LL | Box::new(tmp1) as Box diff --git a/tests/ui/nll/issue-54382-use-span-of-tail-of-block.stderr b/tests/ui/nll/issue-54382-use-span-of-tail-of-block.stderr index d8f43cbc92a..4a32c777a86 100644 --- a/tests/ui/nll/issue-54382-use-span-of-tail-of-block.stderr +++ b/tests/ui/nll/issue-54382-use-span-of-tail-of-block.stderr @@ -1,6 +1,9 @@ error[E0597]: `_thing1` does not live long enough --> $DIR/issue-54382-use-span-of-tail-of-block.rs:7:29 | +LL | let mut _thing1 = D(Box::new("thing1")); + | ----------- binding `_thing1` declared here +... LL | D("other").next(&_thing1) | ----------------^^^^^^^^- | | | diff --git a/tests/ui/nll/issue-54556-stephaneyfx.stderr b/tests/ui/nll/issue-54556-stephaneyfx.stderr index 036a7a0abfd..f9e82cb003f 100644 --- a/tests/ui/nll/issue-54556-stephaneyfx.stderr +++ b/tests/ui/nll/issue-54556-stephaneyfx.stderr @@ -1,6 +1,8 @@ error[E0597]: `stmt` does not live long enough --> $DIR/issue-54556-stephaneyfx.rs:27:21 | +LL | let stmt = Statement; + | ---- binding `stmt` declared here LL | let rows = Rows(&stmt); | ^^^^^ borrowed value does not live long enough LL | rows.map(|row| row).next() diff --git a/tests/ui/nll/issue-54556-temps-in-tail-diagnostic.stderr b/tests/ui/nll/issue-54556-temps-in-tail-diagnostic.stderr index 92f5ffdf388..4eae9fdcde0 100644 --- a/tests/ui/nll/issue-54556-temps-in-tail-diagnostic.stderr +++ b/tests/ui/nll/issue-54556-temps-in-tail-diagnostic.stderr @@ -1,6 +1,9 @@ error[E0597]: `_thing1` does not live long enough --> $DIR/issue-54556-temps-in-tail-diagnostic.rs:5:11 | +LL | let mut _thing1 = D(Box::new("thing1")); + | ----------- binding `_thing1` declared here +LL | // D("other").next(&_thing1).end() LL | D(&_thing1).end() | --^^^^^^^^- | | | diff --git a/tests/ui/nll/issue-54556-used-vs-unused-tails.stderr b/tests/ui/nll/issue-54556-used-vs-unused-tails.stderr index 25226e29673..a2a7a848654 100644 --- a/tests/ui/nll/issue-54556-used-vs-unused-tails.stderr +++ b/tests/ui/nll/issue-54556-used-vs-unused-tails.stderr @@ -2,11 +2,12 @@ error[E0597]: `_t1` does not live long enough --> $DIR/issue-54556-used-vs-unused-tails.rs:10:55 | LL | { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } ; // suggest `;` - | --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` - | | | | - | | | `_t1` dropped here while still borrowed - | | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... + | ------- --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | | | | | + | | | | `_t1` dropped here while still borrowed + | | | borrowed value does not live long enough + | | a temporary with access to the borrow is created here ... + | binding `_t1` declared here | help: consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped | @@ -17,11 +18,12 @@ error[E0597]: `_t1` does not live long enough --> $DIR/issue-54556-used-vs-unused-tails.rs:13:55 | LL | { { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } } ; // suggest `;` - | --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` - | | | | - | | | `_t1` dropped here while still borrowed - | | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... + | ------- --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | | | | | + | | | | `_t1` dropped here while still borrowed + | | | borrowed value does not live long enough + | | a temporary with access to the borrow is created here ... + | binding `_t1` declared here | help: consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped | @@ -32,11 +34,12 @@ error[E0597]: `_t1` does not live long enough --> $DIR/issue-54556-used-vs-unused-tails.rs:16:55 | LL | { { let mut _t1 = D(Box::new("t1")); D(&_t1).end() }; } // suggest `;` - | --^^^^- -- ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` - | | | | - | | | `_t1` dropped here while still borrowed - | | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... + | ------- --^^^^- -- ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | | | | | + | | | | `_t1` dropped here while still borrowed + | | | borrowed value does not live long enough + | | a temporary with access to the borrow is created here ... + | binding `_t1` declared here | help: consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped | @@ -47,11 +50,12 @@ error[E0597]: `_t1` does not live long enough --> $DIR/issue-54556-used-vs-unused-tails.rs:19:55 | LL | let _ = { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } ; // suggest `;` - | --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` - | | | | - | | | `_t1` dropped here while still borrowed - | | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... + | ------- --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | | | | | + | | | | `_t1` dropped here while still borrowed + | | | borrowed value does not live long enough + | | a temporary with access to the borrow is created here ... + | binding `_t1` declared here | help: consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped | @@ -62,11 +66,12 @@ error[E0597]: `_t1` does not live long enough --> $DIR/issue-54556-used-vs-unused-tails.rs:22:55 | LL | let _u = { let mut _t1 = D(Box::new("t1")); D(&_t1).unit() } ; // suggest `;` - | --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` - | | | | - | | | `_t1` dropped here while still borrowed - | | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... + | ------- --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | | | | | + | | | | `_t1` dropped here while still borrowed + | | | borrowed value does not live long enough + | | a temporary with access to the borrow is created here ... + | binding `_t1` declared here | help: consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped | @@ -77,11 +82,12 @@ error[E0597]: `_t1` does not live long enough --> $DIR/issue-54556-used-vs-unused-tails.rs:25:55 | LL | let _x = { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } ; // `let x = ...; x` - | --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` - | | | | - | | | `_t1` dropped here while still borrowed - | | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... + | ------- --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | | | | | + | | | | `_t1` dropped here while still borrowed + | | | borrowed value does not live long enough + | | a temporary with access to the borrow is created here ... + | binding `_t1` declared here | = note: the temporary is part of an expression at the end of a block; consider forcing this temporary to be dropped sooner, before the block's local variables are dropped @@ -94,11 +100,12 @@ error[E0597]: `_t1` does not live long enough --> $DIR/issue-54556-used-vs-unused-tails.rs:30:55 | LL | _y = { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } ; // `let x = ...; x` - | --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` - | | | | - | | | `_t1` dropped here while still borrowed - | | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... + | ------- --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | | | | | + | | | | `_t1` dropped here while still borrowed + | | | borrowed value does not live long enough + | | a temporary with access to the borrow is created here ... + | binding `_t1` declared here | = note: the temporary is part of an expression at the end of a block; consider forcing this temporary to be dropped sooner, before the block's local variables are dropped @@ -111,12 +118,13 @@ error[E0597]: `_t1` does not live long enough --> $DIR/issue-54556-used-vs-unused-tails.rs:37:55 | LL | fn f_local_ref() { let mut _t1 = D(Box::new("t1")); D(&_t1).unit() } // suggest `;` - | --^^^^- - - | | | | - | | | `_t1` dropped here while still borrowed - | | | ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` - | | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... + | ------- --^^^^- - + | | | | | + | | | | `_t1` dropped here while still borrowed + | | | | ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | | | borrowed value does not live long enough + | | a temporary with access to the borrow is created here ... + | binding `_t1` declared here | help: consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped | @@ -127,12 +135,13 @@ error[E0597]: `_t1` does not live long enough --> $DIR/issue-54556-used-vs-unused-tails.rs:40:55 | LL | fn f() -> String { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } // `let x = ...; x` - | --^^^^- - - | | | | - | | | `_t1` dropped here while still borrowed - | | | ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` - | | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... + | ------- --^^^^- - + | | | | | + | | | | `_t1` dropped here while still borrowed + | | | | ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | | | borrowed value does not live long enough + | | a temporary with access to the borrow is created here ... + | binding `_t1` declared here | = note: the temporary is part of an expression at the end of a block; consider forcing this temporary to be dropped sooner, before the block's local variables are dropped diff --git a/tests/ui/nll/issue-54556-wrap-it-up.stderr b/tests/ui/nll/issue-54556-wrap-it-up.stderr index 9f27fac15a7..adc419ae515 100644 --- a/tests/ui/nll/issue-54556-wrap-it-up.stderr +++ b/tests/ui/nll/issue-54556-wrap-it-up.stderr @@ -2,10 +2,10 @@ error[E0506]: cannot assign to `x` because it is borrowed --> $DIR/issue-54556-wrap-it-up.rs:27:5 | LL | let wrap = Wrap { p: &mut x }; - | ------ borrow of `x` occurs here + | ------ `x` is borrowed here ... LL | x = 1; - | ^^^^^ assignment to borrowed `x` occurs here + | ^^^^^ `x` is assigned to here but it was already borrowed LL | } | - borrow might be used here, when `foo` is dropped and runs the destructor for type `Foo<'_>` diff --git a/tests/ui/nll/issue-55511.stderr b/tests/ui/nll/issue-55511.stderr index bf3e58e8cdb..ecb9ef0aef9 100644 --- a/tests/ui/nll/issue-55511.stderr +++ b/tests/ui/nll/issue-55511.stderr @@ -1,6 +1,8 @@ error[E0597]: `a` does not live long enough --> $DIR/issue-55511.rs:13:28 | +LL | let a = 22; + | - binding `a` declared here LL | let b = Some(Cell::new(&a)); | ^^ borrowed value does not live long enough ... diff --git a/tests/ui/nll/issue-57989.stderr b/tests/ui/nll/issue-57989.stderr index 31f40d8252e..d5effd6f346 100644 --- a/tests/ui/nll/issue-57989.stderr +++ b/tests/ui/nll/issue-57989.stderr @@ -13,9 +13,9 @@ error[E0506]: cannot assign to `*x` because it is borrowed --> $DIR/issue-57989.rs:5:5 | LL | let g = &x; - | -- borrow of `*x` occurs here + | -- `*x` is borrowed here LL | *x = 0; - | ^^^^^^ assignment to borrowed `*x` occurs here + | ^^^^^^ `*x` is assigned to here but it was already borrowed LL | LL | g; | - borrow later used here diff --git a/tests/ui/nll/issue-68550.stderr b/tests/ui/nll/issue-68550.stderr index e234ebb04e1..851e3628748 100644 --- a/tests/ui/nll/issue-68550.stderr +++ b/tests/ui/nll/issue-68550.stderr @@ -2,7 +2,9 @@ error[E0597]: `x` does not live long enough --> $DIR/issue-68550.rs:12:20 | LL | fn run<'a, A>(x: A) - | -- lifetime `'a` defined here + | -- - binding `x` declared here + | | + | lifetime `'a` defined here ... LL | let _: &'a A = &x; | ----- ^^ borrowed value does not live long enough diff --git a/tests/ui/nll/issue-69114-static-mut-ty.stderr b/tests/ui/nll/issue-69114-static-mut-ty.stderr index 5e55cb502ca..1b41230d7ba 100644 --- a/tests/ui/nll/issue-69114-static-mut-ty.stderr +++ b/tests/ui/nll/issue-69114-static-mut-ty.stderr @@ -1,6 +1,9 @@ error[E0597]: `n` does not live long enough --> $DIR/issue-69114-static-mut-ty.rs:19:15 | +LL | let n = 42; + | - binding `n` declared here +LL | unsafe { LL | BAR = &n; | ------^^ | | | @@ -13,6 +16,9 @@ LL | } error[E0597]: `n` does not live long enough --> $DIR/issue-69114-static-mut-ty.rs:27:22 | +LL | let n = 42; + | - binding `n` declared here +LL | unsafe { LL | BAR_ELIDED = &n; | -------------^^ | | | diff --git a/tests/ui/nll/issue-69114-static-ty.stderr b/tests/ui/nll/issue-69114-static-ty.stderr index 0815e74b553..9215e850f7d 100644 --- a/tests/ui/nll/issue-69114-static-ty.stderr +++ b/tests/ui/nll/issue-69114-static-ty.stderr @@ -1,6 +1,8 @@ error[E0597]: `n` does not live long enough --> $DIR/issue-69114-static-ty.rs:7:9 | +LL | let n = 42; + | - binding `n` declared here LL | FOO(&n); | ----^^- | | | diff --git a/tests/ui/nll/loan_ends_mid_block_pair.stderr b/tests/ui/nll/loan_ends_mid_block_pair.stderr index eb8442b31d7..58e378ab021 100644 --- a/tests/ui/nll/loan_ends_mid_block_pair.stderr +++ b/tests/ui/nll/loan_ends_mid_block_pair.stderr @@ -2,10 +2,10 @@ error[E0506]: cannot assign to `data.0` because it is borrowed --> $DIR/loan_ends_mid_block_pair.rs:12:5 | LL | let c = &mut data.0; - | ----------- borrow of `data.0` occurs here + | ----------- `data.0` is borrowed here LL | capitalize(c); LL | data.0 = 'e'; - | ^^^^^^^^^^^^ assignment to borrowed `data.0` occurs here + | ^^^^^^^^^^^^ `data.0` is assigned to here but it was already borrowed ... LL | capitalize(c); | - borrow later used here diff --git a/tests/ui/nll/local-outlives-static-via-hrtb.stderr b/tests/ui/nll/local-outlives-static-via-hrtb.stderr index f5c10f3ddea..a6b3328b5a2 100644 --- a/tests/ui/nll/local-outlives-static-via-hrtb.stderr +++ b/tests/ui/nll/local-outlives-static-via-hrtb.stderr @@ -1,6 +1,8 @@ error[E0597]: `local` does not live long enough --> $DIR/local-outlives-static-via-hrtb.rs:24:28 | +LL | let local = 0; + | ----- binding `local` declared here LL | assert_static_via_hrtb(&local); | -----------------------^^^^^^- | | | @@ -19,6 +21,9 @@ LL | fn assert_static_via_hrtb(_: G) where for<'a> G: Outlives<'a> {} error[E0597]: `local` does not live long enough --> $DIR/local-outlives-static-via-hrtb.rs:25:45 | +LL | let local = 0; + | ----- binding `local` declared here +LL | assert_static_via_hrtb(&local); LL | assert_static_via_hrtb_with_assoc_type(&&local); | ----------------------------------------^^^^^^- | | | diff --git a/tests/ui/nll/match-cfg-fake-edges2.stderr b/tests/ui/nll/match-cfg-fake-edges2.stderr index c6d15a936d8..36f2cd0b85d 100644 --- a/tests/ui/nll/match-cfg-fake-edges2.stderr +++ b/tests/ui/nll/match-cfg-fake-edges2.stderr @@ -2,7 +2,7 @@ error[E0503]: cannot use `y.1` because it was mutably borrowed --> $DIR/match-cfg-fake-edges2.rs:8:5 | LL | let r = &mut y.1; - | -------- borrow of `y.1` occurs here + | -------- `y.1` is borrowed here ... LL | match y { | ^^^^^^^ use of borrowed `y.1` diff --git a/tests/ui/nll/match-guards-always-borrow.stderr b/tests/ui/nll/match-guards-always-borrow.stderr index fa01d3a6fd1..afd853c403e 100644 --- a/tests/ui/nll/match-guards-always-borrow.stderr +++ b/tests/ui/nll/match-guards-always-borrow.stderr @@ -4,7 +4,7 @@ error[E0507]: cannot move out of `foo` in pattern guard LL | (|| { let bar = foo; bar.take() })(); | ^^ --- move occurs because `foo` has type `&mut Option<&i32>`, which does not implement the `Copy` trait | | - | move out of `foo` occurs here + | `foo` is moved here | = note: variables bound in patterns cannot be moved from until after the end of the pattern guard @@ -14,7 +14,7 @@ error[E0507]: cannot move out of `foo` in pattern guard LL | (|| { let bar = foo; bar.take() })(); | ^^ --- move occurs because `foo` has type `&mut Option<&i32>`, which does not implement the `Copy` trait | | - | move out of `foo` occurs here + | `foo` is moved here | = note: variables bound in patterns cannot be moved from until after the end of the pattern guard diff --git a/tests/ui/nll/match-guards-partially-borrow.stderr b/tests/ui/nll/match-guards-partially-borrow.stderr index 60b8dee71a8..7bdcbcb9c6e 100644 --- a/tests/ui/nll/match-guards-partially-borrow.stderr +++ b/tests/ui/nll/match-guards-partially-borrow.stderr @@ -74,9 +74,9 @@ error[E0506]: cannot assign to `t` because it is borrowed --> $DIR/match-guards-partially-borrow.rs:225:13 | LL | s if { - | - borrow of `t` occurs here + | - `t` is borrowed here LL | t = !t; - | ^^^^^^ assignment to borrowed `t` occurs here + | ^^^^^^ `t` is assigned to here but it was already borrowed LL | false LL | } => (), // What value should `s` have in the arm? | - borrow later used here @@ -85,9 +85,9 @@ error[E0506]: cannot assign to `t` because it is borrowed --> $DIR/match-guards-partially-borrow.rs:235:13 | LL | s if let Some(()) = { - | - borrow of `t` occurs here + | - `t` is borrowed here LL | t = !t; - | ^^^^^^ assignment to borrowed `t` occurs here + | ^^^^^^ `t` is assigned to here but it was already borrowed LL | None LL | } => (), // What value should `s` have in the arm? | - borrow later used here diff --git a/tests/ui/nll/match-on-borrowed.stderr b/tests/ui/nll/match-on-borrowed.stderr index 32666529f3f..9273484565a 100644 --- a/tests/ui/nll/match-on-borrowed.stderr +++ b/tests/ui/nll/match-on-borrowed.stderr @@ -2,7 +2,7 @@ error[E0503]: cannot use `e` because it was mutably borrowed --> $DIR/match-on-borrowed.rs:47:11 | LL | E::V(ref mut x, _) => x, - | --------- borrow of `e.0` occurs here + | --------- `e.0` is borrowed here ... LL | match e { // Don't know that E uses a tag for its discriminant | ^ use of borrowed `e.0` @@ -14,7 +14,7 @@ error[E0503]: cannot use `*f` because it was mutably borrowed --> $DIR/match-on-borrowed.rs:61:11 | LL | E::V(ref mut x, _) => x, - | --------- borrow of `f.0` occurs here + | --------- `f.0` is borrowed here ... LL | match f { // Don't know that E uses a tag for its discriminant | ^ use of borrowed `f.0` @@ -26,7 +26,7 @@ error[E0503]: cannot use `t` because it was mutably borrowed --> $DIR/match-on-borrowed.rs:81:5 | LL | let x = &mut t; - | ------ borrow of `t` occurs here + | ------ `t` is borrowed here LL | match t { | ^^^^^^^ use of borrowed `t` ... diff --git a/tests/ui/nll/maybe-initialized-drop-implicit-fragment-drop.stderr b/tests/ui/nll/maybe-initialized-drop-implicit-fragment-drop.stderr index 80e29780746..55646b9dca9 100644 --- a/tests/ui/nll/maybe-initialized-drop-implicit-fragment-drop.stderr +++ b/tests/ui/nll/maybe-initialized-drop-implicit-fragment-drop.stderr @@ -2,10 +2,10 @@ error[E0506]: cannot assign to `x` because it is borrowed --> $DIR/maybe-initialized-drop-implicit-fragment-drop.rs:17:5 | LL | let wrap = Wrap { p: &mut x }; - | ------ borrow of `x` occurs here + | ------ `x` is borrowed here ... LL | x = 1; - | ^^^^^ assignment to borrowed `x` occurs here + | ^^^^^ `x` is assigned to here but it was already borrowed LL | // FIXME ^ Should not error in the future with implicit dtors, only manually implemented ones LL | } | - borrow might be used here, when `foo` is dropped and runs the destructor for type `Foo<'_>` diff --git a/tests/ui/nll/maybe-initialized-drop-with-fragment.stderr b/tests/ui/nll/maybe-initialized-drop-with-fragment.stderr index 14074472eaf..c89f94a7894 100644 --- a/tests/ui/nll/maybe-initialized-drop-with-fragment.stderr +++ b/tests/ui/nll/maybe-initialized-drop-with-fragment.stderr @@ -2,10 +2,10 @@ error[E0506]: cannot assign to `x` because it is borrowed --> $DIR/maybe-initialized-drop-with-fragment.rs:19:5 | LL | let wrap = Wrap { p: &mut x }; - | ------ borrow of `x` occurs here + | ------ `x` is borrowed here ... LL | x = 1; - | ^^^^^ assignment to borrowed `x` occurs here + | ^^^^^ `x` is assigned to here but it was already borrowed LL | } | - borrow might be used here, when `foo` is dropped and runs the destructor for type `Foo<'_>` diff --git a/tests/ui/nll/maybe-initialized-drop-with-uninitialized-fragments.stderr b/tests/ui/nll/maybe-initialized-drop-with-uninitialized-fragments.stderr index 91c0afc1dba..90db13bc578 100644 --- a/tests/ui/nll/maybe-initialized-drop-with-uninitialized-fragments.stderr +++ b/tests/ui/nll/maybe-initialized-drop-with-uninitialized-fragments.stderr @@ -2,10 +2,10 @@ error[E0506]: cannot assign to `x` because it is borrowed --> $DIR/maybe-initialized-drop-with-uninitialized-fragments.rs:20:5 | LL | let wrap = Wrap { p: &mut x }; - | ------ borrow of `x` occurs here + | ------ `x` is borrowed here ... LL | x = 1; - | ^^^^^ assignment to borrowed `x` occurs here + | ^^^^^ `x` is assigned to here but it was already borrowed LL | // FIXME ^ This currently errors and it should not. LL | } | - borrow might be used here, when `foo` is dropped and runs the destructor for type `Foo<'_>` diff --git a/tests/ui/nll/maybe-initialized-drop.stderr b/tests/ui/nll/maybe-initialized-drop.stderr index 9825ba4611b..15a53a09af8 100644 --- a/tests/ui/nll/maybe-initialized-drop.stderr +++ b/tests/ui/nll/maybe-initialized-drop.stderr @@ -2,9 +2,9 @@ error[E0506]: cannot assign to `x` because it is borrowed --> $DIR/maybe-initialized-drop.rs:14:5 | LL | let wrap = Wrap { p: &mut x }; - | ------ borrow of `x` occurs here + | ------ `x` is borrowed here LL | x = 1; - | ^^^^^ assignment to borrowed `x` occurs here + | ^^^^^ `x` is assigned to here but it was already borrowed LL | } | - borrow might be used here, when `wrap` is dropped and runs the `Drop` code for type `Wrap` diff --git a/tests/ui/nll/polonius/polonius-smoke-test.stderr b/tests/ui/nll/polonius/polonius-smoke-test.stderr index fa1a6a9c957..789d202f73a 100644 --- a/tests/ui/nll/polonius/polonius-smoke-test.stderr +++ b/tests/ui/nll/polonius/polonius-smoke-test.stderr @@ -8,7 +8,7 @@ error[E0503]: cannot use `x` because it was mutably borrowed --> $DIR/polonius-smoke-test.rs:12:13 | LL | let y = &mut x; - | ------ borrow of `x` occurs here + | ------ `x` is borrowed here LL | let z = x; | ^ use of borrowed `x` LL | let w = y; diff --git a/tests/ui/nll/promoted-bounds.stderr b/tests/ui/nll/promoted-bounds.stderr index df347f4e7f0..d111256b845 100644 --- a/tests/ui/nll/promoted-bounds.stderr +++ b/tests/ui/nll/promoted-bounds.stderr @@ -4,6 +4,7 @@ error[E0597]: `l` does not live long enough LL | let ptr = { | --- borrow later stored here LL | let l = 3; + | - binding `l` declared here LL | let b = &l; | ^^ borrowed value does not live long enough ... diff --git a/tests/ui/nll/reference-carried-through-struct-field.stderr b/tests/ui/nll/reference-carried-through-struct-field.stderr index 56d878e4303..5672b9cd7e9 100644 --- a/tests/ui/nll/reference-carried-through-struct-field.stderr +++ b/tests/ui/nll/reference-carried-through-struct-field.stderr @@ -2,7 +2,7 @@ error[E0503]: cannot use `x` because it was mutably borrowed --> $DIR/reference-carried-through-struct-field.rs:6:5 | LL | let wrapper = Wrap { w: &mut x }; - | ------ borrow of `x` occurs here + | ------ `x` is borrowed here LL | x += 1; | ^^^^^^ use of borrowed `x` LL | *wrapper.w += 1; diff --git a/tests/ui/nll/relate_tys/var-appears-twice.stderr b/tests/ui/nll/relate_tys/var-appears-twice.stderr index d032ce6f213..ff6ea598ff4 100644 --- a/tests/ui/nll/relate_tys/var-appears-twice.stderr +++ b/tests/ui/nll/relate_tys/var-appears-twice.stderr @@ -1,6 +1,9 @@ error[E0597]: `b` does not live long enough --> $DIR/var-appears-twice.rs:20:38 | +LL | let b = 44; + | - binding `b` declared here +... LL | let x: DoubleCell<_> = make_cell(&b); | ------------- ^^ borrowed value does not live long enough | | diff --git a/tests/ui/nll/user-annotations/adt-brace-enums.stderr b/tests/ui/nll/user-annotations/adt-brace-enums.stderr index 253e3825110..9e94fd5a782 100644 --- a/tests/ui/nll/user-annotations/adt-brace-enums.stderr +++ b/tests/ui/nll/user-annotations/adt-brace-enums.stderr @@ -1,6 +1,8 @@ error[E0597]: `c` does not live long enough --> $DIR/adt-brace-enums.rs:25:48 | +LL | let c = 66; + | - binding `c` declared here LL | SomeEnum::SomeVariant::<&'static u32> { t: &c }; | ^^ | | @@ -15,6 +17,7 @@ error[E0597]: `c` does not live long enough LL | fn annot_reference_named_lifetime<'a>(_d: &'a u32) { | -- lifetime `'a` defined here LL | let c = 66; + | - binding `c` declared here LL | SomeEnum::SomeVariant::<&'a u32> { t: &c }; | ^^ | | diff --git a/tests/ui/nll/user-annotations/adt-brace-structs.stderr b/tests/ui/nll/user-annotations/adt-brace-structs.stderr index 8b9d1705df6..cbb7f6a55a9 100644 --- a/tests/ui/nll/user-annotations/adt-brace-structs.stderr +++ b/tests/ui/nll/user-annotations/adt-brace-structs.stderr @@ -1,6 +1,8 @@ error[E0597]: `c` does not live long enough --> $DIR/adt-brace-structs.rs:23:37 | +LL | let c = 66; + | - binding `c` declared here LL | SomeStruct::<&'static u32> { t: &c }; | ^^ | | @@ -15,6 +17,7 @@ error[E0597]: `c` does not live long enough LL | fn annot_reference_named_lifetime<'a>(_d: &'a u32) { | -- lifetime `'a` defined here LL | let c = 66; + | - binding `c` declared here LL | SomeStruct::<&'a u32> { t: &c }; | ^^ | | diff --git a/tests/ui/nll/user-annotations/adt-nullary-enums.stderr b/tests/ui/nll/user-annotations/adt-nullary-enums.stderr index 3326fa521fc..bca85a90d19 100644 --- a/tests/ui/nll/user-annotations/adt-nullary-enums.stderr +++ b/tests/ui/nll/user-annotations/adt-nullary-enums.stderr @@ -1,6 +1,8 @@ error[E0597]: `c` does not live long enough --> $DIR/adt-nullary-enums.rs:33:41 | +LL | let c = 66; + | - binding `c` declared here LL | / combine( LL | | SomeEnum::SomeVariant(Cell::new(&c)), | | ^^ borrowed value does not live long enough @@ -15,7 +17,9 @@ error[E0597]: `c` does not live long enough | LL | fn annot_reference_named_lifetime<'a>(_d: &'a u32) { | -- lifetime `'a` defined here -... +LL | let c = 66; + | - binding `c` declared here +LL | combine( LL | SomeEnum::SomeVariant(Cell::new(&c)), | ----------^^- | | | diff --git a/tests/ui/nll/user-annotations/adt-tuple-enums.stderr b/tests/ui/nll/user-annotations/adt-tuple-enums.stderr index 2fa7042631d..d2d85ec2b9b 100644 --- a/tests/ui/nll/user-annotations/adt-tuple-enums.stderr +++ b/tests/ui/nll/user-annotations/adt-tuple-enums.stderr @@ -1,6 +1,8 @@ error[E0597]: `c` does not live long enough --> $DIR/adt-tuple-enums.rs:28:43 | +LL | let c = 66; + | - binding `c` declared here LL | SomeEnum::SomeVariant::<&'static u32>(&c); | ^^ | | @@ -15,6 +17,7 @@ error[E0597]: `c` does not live long enough LL | fn annot_reference_named_lifetime<'a>(_d: &'a u32) { | -- lifetime `'a` defined here LL | let c = 66; + | - binding `c` declared here LL | SomeEnum::SomeVariant::<&'a u32>(&c); | ^^ | | diff --git a/tests/ui/nll/user-annotations/adt-tuple-struct-calls.stderr b/tests/ui/nll/user-annotations/adt-tuple-struct-calls.stderr index 9664fb9f548..b7bc2a10b70 100644 --- a/tests/ui/nll/user-annotations/adt-tuple-struct-calls.stderr +++ b/tests/ui/nll/user-annotations/adt-tuple-struct-calls.stderr @@ -1,6 +1,9 @@ error[E0597]: `c` does not live long enough --> $DIR/adt-tuple-struct-calls.rs:27:7 | +LL | let c = 66; + | - binding `c` declared here +LL | let f = SomeStruct::<&'static u32>; LL | f(&c); | --^^- | | | @@ -14,7 +17,9 @@ error[E0597]: `c` does not live long enough | LL | fn annot_reference_named_lifetime<'a>(_d: &'a u32) { | -- lifetime `'a` defined here -... +LL | let c = 66; + | - binding `c` declared here +LL | let f = SomeStruct::<&'a u32>; LL | f(&c); | --^^- | | | diff --git a/tests/ui/nll/user-annotations/adt-tuple-struct.stderr b/tests/ui/nll/user-annotations/adt-tuple-struct.stderr index 76b5252258c..97d39da265f 100644 --- a/tests/ui/nll/user-annotations/adt-tuple-struct.stderr +++ b/tests/ui/nll/user-annotations/adt-tuple-struct.stderr @@ -1,6 +1,8 @@ error[E0597]: `c` does not live long enough --> $DIR/adt-tuple-struct.rs:23:32 | +LL | let c = 66; + | - binding `c` declared here LL | SomeStruct::<&'static u32>(&c); | ^^ | | @@ -15,6 +17,7 @@ error[E0597]: `c` does not live long enough LL | fn annot_reference_named_lifetime<'a>(_d: &'a u32) { | -- lifetime `'a` defined here LL | let c = 66; + | - binding `c` declared here LL | SomeStruct::<&'a u32>(&c); | ^^ | | diff --git a/tests/ui/nll/user-annotations/cast_static_lifetime.stderr b/tests/ui/nll/user-annotations/cast_static_lifetime.stderr index 4599d04e7e2..3b9363c41f2 100644 --- a/tests/ui/nll/user-annotations/cast_static_lifetime.stderr +++ b/tests/ui/nll/user-annotations/cast_static_lifetime.stderr @@ -1,6 +1,8 @@ error[E0597]: `x` does not live long enough --> $DIR/cast_static_lifetime.rs:5:19 | +LL | let x = 22_u32; + | - binding `x` declared here LL | let y: &u32 = (&x) as &'static u32; | ^^^^---------------- | | diff --git a/tests/ui/nll/user-annotations/constant-in-expr-inherent-2.stderr b/tests/ui/nll/user-annotations/constant-in-expr-inherent-2.stderr index 12065a85aa4..f164255ef30 100644 --- a/tests/ui/nll/user-annotations/constant-in-expr-inherent-2.stderr +++ b/tests/ui/nll/user-annotations/constant-in-expr-inherent-2.stderr @@ -1,6 +1,8 @@ error[E0597]: `x` does not live long enough --> $DIR/constant-in-expr-inherent-2.rs:23:9 | +LL | let x = (); + | - binding `x` declared here LL | FUN(&x); | ----^^- | | | @@ -13,6 +15,9 @@ LL | } error[E0597]: `x` does not live long enough --> $DIR/constant-in-expr-inherent-2.rs:24:23 | +LL | let x = (); + | - binding `x` declared here +LL | FUN(&x); LL | A::ASSOCIATED_FUN(&x); | ------------------^^- | | | @@ -25,6 +30,9 @@ LL | } error[E0597]: `x` does not live long enough --> $DIR/constant-in-expr-inherent-2.rs:25:28 | +LL | let x = (); + | - binding `x` declared here +... LL | B::ALSO_ASSOCIATED_FUN(&x); | -----------------------^^- | | | @@ -37,6 +45,9 @@ LL | } error[E0597]: `x` does not live long enough --> $DIR/constant-in-expr-inherent-2.rs:26:31 | +LL | let x = (); + | - binding `x` declared here +... LL | <_>::TRAIT_ASSOCIATED_FUN(&x); | --------------------------^^- | | | diff --git a/tests/ui/nll/user-annotations/fns.stderr b/tests/ui/nll/user-annotations/fns.stderr index e0640da39e2..8b53e138d9b 100644 --- a/tests/ui/nll/user-annotations/fns.stderr +++ b/tests/ui/nll/user-annotations/fns.stderr @@ -1,6 +1,8 @@ error[E0597]: `c` does not live long enough --> $DIR/fns.rs:23:29 | +LL | let c = 66; + | - binding `c` declared here LL | some_fn::<&'static u32>(&c); | ------------------------^^- | | | @@ -15,6 +17,7 @@ error[E0597]: `c` does not live long enough LL | fn annot_reference_named_lifetime<'a>(_d: &'a u32) { | -- lifetime `'a` defined here LL | let c = 66; + | - binding `c` declared here LL | some_fn::<&'a u32>(&c); | -------------------^^- | | | diff --git a/tests/ui/nll/user-annotations/method-call.stderr b/tests/ui/nll/user-annotations/method-call.stderr index 10447e45a6d..3803cbf776b 100644 --- a/tests/ui/nll/user-annotations/method-call.stderr +++ b/tests/ui/nll/user-annotations/method-call.stderr @@ -1,6 +1,8 @@ error[E0597]: `c` does not live long enough --> $DIR/method-call.rs:36:34 | +LL | let c = 66; + | - binding `c` declared here LL | a.method::<&'static u32>(b, &c); | -----------------------------^^- | | | @@ -15,6 +17,8 @@ error[E0597]: `c` does not live long enough LL | fn annot_reference_named_lifetime<'a>(_d: &'a u32) { | -- lifetime `'a` defined here ... +LL | let c = 66; + | - binding `c` declared here LL | a.method::<&'a u32>(b, &c); | ------------------------^^- | | | diff --git a/tests/ui/nll/user-annotations/method-ufcs-1.stderr b/tests/ui/nll/user-annotations/method-ufcs-1.stderr index 962ddfd2bd1..c7c08c948ab 100644 --- a/tests/ui/nll/user-annotations/method-ufcs-1.stderr +++ b/tests/ui/nll/user-annotations/method-ufcs-1.stderr @@ -1,6 +1,9 @@ error[E0597]: `a` does not live long enough --> $DIR/method-ufcs-1.rs:30:7 | +LL | let a = 22; + | - binding `a` declared here +... LL | x(&a, b, c); | --^^------- | | | @@ -14,6 +17,8 @@ error[E0597]: `a` does not live long enough | LL | fn annot_reference_named_lifetime<'a>(_d: &'a u32) { | -- lifetime `'a` defined here +LL | let a = 22; + | - binding `a` declared here ... LL | <&'a u32 as Bazoom<_>>::method(&a, b, c); | -------------------------------^^------- diff --git a/tests/ui/nll/user-annotations/method-ufcs-2.stderr b/tests/ui/nll/user-annotations/method-ufcs-2.stderr index 63d59905e1c..b7861a3bd06 100644 --- a/tests/ui/nll/user-annotations/method-ufcs-2.stderr +++ b/tests/ui/nll/user-annotations/method-ufcs-2.stderr @@ -1,6 +1,9 @@ error[E0597]: `a` does not live long enough --> $DIR/method-ufcs-2.rs:30:7 | +LL | let a = 22; + | - binding `a` declared here +... LL | x(&a, b, c); | --^^------- | | | @@ -14,7 +17,10 @@ error[E0597]: `b` does not live long enough | LL | fn annot_reference_named_lifetime<'a>(_d: &'a u32) { | -- lifetime `'a` defined here -... +LL | let a = 22; +LL | let b = 44; + | - binding `b` declared here +LL | let c = 66; LL | <_ as Bazoom<&'a u32>>::method(a, &b, c); | ----------------------------------^^---- | | | diff --git a/tests/ui/nll/user-annotations/method-ufcs-3.stderr b/tests/ui/nll/user-annotations/method-ufcs-3.stderr index e7851833e93..8cb995a03ce 100644 --- a/tests/ui/nll/user-annotations/method-ufcs-3.stderr +++ b/tests/ui/nll/user-annotations/method-ufcs-3.stderr @@ -1,6 +1,8 @@ error[E0597]: `c` does not live long enough --> $DIR/method-ufcs-3.rs:36:53 | +LL | let c = 66; + | - binding `c` declared here LL | <_ as Bazoom<_>>::method::<&'static u32>(&a, b, &c); | ------------------------------------------------^^- | | | @@ -15,6 +17,8 @@ error[E0597]: `c` does not live long enough LL | fn annot_reference_named_lifetime<'a>(_d: &'a u32) { | -- lifetime `'a` defined here ... +LL | let c = 66; + | - binding `c` declared here LL | <_ as Bazoom<_>>::method::<&'a u32>(&a, b, &c); | -------------------------------------------^^- | | | diff --git a/tests/ui/nll/user-annotations/method-ufcs-inherent-1.stderr b/tests/ui/nll/user-annotations/method-ufcs-inherent-1.stderr index 94861babd6f..fb26b8d09e1 100644 --- a/tests/ui/nll/user-annotations/method-ufcs-inherent-1.stderr +++ b/tests/ui/nll/user-annotations/method-ufcs-inherent-1.stderr @@ -4,6 +4,7 @@ error[E0597]: `v` does not live long enough LL | fn foo<'a>() { | -- lifetime `'a` defined here LL | let v = 22; + | - binding `v` declared here LL | let x = A::<'a>::new(&v, 22); | -------------^^----- | | | diff --git a/tests/ui/nll/user-annotations/method-ufcs-inherent-2.stderr b/tests/ui/nll/user-annotations/method-ufcs-inherent-2.stderr index 06f20d9b235..03b97447e1a 100644 --- a/tests/ui/nll/user-annotations/method-ufcs-inherent-2.stderr +++ b/tests/ui/nll/user-annotations/method-ufcs-inherent-2.stderr @@ -4,6 +4,7 @@ error[E0597]: `v` does not live long enough LL | fn foo<'a>() { | -- lifetime `'a` defined here LL | let v = 22; + | - binding `v` declared here LL | let x = A::<'a>::new::<&'a u32>(&v, &v); | ------------------------^^----- | | | @@ -19,6 +20,7 @@ error[E0597]: `v` does not live long enough LL | fn foo<'a>() { | -- lifetime `'a` defined here LL | let v = 22; + | - binding `v` declared here LL | let x = A::<'a>::new::<&'a u32>(&v, &v); | ----------------------------^^- | | | diff --git a/tests/ui/nll/user-annotations/method-ufcs-inherent-3.stderr b/tests/ui/nll/user-annotations/method-ufcs-inherent-3.stderr index 4ad61dc81c4..69dd1d1aaae 100644 --- a/tests/ui/nll/user-annotations/method-ufcs-inherent-3.stderr +++ b/tests/ui/nll/user-annotations/method-ufcs-inherent-3.stderr @@ -4,6 +4,7 @@ error[E0597]: `v` does not live long enough LL | fn foo<'a>() { | -- lifetime `'a` defined here LL | let v = 22; + | - binding `v` declared here LL | let x = >::new(&v, 22); | -------------^^----- | | | diff --git a/tests/ui/nll/user-annotations/method-ufcs-inherent-4.stderr b/tests/ui/nll/user-annotations/method-ufcs-inherent-4.stderr index 0f83e99cdfb..66d82bb49dc 100644 --- a/tests/ui/nll/user-annotations/method-ufcs-inherent-4.stderr +++ b/tests/ui/nll/user-annotations/method-ufcs-inherent-4.stderr @@ -4,6 +4,7 @@ error[E0597]: `v` does not live long enough LL | fn foo<'a>() { | -- lifetime `'a` defined here LL | let v = 22; + | - binding `v` declared here LL | let x = >::new::<&'a u32>(&v, &v); | ------------------------^^----- | | | @@ -19,6 +20,7 @@ error[E0597]: `v` does not live long enough LL | fn foo<'a>() { | -- lifetime `'a` defined here LL | let v = 22; + | - binding `v` declared here LL | let x = >::new::<&'a u32>(&v, &v); | ----------------------------^^- | | | diff --git a/tests/ui/nll/user-annotations/normalization.stderr b/tests/ui/nll/user-annotations/normalization.stderr index 975cb4b66d9..acc3a1800f4 100644 --- a/tests/ui/nll/user-annotations/normalization.stderr +++ b/tests/ui/nll/user-annotations/normalization.stderr @@ -1,6 +1,8 @@ error[E0597]: `a` does not live long enough --> $DIR/normalization.rs:10:31 | +LL | let a = 22; + | - binding `a` declared here LL | let _: <() as Foo>::Out = &a; | ---------------- ^^ borrowed value does not live long enough | | @@ -12,6 +14,8 @@ LL | } error[E0597]: `a` does not live long enough --> $DIR/normalization.rs:13:40 | +LL | let a = 22; + | - binding `a` declared here LL | let _: <&'static () as Foo>::Out = &a; | ------------------------- ^^ borrowed value does not live long enough | | diff --git a/tests/ui/nll/user-annotations/pattern_substs_on_brace_enum_variant.stderr b/tests/ui/nll/user-annotations/pattern_substs_on_brace_enum_variant.stderr index a97e7a9fd46..3e7969e1179 100644 --- a/tests/ui/nll/user-annotations/pattern_substs_on_brace_enum_variant.stderr +++ b/tests/ui/nll/user-annotations/pattern_substs_on_brace_enum_variant.stderr @@ -1,6 +1,8 @@ error[E0597]: `y` does not live long enough --> $DIR/pattern_substs_on_brace_enum_variant.rs:7:33 | +LL | let y = 22; + | - binding `y` declared here LL | let foo = Foo::Bar { field: &y }; | ^^ borrowed value does not live long enough LL | @@ -12,6 +14,8 @@ LL | } error[E0597]: `y` does not live long enough --> $DIR/pattern_substs_on_brace_enum_variant.rs:14:33 | +LL | let y = 22; + | - binding `y` declared here LL | let foo = Foo::Bar { field: &y }; | ^^ borrowed value does not live long enough ... diff --git a/tests/ui/nll/user-annotations/pattern_substs_on_brace_struct.stderr b/tests/ui/nll/user-annotations/pattern_substs_on_brace_struct.stderr index 408d7c2a5e2..89a1e9545e8 100644 --- a/tests/ui/nll/user-annotations/pattern_substs_on_brace_struct.stderr +++ b/tests/ui/nll/user-annotations/pattern_substs_on_brace_struct.stderr @@ -1,6 +1,8 @@ error[E0597]: `y` does not live long enough --> $DIR/pattern_substs_on_brace_struct.rs:5:28 | +LL | let y = 22; + | - binding `y` declared here LL | let foo = Foo { field: &y }; | ^^ borrowed value does not live long enough LL | @@ -12,6 +14,8 @@ LL | } error[E0597]: `y` does not live long enough --> $DIR/pattern_substs_on_brace_struct.rs:12:28 | +LL | let y = 22; + | - binding `y` declared here LL | let foo = Foo { field: &y }; | ^^ borrowed value does not live long enough ... diff --git a/tests/ui/nll/user-annotations/pattern_substs_on_tuple_enum_variant.stderr b/tests/ui/nll/user-annotations/pattern_substs_on_tuple_enum_variant.stderr index 920c906f63a..8efeecc7709 100644 --- a/tests/ui/nll/user-annotations/pattern_substs_on_tuple_enum_variant.stderr +++ b/tests/ui/nll/user-annotations/pattern_substs_on_tuple_enum_variant.stderr @@ -1,6 +1,8 @@ error[E0597]: `y` does not live long enough --> $DIR/pattern_substs_on_tuple_enum_variant.rs:7:24 | +LL | let y = 22; + | - binding `y` declared here LL | let foo = Foo::Bar(&y); | ^^ borrowed value does not live long enough LL | @@ -12,6 +14,8 @@ LL | } error[E0597]: `y` does not live long enough --> $DIR/pattern_substs_on_tuple_enum_variant.rs:14:24 | +LL | let y = 22; + | - binding `y` declared here LL | let foo = Foo::Bar(&y); | ^^ borrowed value does not live long enough ... diff --git a/tests/ui/nll/user-annotations/pattern_substs_on_tuple_struct.stderr b/tests/ui/nll/user-annotations/pattern_substs_on_tuple_struct.stderr index 3f01638d847..d7f1dac88a6 100644 --- a/tests/ui/nll/user-annotations/pattern_substs_on_tuple_struct.stderr +++ b/tests/ui/nll/user-annotations/pattern_substs_on_tuple_struct.stderr @@ -1,6 +1,8 @@ error[E0597]: `y` does not live long enough --> $DIR/pattern_substs_on_tuple_struct.rs:5:19 | +LL | let y = 22; + | - binding `y` declared here LL | let foo = Foo(&y); | ^^ borrowed value does not live long enough LL | @@ -12,6 +14,8 @@ LL | } error[E0597]: `y` does not live long enough --> $DIR/pattern_substs_on_tuple_struct.rs:12:19 | +LL | let y = 22; + | - binding `y` declared here LL | let foo = Foo(&y); | ^^ borrowed value does not live long enough ... diff --git a/tests/ui/nll/user-annotations/patterns.stderr b/tests/ui/nll/user-annotations/patterns.stderr index de6f8f80fe2..8bb714f1d0c 100644 --- a/tests/ui/nll/user-annotations/patterns.stderr +++ b/tests/ui/nll/user-annotations/patterns.stderr @@ -1,6 +1,8 @@ error[E0597]: `x` does not live long enough --> $DIR/patterns.rs:6:9 | +LL | let x = 22; + | - binding `x` declared here LL | let y: &'static u32; | ------------ type annotation requires that `x` is borrowed for `'static` LL | y = &x; @@ -11,6 +13,8 @@ LL | } error[E0597]: `x` does not live long enough --> $DIR/patterns.rs:14:9 | +LL | let x = 22; + | - binding `x` declared here LL | let (y, z): (&'static u32, &'static u32); | ---------------------------- type annotation requires that `x` is borrowed for `'static` LL | y = &x; @@ -21,6 +25,8 @@ LL | } error[E0597]: `x` does not live long enough --> $DIR/patterns.rs:20:13 | +LL | let x = 22; + | - binding `x` declared here LL | let y = &x; | ^^ borrowed value does not live long enough LL | let ref z: &'static u32 = y; @@ -32,6 +38,8 @@ LL | } error[E0597]: `x` does not live long enough --> $DIR/patterns.rs:39:9 | +LL | let x = 22; + | - binding `x` declared here LL | let Single { value: y }: Single<&'static u32>; | -------------------- type annotation requires that `x` is borrowed for `'static` LL | y = &x; @@ -42,6 +50,8 @@ LL | } error[E0597]: `x` does not live long enough --> $DIR/patterns.rs:51:10 | +LL | let x = 22; + | - binding `x` declared here LL | let Single2 { value: mut _y }: Single2; | ------------------ type annotation requires that `x` is borrowed for `'static` LL | _y = &x; @@ -52,6 +62,8 @@ LL | } error[E0597]: `x` does not live long enough --> $DIR/patterns.rs:56:27 | +LL | let x = 22; + | - binding `x` declared here LL | let y: &'static u32 = &x; | ------------ ^^ borrowed value does not live long enough | | @@ -62,6 +74,8 @@ LL | } error[E0597]: `x` does not live long enough --> $DIR/patterns.rs:61:27 | +LL | let x = 22; + | - binding `x` declared here LL | let _: &'static u32 = &x; | ------------ ^^ borrowed value does not live long enough | | @@ -100,6 +114,8 @@ LL | let (_a, b): (Vec<&'static String>, _) = (vec![&String::new()], 44); error[E0597]: `x` does not live long enough --> $DIR/patterns.rs:75:40 | +LL | let x = 22; + | - binding `x` declared here LL | let (_, _): (&'static u32, u32) = (&x, 44); | ------------------- ^^ borrowed value does not live long enough | | @@ -110,6 +126,8 @@ LL | } error[E0597]: `x` does not live long enough --> $DIR/patterns.rs:80:40 | +LL | let x = 22; + | - binding `x` declared here LL | let (y, _): (&'static u32, u32) = (&x, 44); | ------------------- ^^ borrowed value does not live long enough | | @@ -120,6 +138,8 @@ LL | } error[E0597]: `x` does not live long enough --> $DIR/patterns.rs:85:69 | +LL | let x = 22; + | - binding `x` declared here LL | let Single { value: y }: Single<&'static u32> = Single { value: &x }; | -------------------- ^^ borrowed value does not live long enough | | @@ -130,6 +150,8 @@ LL | } error[E0597]: `x` does not live long enough --> $DIR/patterns.rs:90:69 | +LL | let x = 22; + | - binding `x` declared here LL | let Single { value: _ }: Single<&'static u32> = Single { value: &x }; | -------------------- ^^ borrowed value does not live long enough | | @@ -140,6 +162,8 @@ LL | } error[E0597]: `x` does not live long enough --> $DIR/patterns.rs:98:17 | +LL | let x = 22; + | - binding `x` declared here LL | let Double { value1: _, value2: _ }: Double<&'static u32> = Double { | -------------------- type annotation requires that `x` is borrowed for `'static` LL | value1: &x, diff --git a/tests/ui/nll/user-annotations/promoted-annotation.stderr b/tests/ui/nll/user-annotations/promoted-annotation.stderr index cb99a6a369d..132a00ba415 100644 --- a/tests/ui/nll/user-annotations/promoted-annotation.stderr +++ b/tests/ui/nll/user-annotations/promoted-annotation.stderr @@ -4,6 +4,7 @@ error[E0597]: `x` does not live long enough LL | fn foo<'a>() { | -- lifetime `'a` defined here LL | let x = 0; + | - binding `x` declared here LL | let f = &drop::<&'a i32>; | ---------------- assignment requires that `x` is borrowed for `'a` LL | f(&x); diff --git a/tests/ui/nll/user-annotations/type_ascription_static_lifetime.stderr b/tests/ui/nll/user-annotations/type_ascription_static_lifetime.stderr index ccbf3c1d927..766877f8835 100644 --- a/tests/ui/nll/user-annotations/type_ascription_static_lifetime.stderr +++ b/tests/ui/nll/user-annotations/type_ascription_static_lifetime.stderr @@ -1,6 +1,8 @@ error[E0597]: `x` does not live long enough --> $DIR/type_ascription_static_lifetime.rs:6:33 | +LL | let x = 22_u32; + | - binding `x` declared here LL | let y: &u32 = type_ascribe!(&x, &'static u32); | --------------^^--------------- | | | diff --git a/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr b/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr index 1b93267b397..c7c7c074f7c 100644 --- a/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr +++ b/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr @@ -1,6 +1,8 @@ error[E0505]: cannot move out of `arr[..]` because it is borrowed --> $DIR/borrowck-move-ref-pattern.rs:8:24 | +LL | let mut arr = [U, U, U, U, U]; + | ------- binding `arr` declared here LL | let hold_all = &arr; | ---- borrow of `arr` occurs here LL | let [ref _x0_hold, _x1, ref xs_hold @ ..] = arr; diff --git a/tests/ui/regions/do-not-suggest-adding-bound-to-opaque-type.stderr b/tests/ui/regions/do-not-suggest-adding-bound-to-opaque-type.stderr index 6ea238f302f..d76a83b0258 100644 --- a/tests/ui/regions/do-not-suggest-adding-bound-to-opaque-type.stderr +++ b/tests/ui/regions/do-not-suggest-adding-bound-to-opaque-type.stderr @@ -1,6 +1,8 @@ error[E0597]: `x` does not live long enough --> $DIR/do-not-suggest-adding-bound-to-opaque-type.rs:9:7 | +LL | let x = (); + | - binding `x` declared here LL | S(&x) | --^^- | | | diff --git a/tests/ui/regions/regions-addr-of-arg.stderr b/tests/ui/regions/regions-addr-of-arg.stderr index e77289287e5..99060a9c7f5 100644 --- a/tests/ui/regions/regions-addr-of-arg.stderr +++ b/tests/ui/regions/regions-addr-of-arg.stderr @@ -1,6 +1,8 @@ error[E0597]: `a` does not live long enough --> $DIR/regions-addr-of-arg.rs:5:30 | +LL | fn foo(a: isize) { + | - binding `a` declared here LL | let _p: &'static isize = &a; | -------------- ^^ borrowed value does not live long enough | | diff --git a/tests/ui/regions/regions-free-region-ordering-caller1.stderr b/tests/ui/regions/regions-free-region-ordering-caller1.stderr index 8ef7e22536b..c83cfc1c987 100644 --- a/tests/ui/regions/regions-free-region-ordering-caller1.stderr +++ b/tests/ui/regions/regions-free-region-ordering-caller1.stderr @@ -18,6 +18,8 @@ error[E0597]: `y` does not live long enough LL | fn call1<'a>(x: &'a usize) { | -- lifetime `'a` defined here ... +LL | let y: usize = 3; + | - binding `y` declared here LL | let z: &'a & usize = &(&y); | ----------- ^^^^ borrowed value does not live long enough | | diff --git a/tests/ui/regions/regions-infer-proc-static-upvar.stderr b/tests/ui/regions/regions-infer-proc-static-upvar.stderr index 803d0d74491..c8a33bbc522 100644 --- a/tests/ui/regions/regions-infer-proc-static-upvar.stderr +++ b/tests/ui/regions/regions-infer-proc-static-upvar.stderr @@ -1,6 +1,8 @@ error[E0597]: `x` does not live long enough --> $DIR/regions-infer-proc-static-upvar.rs:10:13 | +LL | let x = 3; + | - binding `x` declared here LL | let y = &x; | ^^ borrowed value does not live long enough LL | / foo(move|| { diff --git a/tests/ui/regions/regions-nested-fns.stderr b/tests/ui/regions/regions-nested-fns.stderr index bb2740310f6..ee43f9fa572 100644 --- a/tests/ui/regions/regions-nested-fns.stderr +++ b/tests/ui/regions/regions-nested-fns.stderr @@ -13,6 +13,8 @@ LL | ay = z; error[E0597]: `y` does not live long enough --> $DIR/regions-nested-fns.rs:5:18 | +LL | let y = 3; + | - binding `y` declared here LL | let mut ay = &y; | ^^ borrowed value does not live long enough ... diff --git a/tests/ui/regions/regions-pattern-typing-issue-19552.stderr b/tests/ui/regions/regions-pattern-typing-issue-19552.stderr index f77d94a24b8..18aec29ad0b 100644 --- a/tests/ui/regions/regions-pattern-typing-issue-19552.stderr +++ b/tests/ui/regions/regions-pattern-typing-issue-19552.stderr @@ -1,6 +1,8 @@ error[E0597]: `line` does not live long enough --> $DIR/regions-pattern-typing-issue-19552.rs:5:14 | +LL | let line = String::new(); + | ---- binding `line` declared here LL | match [&*line] { | ^^^^ borrowed value does not live long enough LL | [ word ] => { assert_static(word); } diff --git a/tests/ui/regions/regions-pattern-typing-issue-19997.stderr b/tests/ui/regions/regions-pattern-typing-issue-19997.stderr index ae60e3c0d5d..0abe77a8697 100644 --- a/tests/ui/regions/regions-pattern-typing-issue-19997.stderr +++ b/tests/ui/regions/regions-pattern-typing-issue-19997.stderr @@ -2,10 +2,10 @@ error[E0506]: cannot assign to `a1` because it is borrowed --> $DIR/regions-pattern-typing-issue-19997.rs:7:13 | LL | match (&a1,) { - | --- borrow of `a1` occurs here + | --- `a1` is borrowed here LL | (&ref b0,) => { LL | a1 = &f; - | ^^^^^^^ assignment to borrowed `a1` occurs here + | ^^^^^^^ `a1` is assigned to here but it was already borrowed LL | drop(b0); | -- borrow later used here diff --git a/tests/ui/rfc-2008-non-exhaustive/borrowck-non-exhaustive.stderr b/tests/ui/rfc-2008-non-exhaustive/borrowck-non-exhaustive.stderr index de730ce1030..ad84ebe3a50 100644 --- a/tests/ui/rfc-2008-non-exhaustive/borrowck-non-exhaustive.stderr +++ b/tests/ui/rfc-2008-non-exhaustive/borrowck-non-exhaustive.stderr @@ -2,7 +2,7 @@ error[E0503]: cannot use `x` because it was mutably borrowed --> $DIR/borrowck-non-exhaustive.rs:12:11 | LL | let y = &mut x; - | ------ borrow of `x` occurs here + | ------ `x` is borrowed here LL | match x { | ^ use of borrowed `x` ... diff --git a/tests/ui/rfcs/rfc-2528-type-changing-struct-update/lifetime-update.stderr b/tests/ui/rfcs/rfc-2528-type-changing-struct-update/lifetime-update.stderr index 5f93ad6e027..1c26eb8803d 100644 --- a/tests/ui/rfcs/rfc-2528-type-changing-struct-update/lifetime-update.stderr +++ b/tests/ui/rfcs/rfc-2528-type-changing-struct-update/lifetime-update.stderr @@ -1,6 +1,9 @@ error[E0597]: `s` does not live long enough --> $DIR/lifetime-update.rs:20:17 | +LL | let s = String::from("hello"); + | - binding `s` declared here +... LL | lt_str: &s, | ^^ borrowed value does not live long enough ... diff --git a/tests/ui/self/issue-61882-2.stderr b/tests/ui/self/issue-61882-2.stderr index 0b8e134c966..6faa4477d8c 100644 --- a/tests/ui/self/issue-61882-2.stderr +++ b/tests/ui/self/issue-61882-2.stderr @@ -1,6 +1,8 @@ error[E0597]: `x` does not live long enough --> $DIR/issue-61882-2.rs:6:14 | +LL | let x = 0; + | - binding `x` declared here LL | Self(&x); | ^^ | | diff --git a/tests/ui/span/borrowck-call-is-borrow-issue-12224.stderr b/tests/ui/span/borrowck-call-is-borrow-issue-12224.stderr index 48b42bc7825..9711dad8078 100644 --- a/tests/ui/span/borrowck-call-is-borrow-issue-12224.stderr +++ b/tests/ui/span/borrowck-call-is-borrow-issue-12224.stderr @@ -47,6 +47,9 @@ LL | foo(f); error[E0505]: cannot move out of `f` because it is borrowed --> $DIR/borrowck-call-is-borrow-issue-12224.rs:55:16 | +LL | let mut f = move |g: Box, b: isize| { + | ----- binding `f` declared here +... LL | f(Box::new(|a| { | - ^^^ move out of `f` occurs here | | diff --git a/tests/ui/span/dropck_arr_cycle_checked.stderr b/tests/ui/span/dropck_arr_cycle_checked.stderr index 068c779ae52..23ebc8d598c 100644 --- a/tests/ui/span/dropck_arr_cycle_checked.stderr +++ b/tests/ui/span/dropck_arr_cycle_checked.stderr @@ -1,6 +1,9 @@ error[E0597]: `b2` does not live long enough --> $DIR/dropck_arr_cycle_checked.rs:93:24 | +LL | let (b1, b2, b3); + | -- binding `b2` declared here +... LL | b1.a[0].v.set(Some(&b2)); | ^^^ borrowed value does not live long enough ... @@ -15,6 +18,9 @@ LL | } error[E0597]: `b3` does not live long enough --> $DIR/dropck_arr_cycle_checked.rs:95:24 | +LL | let (b1, b2, b3); + | -- binding `b3` declared here +... LL | b1.a[1].v.set(Some(&b3)); | ^^^ borrowed value does not live long enough ... @@ -29,6 +35,9 @@ LL | } error[E0597]: `b1` does not live long enough --> $DIR/dropck_arr_cycle_checked.rs:99:24 | +LL | let (b1, b2, b3); + | -- binding `b1` declared here +... LL | b3.a[0].v.set(Some(&b1)); | ^^^ borrowed value does not live long enough ... diff --git a/tests/ui/span/dropck_direct_cycle_with_drop.stderr b/tests/ui/span/dropck_direct_cycle_with_drop.stderr index 07ae138ac71..1e75e3b2fa1 100644 --- a/tests/ui/span/dropck_direct_cycle_with_drop.stderr +++ b/tests/ui/span/dropck_direct_cycle_with_drop.stderr @@ -1,6 +1,8 @@ error[E0597]: `d2` does not live long enough --> $DIR/dropck_direct_cycle_with_drop.rs:36:19 | +LL | let (d1, d2) = (D::new(format!("d1")), D::new(format!("d2"))); + | -- binding `d2` declared here LL | d1.p.set(Some(&d2)); | ^^^ borrowed value does not live long enough ... @@ -15,6 +17,9 @@ LL | } error[E0597]: `d1` does not live long enough --> $DIR/dropck_direct_cycle_with_drop.rs:38:19 | +LL | let (d1, d2) = (D::new(format!("d1")), D::new(format!("d2"))); + | -- binding `d1` declared here +... LL | d2.p.set(Some(&d1)); | ^^^ borrowed value does not live long enough LL | diff --git a/tests/ui/span/dropck_misc_variants.stderr b/tests/ui/span/dropck_misc_variants.stderr index 76e90574cef..24a2c9089f5 100644 --- a/tests/ui/span/dropck_misc_variants.stderr +++ b/tests/ui/span/dropck_misc_variants.stderr @@ -1,6 +1,9 @@ error[E0597]: `bomb` does not live long enough --> $DIR/dropck_misc_variants.rs:23:36 | +LL | let (_w, bomb); + | ---- binding `bomb` declared here +LL | bomb = vec![""]; LL | _w = Wrap::<&[&str]>(NoisyDrop(&bomb)); | ^^^^^ borrowed value does not live long enough LL | } @@ -14,6 +17,9 @@ LL | } error[E0597]: `v` does not live long enough --> $DIR/dropck_misc_variants.rs:31:27 | +LL | let (_w,v); + | - binding `v` declared here +... LL | let u = NoisyDrop(&v); | ^^ borrowed value does not live long enough ... diff --git a/tests/ui/span/dropck_vec_cycle_checked.stderr b/tests/ui/span/dropck_vec_cycle_checked.stderr index 7ff991c0c37..5817439c0d8 100644 --- a/tests/ui/span/dropck_vec_cycle_checked.stderr +++ b/tests/ui/span/dropck_vec_cycle_checked.stderr @@ -1,6 +1,9 @@ error[E0597]: `c2` does not live long enough --> $DIR/dropck_vec_cycle_checked.rs:98:24 | +LL | let (mut c1, mut c2, mut c3); + | ------ binding `c2` declared here +... LL | c1.v[0].v.set(Some(&c2)); | ^^^ borrowed value does not live long enough ... @@ -15,6 +18,9 @@ LL | } error[E0597]: `c3` does not live long enough --> $DIR/dropck_vec_cycle_checked.rs:100:24 | +LL | let (mut c1, mut c2, mut c3); + | ------ binding `c3` declared here +... LL | c1.v[1].v.set(Some(&c3)); | ^^^ borrowed value does not live long enough ... @@ -29,6 +35,9 @@ LL | } error[E0597]: `c1` does not live long enough --> $DIR/dropck_vec_cycle_checked.rs:104:24 | +LL | let (mut c1, mut c2, mut c3); + | ------ binding `c1` declared here +... LL | c3.v[0].v.set(Some(&c1)); | ^^^ borrowed value does not live long enough ... diff --git a/tests/ui/span/issue-24805-dropck-child-has-items-via-parent.stderr b/tests/ui/span/issue-24805-dropck-child-has-items-via-parent.stderr index 809e60a8c8a..c3b6d7580b4 100644 --- a/tests/ui/span/issue-24805-dropck-child-has-items-via-parent.stderr +++ b/tests/ui/span/issue-24805-dropck-child-has-items-via-parent.stderr @@ -1,6 +1,9 @@ error[E0597]: `d1` does not live long enough --> $DIR/issue-24805-dropck-child-has-items-via-parent.rs:28:18 | +LL | let (_d, d1); + | -- binding `d1` declared here +... LL | _d = D_Child(&d1); | ^^^ borrowed value does not live long enough ... diff --git a/tests/ui/span/issue-24805-dropck-trait-has-items.stderr b/tests/ui/span/issue-24805-dropck-trait-has-items.stderr index 2e217066915..e52c57d9ab1 100644 --- a/tests/ui/span/issue-24805-dropck-trait-has-items.stderr +++ b/tests/ui/span/issue-24805-dropck-trait-has-items.stderr @@ -1,6 +1,9 @@ error[E0597]: `d1` does not live long enough --> $DIR/issue-24805-dropck-trait-has-items.rs:37:26 | +LL | let (_d, d1); + | -- binding `d1` declared here +LL | d1 = D_HasSelfMethod(1); LL | _d = D_HasSelfMethod(&d1); | ^^^ borrowed value does not live long enough LL | } @@ -14,6 +17,9 @@ LL | } error[E0597]: `d1` does not live long enough --> $DIR/issue-24805-dropck-trait-has-items.rs:43:33 | +LL | let (_d, d1); + | -- binding `d1` declared here +LL | d1 = D_HasMethodWithSelfArg(1); LL | _d = D_HasMethodWithSelfArg(&d1); | ^^^ borrowed value does not live long enough LL | } @@ -27,6 +33,9 @@ LL | } error[E0597]: `d1` does not live long enough --> $DIR/issue-24805-dropck-trait-has-items.rs:49:20 | +LL | let (_d, d1); + | -- binding `d1` declared here +LL | d1 = D_HasType(1); LL | _d = D_HasType(&d1); | ^^^ borrowed value does not live long enough LL | } diff --git a/tests/ui/span/issue-24895-copy-clone-dropck.stderr b/tests/ui/span/issue-24895-copy-clone-dropck.stderr index 18a3dc9e6de..83db4d509d4 100644 --- a/tests/ui/span/issue-24895-copy-clone-dropck.stderr +++ b/tests/ui/span/issue-24895-copy-clone-dropck.stderr @@ -1,6 +1,9 @@ error[E0597]: `d1` does not live long enough --> $DIR/issue-24895-copy-clone-dropck.rs:27:14 | +LL | let (d2, d1); + | -- binding `d1` declared here +LL | d1 = D(34, "d1"); LL | d2 = D(S(&d1, "inner"), "d2"); | ^^^ borrowed value does not live long enough LL | } diff --git a/tests/ui/span/issue-25199.stderr b/tests/ui/span/issue-25199.stderr index d70a4afc1bf..1e0276f0c36 100644 --- a/tests/ui/span/issue-25199.stderr +++ b/tests/ui/span/issue-25199.stderr @@ -1,6 +1,8 @@ error[E0597]: `container` does not live long enough --> $DIR/issue-25199.rs:70:27 | +LL | let container = Container::new(); + | --------- binding `container` declared here LL | let test = Test{test: &container}; | ^^^^^^^^^^ borrowed value does not live long enough ... diff --git a/tests/ui/span/issue-26656.stderr b/tests/ui/span/issue-26656.stderr index 1e939c484fb..fea6e001238 100644 --- a/tests/ui/span/issue-26656.stderr +++ b/tests/ui/span/issue-26656.stderr @@ -1,6 +1,9 @@ error[E0597]: `ticking` does not live long enough --> $DIR/issue-26656.rs:40:35 | +LL | let (mut zook, ticking); + | ------- binding `ticking` declared here +... LL | zook.button = B::BigRedButton(&ticking); | ^^^^^^^^ borrowed value does not live long enough LL | } diff --git a/tests/ui/span/issue-29106.stderr b/tests/ui/span/issue-29106.stderr index 71fbd60ee73..28ee7acd90e 100644 --- a/tests/ui/span/issue-29106.stderr +++ b/tests/ui/span/issue-29106.stderr @@ -1,6 +1,9 @@ error[E0597]: `x` does not live long enough --> $DIR/issue-29106.rs:16:26 | +LL | let (y, x); + | - binding `x` declared here +LL | x = "alive".to_string(); LL | y = Arc::new(Foo(&x)); | ^^ borrowed value does not live long enough LL | } @@ -14,6 +17,9 @@ LL | } error[E0597]: `x` does not live long enough --> $DIR/issue-29106.rs:23:25 | +LL | let (y, x); + | - binding `x` declared here +LL | x = "alive".to_string(); LL | y = Rc::new(Foo(&x)); | ^^ borrowed value does not live long enough LL | } diff --git a/tests/ui/span/issue-36537.stderr b/tests/ui/span/issue-36537.stderr index 79a0ebaeb8d..6c330c1a094 100644 --- a/tests/ui/span/issue-36537.stderr +++ b/tests/ui/span/issue-36537.stderr @@ -1,6 +1,8 @@ error[E0597]: `a` does not live long enough --> $DIR/issue-36537.rs:5:13 | +LL | let a = 42; + | - binding `a` declared here LL | p = &a; | ^^ borrowed value does not live long enough ... diff --git a/tests/ui/span/issue-40157.stderr b/tests/ui/span/issue-40157.stderr index 57f80214a4f..e9b84de5059 100644 --- a/tests/ui/span/issue-40157.stderr +++ b/tests/ui/span/issue-40157.stderr @@ -2,11 +2,9 @@ error[E0597]: `foo` does not live long enough --> $DIR/issue-40157.rs:2:53 | LL | {println!("{:?}", match { let foo = vec![1, 2]; foo.get(1) } { x => x });} - | ------------------------^^^^^^^^^^-- - | | | | - | | | `foo` dropped here while still borrowed - | | borrowed value does not live long enough - | borrow later used here + | ^^^^^^^^^^ - `foo` dropped here while still borrowed + | | + | borrowed value does not live long enough error: aborting due to previous error diff --git a/tests/ui/span/issue28498-reject-lifetime-param.stderr b/tests/ui/span/issue28498-reject-lifetime-param.stderr index 3119ddd03cc..94c450c7b1e 100644 --- a/tests/ui/span/issue28498-reject-lifetime-param.stderr +++ b/tests/ui/span/issue28498-reject-lifetime-param.stderr @@ -1,6 +1,9 @@ error[E0597]: `first_dropped` does not live long enough --> $DIR/issue28498-reject-lifetime-param.rs:32:19 | +LL | let (foo1, first_dropped); + | ------------- binding `first_dropped` declared here +... LL | foo1 = Foo(1, &first_dropped); | ^^^^^^^^^^^^^^ borrowed value does not live long enough ... diff --git a/tests/ui/span/issue28498-reject-passed-to-fn.stderr b/tests/ui/span/issue28498-reject-passed-to-fn.stderr index 60e8a648cd5..e133f75d57b 100644 --- a/tests/ui/span/issue28498-reject-passed-to-fn.stderr +++ b/tests/ui/span/issue28498-reject-passed-to-fn.stderr @@ -1,6 +1,9 @@ error[E0597]: `first_dropped` does not live long enough --> $DIR/issue28498-reject-passed-to-fn.rs:34:19 | +LL | let (foo1, first_dropped); + | ------------- binding `first_dropped` declared here +... LL | foo1 = Foo(1, &first_dropped, Box::new(callback)); | ^^^^^^^^^^^^^^ borrowed value does not live long enough ... diff --git a/tests/ui/span/issue28498-reject-trait-bound.stderr b/tests/ui/span/issue28498-reject-trait-bound.stderr index 22e4a8205b6..9ab3cdd1343 100644 --- a/tests/ui/span/issue28498-reject-trait-bound.stderr +++ b/tests/ui/span/issue28498-reject-trait-bound.stderr @@ -1,6 +1,9 @@ error[E0597]: `first_dropped` does not live long enough --> $DIR/issue28498-reject-trait-bound.rs:34:19 | +LL | let (foo1, first_dropped); + | ------------- binding `first_dropped` declared here +... LL | foo1 = Foo(1, &first_dropped); | ^^^^^^^^^^^^^^ borrowed value does not live long enough ... diff --git a/tests/ui/span/mut-ptr-cant-outlive-ref.stderr b/tests/ui/span/mut-ptr-cant-outlive-ref.stderr index 4d976a7bbfa..be56f9489c7 100644 --- a/tests/ui/span/mut-ptr-cant-outlive-ref.stderr +++ b/tests/ui/span/mut-ptr-cant-outlive-ref.stderr @@ -1,6 +1,8 @@ error[E0597]: `b` does not live long enough --> $DIR/mut-ptr-cant-outlive-ref.rs:8:15 | +LL | let b = m.borrow(); + | - binding `b` declared here LL | p = &*b; | ^ borrowed value does not live long enough LL | } diff --git a/tests/ui/span/range-2.stderr b/tests/ui/span/range-2.stderr index 8ca8156b083..d7084b00ba4 100644 --- a/tests/ui/span/range-2.stderr +++ b/tests/ui/span/range-2.stderr @@ -3,7 +3,9 @@ error[E0597]: `a` does not live long enough | LL | let r = { | - borrow later stored here -... +LL | let a = 42; + | - binding `a` declared here +LL | let b = 42; LL | &a..&b | ^^ borrowed value does not live long enough LL | }; @@ -14,7 +16,9 @@ error[E0597]: `b` does not live long enough | LL | let r = { | - borrow later stored here -... +LL | let a = 42; +LL | let b = 42; + | - binding `b` declared here LL | &a..&b | ^^ borrowed value does not live long enough LL | }; diff --git a/tests/ui/span/regionck-unboxed-closure-lifetimes.stderr b/tests/ui/span/regionck-unboxed-closure-lifetimes.stderr index 0b985de609c..fb3fad6ae90 100644 --- a/tests/ui/span/regionck-unboxed-closure-lifetimes.stderr +++ b/tests/ui/span/regionck-unboxed-closure-lifetimes.stderr @@ -1,6 +1,8 @@ error[E0597]: `c` does not live long enough --> $DIR/regionck-unboxed-closure-lifetimes.rs:8:21 | +LL | let c = 1; + | - binding `c` declared here LL | let c_ref = &c; | ^^ borrowed value does not live long enough ... diff --git a/tests/ui/span/regions-close-over-type-parameter-2.stderr b/tests/ui/span/regions-close-over-type-parameter-2.stderr index 2e584d9a884..fed40a4fdd2 100644 --- a/tests/ui/span/regions-close-over-type-parameter-2.stderr +++ b/tests/ui/span/regions-close-over-type-parameter-2.stderr @@ -1,6 +1,8 @@ error[E0597]: `tmp0` does not live long enough --> $DIR/regions-close-over-type-parameter-2.rs:23:20 | +LL | let tmp0 = 3; + | ---- binding `tmp0` declared here LL | let tmp1 = &tmp0; | ^^^^^ borrowed value does not live long enough LL | repeater3(tmp1) diff --git a/tests/ui/span/regions-escape-loop-via-variable.stderr b/tests/ui/span/regions-escape-loop-via-variable.stderr index 42df6685297..e5c7d8b26ab 100644 --- a/tests/ui/span/regions-escape-loop-via-variable.stderr +++ b/tests/ui/span/regions-escape-loop-via-variable.stderr @@ -2,7 +2,9 @@ error[E0597]: `x` does not live long enough --> $DIR/regions-escape-loop-via-variable.rs:11:13 | LL | let x = 1 + *p; - | -- borrow later used here + | - -- borrow later used here + | | + | binding `x` declared here LL | p = &x; | ^^ borrowed value does not live long enough LL | } diff --git a/tests/ui/span/regions-escape-loop-via-vec.stderr b/tests/ui/span/regions-escape-loop-via-vec.stderr index 2b649307739..532ac3606c5 100644 --- a/tests/ui/span/regions-escape-loop-via-vec.stderr +++ b/tests/ui/span/regions-escape-loop-via-vec.stderr @@ -2,7 +2,7 @@ error[E0503]: cannot use `x` because it was mutably borrowed --> $DIR/regions-escape-loop-via-vec.rs:5:11 | LL | let mut _y = vec![&mut x]; - | ------ borrow of `x` occurs here + | ------ `x` is borrowed here LL | while x < 10 { | ^ use of borrowed `x` LL | let mut z = x; @@ -13,7 +13,7 @@ error[E0503]: cannot use `x` because it was mutably borrowed --> $DIR/regions-escape-loop-via-vec.rs:6:21 | LL | let mut _y = vec![&mut x]; - | ------ borrow of `x` occurs here + | ------ `x` is borrowed here LL | while x < 10 { LL | let mut z = x; | ^ use of borrowed `x` @@ -23,11 +23,10 @@ LL | _y.push(&mut z); error[E0597]: `z` does not live long enough --> $DIR/regions-escape-loop-via-vec.rs:7:17 | +LL | let mut z = x; + | ----- binding `z` declared here LL | _y.push(&mut z); - | --------^^^^^^- - | | | - | | borrowed value does not live long enough - | borrow later used here + | ^^^^^^ borrowed value does not live long enough ... LL | } | - `z` dropped here while still borrowed @@ -36,7 +35,7 @@ error[E0503]: cannot use `x` because it was mutably borrowed --> $DIR/regions-escape-loop-via-vec.rs:9:9 | LL | let mut _y = vec![&mut x]; - | ------ borrow of `x` occurs here + | ------ `x` is borrowed here ... LL | _y.push(&mut z); | --------------- borrow later used here diff --git a/tests/ui/span/send-is-not-static-ensures-scoping.stderr b/tests/ui/span/send-is-not-static-ensures-scoping.stderr index 65d10c1305b..bae0befcaca 100644 --- a/tests/ui/span/send-is-not-static-ensures-scoping.stderr +++ b/tests/ui/span/send-is-not-static-ensures-scoping.stderr @@ -4,6 +4,7 @@ error[E0597]: `x` does not live long enough LL | let bad = { | --- borrow later stored here LL | let x = 1; + | - binding `x` declared here LL | let y = &x; | ^^ borrowed value does not live long enough ... diff --git a/tests/ui/span/send-is-not-static-std-sync-2.stderr b/tests/ui/span/send-is-not-static-std-sync-2.stderr index bcd07e11647..b0267fa6f43 100644 --- a/tests/ui/span/send-is-not-static-std-sync-2.stderr +++ b/tests/ui/span/send-is-not-static-std-sync-2.stderr @@ -4,6 +4,7 @@ error[E0597]: `x` does not live long enough LL | let lock = { | ---- borrow later stored here LL | let x = 1; + | - binding `x` declared here LL | Mutex::new(&x) | ^^ borrowed value does not live long enough LL | }; @@ -15,6 +16,7 @@ error[E0597]: `x` does not live long enough LL | let lock = { | ---- borrow later stored here LL | let x = 1; + | - binding `x` declared here LL | RwLock::new(&x) | ^^ borrowed value does not live long enough LL | }; @@ -25,7 +27,9 @@ error[E0597]: `x` does not live long enough | LL | let (_tx, rx) = { | --- borrow later used here -... +LL | let x = 1; + | - binding `x` declared here +LL | let (tx, rx) = mpsc::channel(); LL | let _ = tx.send(&x); | ^^ borrowed value does not live long enough LL | (tx, rx) diff --git a/tests/ui/span/send-is-not-static-std-sync.stderr b/tests/ui/span/send-is-not-static-std-sync.stderr index 5d493a3e4ee..28b1c5fe715 100644 --- a/tests/ui/span/send-is-not-static-std-sync.stderr +++ b/tests/ui/span/send-is-not-static-std-sync.stderr @@ -12,6 +12,8 @@ LL | *lock.lock().unwrap() = &z; error[E0597]: `z` does not live long enough --> $DIR/send-is-not-static-std-sync.rs:16:33 | +LL | let z = 2; + | - binding `z` declared here LL | *lock.lock().unwrap() = &z; | ^^ borrowed value does not live long enough LL | } @@ -34,6 +36,8 @@ LL | *lock.write().unwrap() = &z; error[E0597]: `z` does not live long enough --> $DIR/send-is-not-static-std-sync.rs:30:34 | +LL | let z = 2; + | - binding `z` declared here LL | *lock.write().unwrap() = &z; | ^^ borrowed value does not live long enough LL | } @@ -56,6 +60,8 @@ LL | tx.send(&z).unwrap(); error[E0597]: `z` does not live long enough --> $DIR/send-is-not-static-std-sync.rs:46:17 | +LL | let z = 2; + | - binding `z` declared here LL | tx.send(&z).unwrap(); | ^^ borrowed value does not live long enough LL | } diff --git a/tests/ui/span/vec-must-not-hide-type-from-dropck.stderr b/tests/ui/span/vec-must-not-hide-type-from-dropck.stderr index f87c32d1ad0..f2fefca414e 100644 --- a/tests/ui/span/vec-must-not-hide-type-from-dropck.stderr +++ b/tests/ui/span/vec-must-not-hide-type-from-dropck.stderr @@ -1,6 +1,9 @@ error[E0597]: `c2` does not live long enough --> $DIR/vec-must-not-hide-type-from-dropck.rs:117:24 | +LL | let (mut c1, mut c2); + | ------ binding `c2` declared here +... LL | c1.v[0].v.set(Some(&c2)); | ^^^ borrowed value does not live long enough ... @@ -15,6 +18,9 @@ LL | } error[E0597]: `c1` does not live long enough --> $DIR/vec-must-not-hide-type-from-dropck.rs:119:24 | +LL | let (mut c1, mut c2); + | ------ binding `c1` declared here +... LL | c2.v[0].v.set(Some(&c1)); | ^^^ borrowed value does not live long enough LL | diff --git a/tests/ui/span/vec_refs_data_with_early_death.stderr b/tests/ui/span/vec_refs_data_with_early_death.stderr index 684e7845313..73f27144af4 100644 --- a/tests/ui/span/vec_refs_data_with_early_death.stderr +++ b/tests/ui/span/vec_refs_data_with_early_death.stderr @@ -1,6 +1,9 @@ error[E0597]: `x` does not live long enough --> $DIR/vec_refs_data_with_early_death.rs:17:12 | +LL | let x: i8 = 3; + | - binding `x` declared here +... LL | v.push(&x); | ^^ borrowed value does not live long enough ... @@ -15,6 +18,9 @@ LL | } error[E0597]: `y` does not live long enough --> $DIR/vec_refs_data_with_early_death.rs:19:12 | +LL | let y: i8 = 4; + | - binding `y` declared here +... LL | v.push(&y); | ^^ borrowed value does not live long enough ... diff --git a/tests/ui/span/wf-method-late-bound-regions.stderr b/tests/ui/span/wf-method-late-bound-regions.stderr index 6b0b008208f..64c2d0f1606 100644 --- a/tests/ui/span/wf-method-late-bound-regions.stderr +++ b/tests/ui/span/wf-method-late-bound-regions.stderr @@ -4,6 +4,7 @@ error[E0597]: `pointer` does not live long enough LL | let dangling = { | -------- borrow later stored here LL | let pointer = Box::new(42); + | ------- binding `pointer` declared here LL | f2.xmute(&pointer) | ^^^^^^^^ borrowed value does not live long enough LL | }; diff --git a/tests/ui/static/static-lifetime-bound.stderr b/tests/ui/static/static-lifetime-bound.stderr index ef07a89315f..e22411b13b7 100644 --- a/tests/ui/static/static-lifetime-bound.stderr +++ b/tests/ui/static/static-lifetime-bound.stderr @@ -9,6 +9,8 @@ LL | fn f<'a: 'static>(_: &'a i32) {} error[E0597]: `x` does not live long enough --> $DIR/static-lifetime-bound.rs:5:7 | +LL | let x = 0; + | - binding `x` declared here LL | f(&x); | --^^- | | | diff --git a/tests/ui/suggestions/borrow-for-loop-head.stderr b/tests/ui/suggestions/borrow-for-loop-head.stderr index cbdb94877bd..0f179438a12 100644 --- a/tests/ui/suggestions/borrow-for-loop-head.stderr +++ b/tests/ui/suggestions/borrow-for-loop-head.stderr @@ -1,6 +1,8 @@ error[E0505]: cannot move out of `a` because it is borrowed --> $DIR/borrow-for-loop-head.rs:4:18 | +LL | let a = vec![1, 2, 3]; + | - binding `a` declared here LL | for i in &a { | -- borrow of `a` occurs here LL | for j in a { diff --git a/tests/ui/suggestions/option-content-move2.stderr b/tests/ui/suggestions/option-content-move2.stderr index 1d3dff3be34..94acda73c4e 100644 --- a/tests/ui/suggestions/option-content-move2.stderr +++ b/tests/ui/suggestions/option-content-move2.stderr @@ -7,7 +7,7 @@ LL | func(|| { | -- captured by this `FnMut` closure LL | // Shouldn't suggest `move ||.as_ref()` here LL | move || { - | ^^^^^^^ move out of `var` occurs here + | ^^^^^^^ `var` is moved here LL | LL | var = Some(NotCopyable); | --- diff --git a/tests/ui/traits/associated_type_bound/check-trait-object-bounds-3.stderr b/tests/ui/traits/associated_type_bound/check-trait-object-bounds-3.stderr index ade552c4bab..c7af71a4214 100644 --- a/tests/ui/traits/associated_type_bound/check-trait-object-bounds-3.stderr +++ b/tests/ui/traits/associated_type_bound/check-trait-object-bounds-3.stderr @@ -1,6 +1,8 @@ error[E0597]: `s` does not live long enough --> $DIR/check-trait-object-bounds-3.rs:15:34 | +LL | let s = String::from("abcdef"); + | - binding `s` declared here LL | z = f::>(&s); | ---------------------^^- | | | diff --git a/tests/ui/traits/coercion-generic-regions.stderr b/tests/ui/traits/coercion-generic-regions.stderr index 5cfb6490123..ae70202ab7c 100644 --- a/tests/ui/traits/coercion-generic-regions.stderr +++ b/tests/ui/traits/coercion-generic-regions.stderr @@ -1,6 +1,8 @@ error[E0597]: `person` does not live long enough --> $DIR/coercion-generic-regions.rs:17:24 | +LL | let person = "Fred".to_string(); + | ------ binding `person` declared here LL | let person: &str = &person; | ^^^^^^^ | | diff --git a/tests/ui/traits/vtable/issue-97381.stderr b/tests/ui/traits/vtable/issue-97381.stderr index c4f8294e263..89360c44e78 100644 --- a/tests/ui/traits/vtable/issue-97381.stderr +++ b/tests/ui/traits/vtable/issue-97381.stderr @@ -1,6 +1,9 @@ error[E0505]: cannot move out of `v` because it is borrowed --> $DIR/issue-97381.rs:26:14 | +LL | let v = [1, 2, 3] + | - binding `v` declared here +... LL | let el = &v[0]; | - borrow of `v` occurs here LL | diff --git a/tests/ui/try-block/try-block-bad-lifetime.stderr b/tests/ui/try-block/try-block-bad-lifetime.stderr index ea079e30d9c..28941cb0a9e 100644 --- a/tests/ui/try-block/try-block-bad-lifetime.stderr +++ b/tests/ui/try-block/try-block-bad-lifetime.stderr @@ -4,6 +4,7 @@ error[E0597]: `my_string` does not live long enough LL | let result: Result<(), &str> = try { | ------ borrow later stored here LL | let my_string = String::from(""); + | --------- binding `my_string` declared here LL | let my_str: & str = & my_string; | ^^^^^^^^^^^ borrowed value does not live long enough ... @@ -14,10 +15,10 @@ error[E0506]: cannot assign to `i` because it is borrowed --> $DIR/try-block-bad-lifetime.rs:29:13 | LL | let k = &mut i; - | ------ borrow of `i` occurs here + | ------ `i` is borrowed here ... LL | i = 10; - | ^^^^^^ assignment to borrowed `i` occurs here + | ^^^^^^ `i` is assigned to here but it was already borrowed LL | }; LL | ::std::mem::drop(k); | - borrow later used here @@ -38,10 +39,10 @@ error[E0506]: cannot assign to `i` because it is borrowed --> $DIR/try-block-bad-lifetime.rs:32:9 | LL | let k = &mut i; - | ------ borrow of `i` occurs here + | ------ `i` is borrowed here ... LL | i = 40; - | ^^^^^^ assignment to borrowed `i` occurs here + | ^^^^^^ `i` is assigned to here but it was already borrowed LL | LL | let i_ptr = if let Err(i_ptr) = j { i_ptr } else { panic ! ("") }; | - borrow later used here diff --git a/tests/ui/try-block/try-block-maybe-bad-lifetime.stderr b/tests/ui/try-block/try-block-maybe-bad-lifetime.stderr index f738b03eed6..71c7e460c39 100644 --- a/tests/ui/try-block/try-block-maybe-bad-lifetime.stderr +++ b/tests/ui/try-block/try-block-maybe-bad-lifetime.stderr @@ -2,10 +2,10 @@ error[E0506]: cannot assign to `i` because it is borrowed --> $DIR/try-block-maybe-bad-lifetime.rs:17:9 | LL | &i - | -- borrow of `i` occurs here + | -- `i` is borrowed here LL | }; LL | i = 0; - | ^^^^^ assignment to borrowed `i` occurs here + | ^^^^^ `i` is assigned to here but it was already borrowed LL | let _ = i; LL | do_something_with(x); | - borrow later used here @@ -32,10 +32,10 @@ error[E0506]: cannot assign to `i` because it is borrowed --> $DIR/try-block-maybe-bad-lifetime.rs:40:9 | LL | j = &i; - | -- borrow of `i` occurs here + | -- `i` is borrowed here LL | }; LL | i = 0; - | ^^^^^ assignment to borrowed `i` occurs here + | ^^^^^ `i` is assigned to here but it was already borrowed LL | let _ = i; LL | do_something_with(j); | - borrow later used here diff --git a/tests/ui/unboxed-closures/unboxed-closures-borrow-conflict.stderr b/tests/ui/unboxed-closures/unboxed-closures-borrow-conflict.stderr index 21d6b4fde7e..98fe97c5c18 100644 --- a/tests/ui/unboxed-closures/unboxed-closures-borrow-conflict.stderr +++ b/tests/ui/unboxed-closures/unboxed-closures-borrow-conflict.stderr @@ -4,7 +4,7 @@ error[E0503]: cannot use `x` because it was mutably borrowed LL | let f = || x += 1; | -- - borrow occurs due to use of `x` in closure | | - | borrow of `x` occurs here + | `x` is borrowed here LL | let _y = x; | ^ use of borrowed `x` LL | f; diff --git a/tests/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.stderr b/tests/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.stderr index cbdb4dd0fb5..23aa18d7156 100644 --- a/tests/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.stderr +++ b/tests/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.stderr @@ -16,14 +16,14 @@ error[E0506]: cannot assign to `factorial` because it is borrowed --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:20:5 | LL | let f = |x: u32| -> u32 { - | --------------- borrow of `factorial` occurs here + | --------------- `factorial` is borrowed here LL | let g = factorial.as_ref().unwrap(); | --------- borrow occurs due to use in closure ... LL | factorial = Some(Box::new(f)); | ^^^^^^^^^ | | - | assignment to borrowed `factorial` occurs here + | `factorial` is assigned to here but it was already borrowed | borrow later used here error[E0597]: `factorial` does not live long enough @@ -47,12 +47,12 @@ LL | let mut factorial: Option u32 + 'static>> = None; | ----------------------------------------- type annotation requires that `factorial` is borrowed for `'static` LL | LL | let f = |x: u32| -> u32 { - | --------------- borrow of `factorial` occurs here + | --------------- `factorial` is borrowed here LL | let g = factorial.as_ref().unwrap(); | --------- borrow occurs due to use in closure ... LL | factorial = Some(Box::new(f)); - | ^^^^^^^^^ assignment to borrowed `factorial` occurs here + | ^^^^^^^^^ `factorial` is assigned to here but it was already borrowed error: aborting due to 4 previous errors diff --git a/tests/ui/unop-move-semantics.stderr b/tests/ui/unop-move-semantics.stderr index 2a3ca14433f..e47785c465a 100644 --- a/tests/ui/unop-move-semantics.stderr +++ b/tests/ui/unop-move-semantics.stderr @@ -23,6 +23,8 @@ LL | fn move_then_borrow + Clone + Copy>(x: T) { error[E0505]: cannot move out of `x` because it is borrowed --> $DIR/unop-move-semantics.rs:15:6 | +LL | fn move_borrowed>(x: T, mut y: T) { + | - binding `x` declared here LL | let m = &x; | -- borrow of `x` occurs here ... @@ -35,6 +37,9 @@ LL | use_mut(n); use_imm(m); error[E0505]: cannot move out of `y` because it is borrowed --> $DIR/unop-move-semantics.rs:17:6 | +LL | fn move_borrowed>(x: T, mut y: T) { + | ----- binding `y` declared here +LL | let m = &x; LL | let n = &mut y; | ------ borrow of `y` occurs here ... diff --git a/tests/ui/variance/variance-issue-20533.stderr b/tests/ui/variance/variance-issue-20533.stderr index 008e2a002bb..258f67db5ce 100644 --- a/tests/ui/variance/variance-issue-20533.stderr +++ b/tests/ui/variance/variance-issue-20533.stderr @@ -1,6 +1,8 @@ error[E0505]: cannot move out of `a` because it is borrowed --> $DIR/variance-issue-20533.rs:28:14 | +LL | let a = AffineU32(1); + | - binding `a` declared here LL | let x = foo(&a); | -- borrow of `a` occurs here LL | drop(a); @@ -11,6 +13,8 @@ LL | drop(x); error[E0505]: cannot move out of `a` because it is borrowed --> $DIR/variance-issue-20533.rs:34:14 | +LL | let a = AffineU32(1); + | - binding `a` declared here LL | let x = bar(&a); | -- borrow of `a` occurs here LL | drop(a); @@ -21,6 +25,8 @@ LL | drop(x); error[E0505]: cannot move out of `a` because it is borrowed --> $DIR/variance-issue-20533.rs:40:14 | +LL | let a = AffineU32(1); + | - binding `a` declared here LL | let x = baz(&a); | -- borrow of `a` occurs here LL | drop(a); From e4f61afa779e01af24c6f20394de8e3950b368c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 15 Jan 2023 19:57:32 +0000 Subject: [PATCH 2/5] Fix fulldeps-ui tests --- tests/ui-fulldeps/dropck-tarena-cycle-checked.stderr | 2 ++ tests/ui-fulldeps/dropck-tarena-unsound-drop.stderr | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tests/ui-fulldeps/dropck-tarena-cycle-checked.stderr b/tests/ui-fulldeps/dropck-tarena-cycle-checked.stderr index 4299688221a..47897dc003a 100644 --- a/tests/ui-fulldeps/dropck-tarena-cycle-checked.stderr +++ b/tests/ui-fulldeps/dropck-tarena-cycle-checked.stderr @@ -1,6 +1,8 @@ error[E0597]: `arena` does not live long enough --> $DIR/dropck-tarena-cycle-checked.rs:116:7 | +LL | let arena = TypedArena::default(); + | ----- binding `arena` declared here LL | f(&arena); | ^^^^^^ borrowed value does not live long enough LL | } diff --git a/tests/ui-fulldeps/dropck-tarena-unsound-drop.stderr b/tests/ui-fulldeps/dropck-tarena-unsound-drop.stderr index ccffee9cdbd..493d74b0bde 100644 --- a/tests/ui-fulldeps/dropck-tarena-unsound-drop.stderr +++ b/tests/ui-fulldeps/dropck-tarena-unsound-drop.stderr @@ -1,6 +1,8 @@ error[E0597]: `arena` does not live long enough --> $DIR/dropck-tarena-unsound-drop.rs:41:7 | +LL | let arena: TypedArena = TypedArena::default(); + | ----- binding `arena` declared here LL | f(&arena); | ^^^^^^ borrowed value does not live long enough LL | } From be2ec32b18f7ad858dc746b26eb3a91a62a2c360 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Tue, 17 Jan 2023 02:45:11 +0000 Subject: [PATCH 3/5] Account for `*` when looking for inner-most path in expression --- .../rustc_borrowck/src/diagnostics/explain_borrow.rs | 4 +++- tests/ui/borrowck/borrowck-bad-nested-calls-move.stderr | 5 +++++ tests/ui/borrowck/borrowck-move-mut-base-ptr.stderr | 2 ++ tests/ui/borrowck/borrowck-unary-move.stderr | 2 ++ tests/ui/nll/polonius/polonius-smoke-test.stderr | 6 +++++- tests/ui/span/dropck-object-cycle.stderr | 2 ++ .../span/regions-infer-borrow-scope-within-loop.stderr | 3 +++ tests/ui/span/send-is-not-static-std-sync.stderr | 9 +++++++++ 8 files changed, 31 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs index e4f45c53aef..d60facb91b4 100644 --- a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs +++ b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs @@ -75,7 +75,9 @@ impl<'tcx> BorrowExplanation<'tcx> { let mut expr_finder = FindExprBySpan::new(span); expr_finder.visit_expr(body.value); if let Some(mut expr) = expr_finder.result { - while let hir::ExprKind::AddrOf(_, _, inner) = &expr.kind { + while let hir::ExprKind::AddrOf(_, _, inner) + | hir::ExprKind::Unary(hir::UnOp::Deref, inner) = &expr.kind + { expr = inner; } if let hir::ExprKind::Path(hir::QPath::Resolved(None, p)) = expr.kind diff --git a/tests/ui/borrowck/borrowck-bad-nested-calls-move.stderr b/tests/ui/borrowck/borrowck-bad-nested-calls-move.stderr index 371bcf2b69c..e582ec605de 100644 --- a/tests/ui/borrowck/borrowck-bad-nested-calls-move.stderr +++ b/tests/ui/borrowck/borrowck-bad-nested-calls-move.stderr @@ -1,6 +1,9 @@ error[E0505]: cannot move out of `a` because it is borrowed --> $DIR/borrowck-bad-nested-calls-move.rs:25:9 | +LL | let mut a: Box<_> = Box::new(1); + | ----- binding `a` declared here +... LL | add( | --- borrow later used by call LL | &*a, @@ -11,6 +14,8 @@ LL | a); error[E0505]: cannot move out of `a` because it is borrowed --> $DIR/borrowck-bad-nested-calls-move.rs:32:9 | +LL | let mut a: Box<_> = Box::new(1); + | ----- binding `a` declared here LL | add( | --- borrow later used by call LL | &*a, diff --git a/tests/ui/borrowck/borrowck-move-mut-base-ptr.stderr b/tests/ui/borrowck/borrowck-move-mut-base-ptr.stderr index d5ff0c501c4..cdad20c52bf 100644 --- a/tests/ui/borrowck/borrowck-move-mut-base-ptr.stderr +++ b/tests/ui/borrowck/borrowck-move-mut-base-ptr.stderr @@ -1,6 +1,8 @@ error[E0505]: cannot move out of `t0` because it is borrowed --> $DIR/borrowck-move-mut-base-ptr.rs:10:14 | +LL | fn foo(t0: &mut isize) { + | -- binding `t0` declared here LL | let p: &isize = &*t0; // Freezes `*t0` | ---- borrow of `*t0` occurs here LL | let t1 = t0; diff --git a/tests/ui/borrowck/borrowck-unary-move.stderr b/tests/ui/borrowck/borrowck-unary-move.stderr index aab225ed4a4..f3b962059f5 100644 --- a/tests/ui/borrowck/borrowck-unary-move.stderr +++ b/tests/ui/borrowck/borrowck-unary-move.stderr @@ -1,6 +1,8 @@ error[E0505]: cannot move out of `x` because it is borrowed --> $DIR/borrowck-unary-move.rs:3:10 | +LL | fn foo(x: Box) -> isize { + | - binding `x` declared here LL | let y = &*x; | --- borrow of `*x` occurs here LL | free(x); diff --git a/tests/ui/nll/polonius/polonius-smoke-test.stderr b/tests/ui/nll/polonius/polonius-smoke-test.stderr index 789d202f73a..534813b2d9f 100644 --- a/tests/ui/nll/polonius/polonius-smoke-test.stderr +++ b/tests/ui/nll/polonius/polonius-smoke-test.stderr @@ -18,7 +18,9 @@ error[E0505]: cannot move out of `x` because it is borrowed --> $DIR/polonius-smoke-test.rs:18:13 | LL | pub fn use_while_mut_fr(x: &mut i32) -> &mut i32 { - | - let's call the lifetime of this reference `'1` + | - - let's call the lifetime of this reference `'1` + | | + | binding `x` declared here LL | let y = &mut *x; | ------- borrow of `*x` occurs here LL | let z = x; @@ -29,6 +31,8 @@ LL | y error[E0505]: cannot move out of `s` because it is borrowed --> $DIR/polonius-smoke-test.rs:42:5 | +LL | let s = &mut 1; + | - binding `s` declared here LL | let r = &mut *s; | ------- borrow of `*s` occurs here LL | let tmp = foo(&r); diff --git a/tests/ui/span/dropck-object-cycle.stderr b/tests/ui/span/dropck-object-cycle.stderr index 229d17e1cf9..097fb6219f1 100644 --- a/tests/ui/span/dropck-object-cycle.stderr +++ b/tests/ui/span/dropck-object-cycle.stderr @@ -1,6 +1,8 @@ error[E0597]: `*m` does not live long enough --> $DIR/dropck-object-cycle.rs:27:31 | +LL | let m : Box = make_val(); + | - binding `m` declared here LL | assert_eq!(object_invoke1(&*m), (4,5)); | ^^^ borrowed value does not live long enough ... diff --git a/tests/ui/span/regions-infer-borrow-scope-within-loop.stderr b/tests/ui/span/regions-infer-borrow-scope-within-loop.stderr index fd67c65c4e9..47931db84ca 100644 --- a/tests/ui/span/regions-infer-borrow-scope-within-loop.stderr +++ b/tests/ui/span/regions-infer-borrow-scope-within-loop.stderr @@ -1,6 +1,9 @@ error[E0597]: `*x` does not live long enough --> $DIR/regions-infer-borrow-scope-within-loop.rs:13:20 | +LL | let x = make_box(); + | - binding `x` declared here +... LL | y = borrow(&*x); | ^^^ borrowed value does not live long enough ... diff --git a/tests/ui/span/send-is-not-static-std-sync.stderr b/tests/ui/span/send-is-not-static-std-sync.stderr index 28b1c5fe715..7dfe94bca60 100644 --- a/tests/ui/span/send-is-not-static-std-sync.stderr +++ b/tests/ui/span/send-is-not-static-std-sync.stderr @@ -1,6 +1,9 @@ error[E0505]: cannot move out of `y` because it is borrowed --> $DIR/send-is-not-static-std-sync.rs:13:10 | +LL | let y = Box::new(1); + | - binding `y` declared here +LL | let lock = Mutex::new(&x); LL | *lock.lock().unwrap() = &*y; | --- borrow of `*y` occurs here LL | drop(y); @@ -25,6 +28,9 @@ LL | lock.use_ref(); // (Mutex is #[may_dangle] so its dtor does not use `z` error[E0505]: cannot move out of `y` because it is borrowed --> $DIR/send-is-not-static-std-sync.rs:27:10 | +LL | let y = Box::new(1); + | - binding `y` declared here +LL | let lock = RwLock::new(&x); LL | *lock.write().unwrap() = &*y; | --- borrow of `*y` occurs here LL | drop(y); @@ -49,6 +55,9 @@ LL | lock.use_ref(); // (RwLock is #[may_dangle] so its dtor does not use `z error[E0505]: cannot move out of `y` because it is borrowed --> $DIR/send-is-not-static-std-sync.rs:43:10 | +LL | let y = Box::new(1); + | - binding `y` declared here +... LL | tx.send(&*y); | --- borrow of `*y` occurs here LL | drop(y); From c6111e8d232964f11eb3540ed7228de6e13782df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Tue, 17 Jan 2023 02:47:50 +0000 Subject: [PATCH 4/5] Account for field access when looking for inner-most path in expression --- compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs | 3 ++- tests/ui/borrowck/borrow-tuple-fields.stderr | 4 ++++ tests/ui/borrowck/borrowck-field-sensitivity.stderr | 4 ++++ .../borrowck-local-borrow-with-panic-outlives-fn.stderr | 2 ++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs index d60facb91b4..b6a676ef636 100644 --- a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs +++ b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs @@ -76,7 +76,8 @@ impl<'tcx> BorrowExplanation<'tcx> { expr_finder.visit_expr(body.value); if let Some(mut expr) = expr_finder.result { while let hir::ExprKind::AddrOf(_, _, inner) - | hir::ExprKind::Unary(hir::UnOp::Deref, inner) = &expr.kind + | hir::ExprKind::Unary(hir::UnOp::Deref, inner) + | hir::ExprKind::Field(inner, _) = &expr.kind { expr = inner; } diff --git a/tests/ui/borrowck/borrow-tuple-fields.stderr b/tests/ui/borrowck/borrow-tuple-fields.stderr index befa751a600..d7d3efe492c 100644 --- a/tests/ui/borrowck/borrow-tuple-fields.stderr +++ b/tests/ui/borrowck/borrow-tuple-fields.stderr @@ -1,6 +1,8 @@ error[E0505]: cannot move out of `x` because it is borrowed --> $DIR/borrow-tuple-fields.rs:12:13 | +LL | let x: (Box<_>, _) = (Box::new(1), 2); + | - binding `x` declared here LL | let r = &x.0; | ---- borrow of `x.0` occurs here LL | let y = x; @@ -32,6 +34,8 @@ LL | a.use_ref(); error[E0505]: cannot move out of `x` because it is borrowed --> $DIR/borrow-tuple-fields.rs:28:13 | +LL | let x = Foo(Box::new(1), 2); + | - binding `x` declared here LL | let r = &x.0; | ---- borrow of `x.0` occurs here LL | let y = x; diff --git a/tests/ui/borrowck/borrowck-field-sensitivity.stderr b/tests/ui/borrowck/borrowck-field-sensitivity.stderr index e009f5913ed..11812847dd1 100644 --- a/tests/ui/borrowck/borrowck-field-sensitivity.stderr +++ b/tests/ui/borrowck/borrowck-field-sensitivity.stderr @@ -41,6 +41,8 @@ LL | let p = &x.b; error[E0505]: cannot move out of `x.b` because it is borrowed --> $DIR/borrowck-field-sensitivity.rs:34:10 | +LL | let x = A { a: 1, b: Box::new(2) }; + | - binding `x` declared here LL | let p = &x.b; | ---- borrow of `x.b` occurs here LL | drop(x.b); @@ -51,6 +53,8 @@ LL | drop(**p); error[E0505]: cannot move out of `x.b` because it is borrowed --> $DIR/borrowck-field-sensitivity.rs:41:14 | +LL | let x = A { a: 1, b: Box::new(2) }; + | - binding `x` declared here LL | let p = &x.b; | ---- borrow of `x.b` occurs here LL | let _y = A { a: 3, .. x }; diff --git a/tests/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.stderr b/tests/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.stderr index 6ea6951ad96..0fdb1dabbc5 100644 --- a/tests/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.stderr +++ b/tests/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.stderr @@ -1,6 +1,8 @@ error[E0597]: `z.1` does not live long enough --> $DIR/borrowck-local-borrow-with-panic-outlives-fn.rs:3:15 | +LL | let mut z = (0, 0); + | ----- binding `z` declared here LL | *x = Some(&mut z.1); | ----------^^^^^^^^- | | | From 7b8251e1886924dde68ff9b6a1c02e9973d0bd0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Tue, 17 Jan 2023 02:52:43 +0000 Subject: [PATCH 5/5] Account for method call and indexing when looking for inner-most path in expression --- .../rustc_borrowck/src/diagnostics/explain_borrow.rs | 4 +++- tests/ui/box/leak-alloc.stderr | 2 ++ tests/ui/dropck/drop-with-active-borrows-1.stderr | 2 ++ tests/ui/generator/dropck.stderr | 3 +++ .../ui/issues/issue-52126-assign-op-invariance.stderr | 2 ++ .../ui/macros/format-args-temporaries-in-write.stderr | 4 ++++ tests/ui/match/issue-74050-end-span.stderr | 1 + tests/ui/moves/move-fn-self-receiver.stderr | 2 ++ tests/ui/nll/issue-54556-niconii.stderr | 3 +++ tests/ui/span/borrowck-let-suggestion-suffixes.rs | 1 + tests/ui/span/borrowck-let-suggestion-suffixes.stderr | 11 +++++++---- tests/ui/span/destructor-restrictions.stderr | 2 ++ ...issue-23338-locals-die-before-temps-of-body.stderr | 4 ++++ tests/ui/span/issue-40157.stderr | 7 ++++--- 14 files changed, 40 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs index b6a676ef636..19855075ced 100644 --- a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs +++ b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs @@ -77,7 +77,9 @@ impl<'tcx> BorrowExplanation<'tcx> { if let Some(mut expr) = expr_finder.result { while let hir::ExprKind::AddrOf(_, _, inner) | hir::ExprKind::Unary(hir::UnOp::Deref, inner) - | hir::ExprKind::Field(inner, _) = &expr.kind + | hir::ExprKind::Field(inner, _) + | hir::ExprKind::MethodCall(_, inner, _, _) + | hir::ExprKind::Index(inner, _) = &expr.kind { expr = inner; } diff --git a/tests/ui/box/leak-alloc.stderr b/tests/ui/box/leak-alloc.stderr index e8a6ad0995a..5140b58934a 100644 --- a/tests/ui/box/leak-alloc.stderr +++ b/tests/ui/box/leak-alloc.stderr @@ -1,6 +1,8 @@ error[E0505]: cannot move out of `alloc` because it is borrowed --> $DIR/leak-alloc.rs:26:10 | +LL | let alloc = Alloc {}; + | ----- binding `alloc` declared here LL | let boxed = Box::new_in(10, alloc.by_ref()); | -------------- borrow of `alloc` occurs here LL | let theref = Box::leak(boxed); diff --git a/tests/ui/dropck/drop-with-active-borrows-1.stderr b/tests/ui/dropck/drop-with-active-borrows-1.stderr index 8d6a7f3721f..4585b22974c 100644 --- a/tests/ui/dropck/drop-with-active-borrows-1.stderr +++ b/tests/ui/dropck/drop-with-active-borrows-1.stderr @@ -1,6 +1,8 @@ error[E0505]: cannot move out of `a` because it is borrowed --> $DIR/drop-with-active-borrows-1.rs:4:10 | +LL | let a = "".to_string(); + | - binding `a` declared here LL | let b: Vec<&str> = a.lines().collect(); | --------- borrow of `a` occurs here LL | drop(a); diff --git a/tests/ui/generator/dropck.stderr b/tests/ui/generator/dropck.stderr index 7bb188352d7..b9a3a124acb 100644 --- a/tests/ui/generator/dropck.stderr +++ b/tests/ui/generator/dropck.stderr @@ -1,6 +1,9 @@ error[E0597]: `*cell` does not live long enough --> $DIR/dropck.rs:10:40 | +LL | let (mut gen, cell); + | ---- binding `cell` declared here +LL | cell = Box::new(RefCell::new(0)); LL | let ref_ = Box::leak(Box::new(Some(cell.borrow_mut()))); | ^^^^^^^^^^^^^^^^^ borrowed value does not live long enough ... diff --git a/tests/ui/issues/issue-52126-assign-op-invariance.stderr b/tests/ui/issues/issue-52126-assign-op-invariance.stderr index d4506757762..2d3b48832c5 100644 --- a/tests/ui/issues/issue-52126-assign-op-invariance.stderr +++ b/tests/ui/issues/issue-52126-assign-op-invariance.stderr @@ -1,6 +1,8 @@ error[E0597]: `line` does not live long enough --> $DIR/issue-52126-assign-op-invariance.rs:34:28 | +LL | for line in vec!["123456789".to_string(), "12345678".to_string()] { + | ---- binding `line` declared here LL | let v: Vec<&str> = line.split_whitespace().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough ... diff --git a/tests/ui/macros/format-args-temporaries-in-write.stderr b/tests/ui/macros/format-args-temporaries-in-write.stderr index 287cd7d6704..520b2ce5052 100644 --- a/tests/ui/macros/format-args-temporaries-in-write.stderr +++ b/tests/ui/macros/format-args-temporaries-in-write.stderr @@ -1,6 +1,8 @@ error[E0597]: `mutex` does not live long enough --> $DIR/format-args-temporaries-in-write.rs:41:27 | +LL | let mutex = Mutex; + | ----- binding `mutex` declared here LL | write!(Out, "{}", mutex.lock()) /* no semicolon */ | ^^^^^^^^^^^^ | | @@ -16,6 +18,8 @@ LL | }; error[E0597]: `mutex` does not live long enough --> $DIR/format-args-temporaries-in-write.rs:47:29 | +LL | let mutex = Mutex; + | ----- binding `mutex` declared here LL | writeln!(Out, "{}", mutex.lock()) /* no semicolon */ | ^^^^^^^^^^^^ | | diff --git a/tests/ui/match/issue-74050-end-span.stderr b/tests/ui/match/issue-74050-end-span.stderr index 59c091e44eb..0b3425f2b1a 100644 --- a/tests/ui/match/issue-74050-end-span.stderr +++ b/tests/ui/match/issue-74050-end-span.stderr @@ -4,6 +4,7 @@ error[E0597]: `arg` does not live long enough LL | let _arg = match args.next() { | ---- borrow later stored here LL | Some(arg) => { + | --- binding `arg` declared here LL | match arg.to_str() { | ^^^^^^^^^^^^ borrowed value does not live long enough ... diff --git a/tests/ui/moves/move-fn-self-receiver.stderr b/tests/ui/moves/move-fn-self-receiver.stderr index 7f69e5dcfb7..91d237b1d1a 100644 --- a/tests/ui/moves/move-fn-self-receiver.stderr +++ b/tests/ui/moves/move-fn-self-receiver.stderr @@ -75,6 +75,8 @@ LL | fn use_pin_box_self(self: Pin>) {} error[E0505]: cannot move out of `mut_foo` because it is borrowed --> $DIR/move-fn-self-receiver.rs:50:5 | +LL | let mut mut_foo = Foo; + | ----------- binding `mut_foo` declared here LL | let ret = mut_foo.use_mut_self(); | ---------------------- borrow of `mut_foo` occurs here LL | mut_foo; diff --git a/tests/ui/nll/issue-54556-niconii.stderr b/tests/ui/nll/issue-54556-niconii.stderr index a8e1edc5497..d41d462f2bc 100644 --- a/tests/ui/nll/issue-54556-niconii.stderr +++ b/tests/ui/nll/issue-54556-niconii.stderr @@ -1,6 +1,9 @@ error[E0597]: `counter` does not live long enough --> $DIR/issue-54556-niconii.rs:22:20 | +LL | let counter = Mutex; + | ------- binding `counter` declared here +LL | LL | if let Ok(_) = counter.lock() { } | ^^^^^^^^^^^^^^ | | diff --git a/tests/ui/span/borrowck-let-suggestion-suffixes.rs b/tests/ui/span/borrowck-let-suggestion-suffixes.rs index 18abfb5c3fb..ad556f281df 100644 --- a/tests/ui/span/borrowck-let-suggestion-suffixes.rs +++ b/tests/ui/span/borrowck-let-suggestion-suffixes.rs @@ -8,6 +8,7 @@ fn f() { { let young = ['y']; // statement 3 + //~^ NOTE binding `young` declared here v2.push(&young[0]); // statement 4 //~^ ERROR `young[_]` does not live long enough diff --git a/tests/ui/span/borrowck-let-suggestion-suffixes.stderr b/tests/ui/span/borrowck-let-suggestion-suffixes.stderr index 2dc29a78d20..545b235a552 100644 --- a/tests/ui/span/borrowck-let-suggestion-suffixes.stderr +++ b/tests/ui/span/borrowck-let-suggestion-suffixes.stderr @@ -1,6 +1,9 @@ error[E0597]: `young[_]` does not live long enough - --> $DIR/borrowck-let-suggestion-suffixes.rs:12:17 + --> $DIR/borrowck-let-suggestion-suffixes.rs:13:17 | +LL | let young = ['y']; // statement 3 + | ----- binding `young` declared here +... LL | v2.push(&young[0]); // statement 4 | ^^^^^^^^^ borrowed value does not live long enough ... @@ -11,7 +14,7 @@ LL | (v1, v2, v3, /* v4 is above. */ v5).use_ref(); | -- borrow later used here error[E0716]: temporary value dropped while borrowed - --> $DIR/borrowck-let-suggestion-suffixes.rs:19:14 + --> $DIR/borrowck-let-suggestion-suffixes.rs:20:14 | LL | v3.push(&id('x')); // statement 6 | ^^^^^^^ - temporary value is freed at the end of this statement @@ -28,7 +31,7 @@ LL ~ v3.push(&binding); // statement 6 | error[E0716]: temporary value dropped while borrowed - --> $DIR/borrowck-let-suggestion-suffixes.rs:29:18 + --> $DIR/borrowck-let-suggestion-suffixes.rs:30:18 | LL | v4.push(&id('y')); | ^^^^^^^ - temporary value is freed at the end of this statement @@ -41,7 +44,7 @@ LL | v4.use_ref(); = note: consider using a `let` binding to create a longer lived value error[E0716]: temporary value dropped while borrowed - --> $DIR/borrowck-let-suggestion-suffixes.rs:40:14 + --> $DIR/borrowck-let-suggestion-suffixes.rs:41:14 | LL | v5.push(&id('z')); | ^^^^^^^ - temporary value is freed at the end of this statement diff --git a/tests/ui/span/destructor-restrictions.stderr b/tests/ui/span/destructor-restrictions.stderr index 53c9404620f..281248626c8 100644 --- a/tests/ui/span/destructor-restrictions.stderr +++ b/tests/ui/span/destructor-restrictions.stderr @@ -1,6 +1,8 @@ error[E0597]: `*a` does not live long enough --> $DIR/destructor-restrictions.rs:8:10 | +LL | let a = Box::new(RefCell::new(4)); + | - binding `a` declared here LL | *a.borrow() + 1 | ^^^^^^^^^^ | | diff --git a/tests/ui/span/issue-23338-locals-die-before-temps-of-body.stderr b/tests/ui/span/issue-23338-locals-die-before-temps-of-body.stderr index 3c2022748f0..e1a377203e2 100644 --- a/tests/ui/span/issue-23338-locals-die-before-temps-of-body.stderr +++ b/tests/ui/span/issue-23338-locals-die-before-temps-of-body.stderr @@ -1,6 +1,8 @@ error[E0597]: `y` does not live long enough --> $DIR/issue-23338-locals-die-before-temps-of-body.rs:10:5 | +LL | let y = x; + | - binding `y` declared here LL | y.borrow().clone() | ^^^^^^^^^^ | | @@ -22,6 +24,8 @@ LL | let x = y.borrow().clone(); x error[E0597]: `y` does not live long enough --> $DIR/issue-23338-locals-die-before-temps-of-body.rs:17:9 | +LL | let y = x; + | - binding `y` declared here LL | y.borrow().clone() | ^^^^^^^^^^ | | diff --git a/tests/ui/span/issue-40157.stderr b/tests/ui/span/issue-40157.stderr index e9b84de5059..a0afd33f7c7 100644 --- a/tests/ui/span/issue-40157.stderr +++ b/tests/ui/span/issue-40157.stderr @@ -2,9 +2,10 @@ error[E0597]: `foo` does not live long enough --> $DIR/issue-40157.rs:2:53 | LL | {println!("{:?}", match { let foo = vec![1, 2]; foo.get(1) } { x => x });} - | ^^^^^^^^^^ - `foo` dropped here while still borrowed - | | - | borrowed value does not live long enough + | --- ^^^^^^^^^^ - `foo` dropped here while still borrowed + | | | + | | borrowed value does not live long enough + | binding `foo` declared here error: aborting due to previous error