Rollup merge of #106897 - estebank:issue-99430, r=davidtwco

Tweak E0597

CC #99430
This commit is contained in:
Matthias Krüger 2023-01-25 22:19:52 +01:00 committed by GitHub
commit 9e3f330656
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
230 changed files with 853 additions and 354 deletions

View File

@ -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
}

View File

@ -1736,7 +1736,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
&self.local_names,
&mut err,
"",
None,
Some(borrow_span),
None,
);
}

View File

@ -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,36 @@ impl<'tcx> BorrowExplanation<'tcx> {
borrow_span: Option<Span>,
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)
| hir::ExprKind::Unary(hir::UnOp::Deref, inner)
| hir::ExprKind::Field(inner, _)
| hir::ExprKind::MethodCall(_, inner, _, _)
| hir::ExprKind::Index(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 {

View File

@ -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"));
}
}
}

View File

@ -2825,7 +2825,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 }
}
}

View File

@ -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 | }

View File

@ -1,6 +1,8 @@
error[E0597]: `arena` does not live long enough
--> $DIR/dropck-tarena-unsound-drop.rs:41:7
|
LL | let arena: TypedArena<C> = TypedArena::default();
| ----- binding `arena` declared here
LL | f(&arena);
| ^^^^^^ borrowed value does not live long enough
LL | }

View File

@ -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 |

View File

@ -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(<T as Foo<'a>>::Bar)>(x: T, f: F) {
| - binding `x` declared here
...
LL | 's: loop { y = denormalise(&x); break }
| -- borrow of `x` occurs here
LL | drop(x);

View File

@ -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 | }

View File

@ -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`

View File

@ -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

View File

@ -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
+=

View File

@ -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
...

View File

@ -41,6 +41,8 @@ LL | fn move_then_borrow<T: Add<Output=()> + 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<T: Add<Output=()>>(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<T: Add<Output=()>>(x: T, mut y: T) {
| ----- binding `y` declared here
LL | let m = &x;
LL | let n = &mut y;
| ------ borrow of `y` occurs here
...

View File

@ -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;

View File

@ -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`

View File

@ -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

View File

@ -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

View File

@ -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,

View File

@ -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

View File

@ -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`
...

View File

@ -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 };

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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|| {

View File

@ -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);

View File

@ -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

View File

@ -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`

View File

@ -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);
| ----------^^^^^^^^-
| | |

View File

@ -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`

View File

@ -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<isize>`, which does not implement the `Copy` trait
| move out of `bar` occurs here
| `bar` is moved here
error: aborting due to previous error

View File

@ -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<_>> = Box::new(Box::new(2));
| - binding `a` declared here
LL | let b = &a;
| -- borrow of `a` occurs here
LL |

View File

@ -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;

View File

@ -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;

View File

@ -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|| {

View File

@ -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

View File

@ -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

View File

@ -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
...

View File

@ -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

View File

@ -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>) -> isize {
| - binding `x` declared here
LL | let y = &*x;
| --- borrow of `*x` occurs here
LL | free(x);

View File

@ -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();

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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<isize>] = &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
}

View File

@ -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

View File

@ -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
| |

View File

@ -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

View File

@ -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

View File

@ -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
|

View File

@ -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

View File

@ -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

View File

@ -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
|

View File

@ -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
|

View File

@ -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
|

View File

@ -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
|

View File

@ -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
|

View File

@ -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
|

View File

@ -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
|

View File

@ -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

View File

@ -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`

View File

@ -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 |

View File

@ -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);

View File

@ -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);

View File

@ -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;
| ------^^^^^^^^
| | |

View File

@ -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
...

View File

@ -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

View File

@ -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
}

View File

@ -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

View File

@ -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

View File

@ -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 | };

View File

@ -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);

View File

@ -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
...

View File

@ -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
...

View File

@ -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
...

View File

@ -1,6 +1,8 @@
error[E0597]: `v` does not live long enough
--> $DIR/dropck-union.rs:37:18
|
LL | let v : Wrap<C> = Wrap::new(C(Cell::new(None)));
| - binding `v` declared here
LL | v.0.set(Some(&v));
| ^^ borrowed value does not live long enough
LL | }

View File

@ -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<dyn Obj>, Box<dyn Obj>, Box<dyn Obj>) = (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<dyn Obj>, Box<dyn Obj>, Box<dyn Obj>) = (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<dyn Obj>, Box<dyn Obj>, Box<dyn Obj>) = (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<dyn Obj>, Box<dyn Obj>, Box<dyn Obj>) = (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<dyn Obj>, Box<dyn Obj>, Box<dyn Obj>) = (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<dyn Obj>, Box<dyn Obj>, Box<dyn Obj>) = (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

View File

@ -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<Foo> = &f1;
| ^^^ borrowed value does not live long enough
LL | let f3: &'a Fat<dyn Bar> = 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;

View File

@ -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();

View File

@ -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 |

View File

@ -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);

View File

@ -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

View File

@ -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 |

View File

@ -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);

View File

@ -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);

View File

@ -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
...

View File

@ -4,6 +4,7 @@ error[E0597]: `a` does not live long enough
LL | fn bug<'a, T: ?Sized + Fun<F<'a> = [u8]>>(_ : Box<T>) -> &'static T::F<'a> {
| -- lifetime `'a` defined here
LL | let a = [0; 1];
| - binding `a` declared here
LL | let _x = T::identity(&a);
| ------------^^-
| | |

View File

@ -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

View File

@ -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 |

View File

@ -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);
| -----^^------
| | |

View File

@ -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 });
| ------------------^^-
| | |

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
...

View File

@ -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 |

View File

@ -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 */
| ^^^^^^^^^^^^
| |

Some files were not shown because too many files have changed in this diff Show More