diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:43 +0000 |
commit | 3e3e70d529d8c7d7c4d7bc4fefc9f109393b9245 (patch) | |
tree | daf049b282ab10e8c3d03e409b3cd84ff3f7690c /tests/ui/borrowck | |
parent | Adding debian version 1.68.2+dfsg1-1. (diff) | |
download | rustc-3e3e70d529d8c7d7c4d7bc4fefc9f109393b9245.tar.xz rustc-3e3e70d529d8c7d7c4d7bc4fefc9f109393b9245.zip |
Merging upstream version 1.69.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/borrowck')
66 files changed, 351 insertions, 178 deletions
diff --git a/tests/ui/borrowck/bindings-after-at-or-patterns-slice-patterns-box-patterns.stderr b/tests/ui/borrowck/bindings-after-at-or-patterns-slice-patterns-box-patterns.stderr index 50eee1049..5835f0675 100644 --- a/tests/ui/borrowck/bindings-after-at-or-patterns-slice-patterns-box-patterns.stderr +++ b/tests/ui/borrowck/bindings-after-at-or-patterns-slice-patterns-box-patterns.stderr @@ -4,8 +4,8 @@ error: cannot borrow value as mutable because it is also borrowed as immutable LL | ref foo @ [.., ref mut bar] => (), | -------^^^^^^^^-----------^ | | | - | | mutable borrow, by `bar`, occurs here - | immutable borrow, by `foo`, occurs here + | | value is mutably borrowed by `bar` here + | value is borrowed by `foo` here error: cannot borrow value as mutable because it is also borrowed as immutable --> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:120:9 @@ -13,8 +13,8 @@ error: cannot borrow value as mutable because it is also borrowed as immutable LL | ref foo @ Some(box ref mut s) => (), | -------^^^^^^^^^^^^---------^ | | | - | | mutable borrow, by `s`, occurs here - | immutable borrow, by `foo`, occurs here + | | value is mutably borrowed by `s` here + | value is borrowed by `foo` here error[E0382]: borrow of moved value: `x` --> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:18:5 diff --git a/tests/ui/borrowck/borrow-tuple-fields.stderr b/tests/ui/borrowck/borrow-tuple-fields.stderr index befa751a6..d7d3efe49 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-anon-fields-variant.stderr b/tests/ui/borrowck/borrowck-anon-fields-variant.stderr index 98f6f00a7..c1d668f74 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 2b7cef7b3..d35f2331a 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 0b21d113f..8c0a8efcc 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-bad-nested-calls-move.stderr b/tests/ui/borrowck/borrowck-bad-nested-calls-move.stderr index 371bcf2b6..e582ec605 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-borrow-mut-base-ptr-in-aliasable-loc.stderr b/tests/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr index ce9f7aa05..dd0817ff2 100644 --- a/tests/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr +++ b/tests/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr @@ -1,11 +1,13 @@ error[E0594]: cannot assign to `**t1`, which is behind a `&` reference --> $DIR/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs:9:5 | -LL | let t1 = t0; - | -- consider changing this binding's type to be: `&mut &mut isize` -LL | let p: &isize = &**t0; LL | **t1 = 22; | ^^^^^^^^^ `t1` is a `&` reference, so the data it refers to cannot be written + | +help: consider specifying this binding's type + | +LL | let t1: &mut &mut isize = t0; + | +++++++++++++++++ error[E0502]: cannot borrow `**t0` as immutable because it is also borrowed as mutable --> $DIR/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs:14:21 diff --git a/tests/ui/borrowck/borrowck-closures-mut-and-imm.stderr b/tests/ui/borrowck/borrowck-closures-mut-and-imm.stderr index fadcd11a5..8a7870e0c 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 2c1b9c10d..cb29c9fda 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-field-sensitivity.stderr b/tests/ui/borrowck/borrowck-field-sensitivity.stderr index e009f5913..11812847d 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-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 a66db05cc..1a20ec85f 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 42a55b7a8..374c5ee3e 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 66f1cd9bd..6cdce7bee 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 3548da35b..6eabfff90 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 b5c6b101f..38e06fa01 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 6994c837d..311369a26 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 24cc4933e..f1640d3b7 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-local-borrow-with-panic-outlives-fn.stderr b/tests/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.stderr index 6ea6951ad..0fdb1dabb 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); | ----------^^^^^^^^- | | | diff --git a/tests/ui/borrowck/borrowck-match-already-borrowed.stderr b/tests/ui/borrowck/borrowck-match-already-borrowed.stderr index 39047be9d..e5c0ec960 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 8ddc48b2a..6eaa1fa31 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<isize>`, 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 f833abcc0..bd94f1a42 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<_>> = 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-mut-base-ptr.stderr b/tests/ui/borrowck/borrowck-move-mut-base-ptr.stderr index d5ff0c501..cdad20c52 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-move-subcomponent.stderr b/tests/ui/borrowck/borrowck-move-subcomponent.stderr index 8c9083fcf..341146bd1 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 f94cbc30d..70abe7b34 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 5d52e4919..7f42becd2 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 087f2ac79..fb7af50bc 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 fb0e274c2..7f8cc74a7 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 9e65ccf5a..b86a86938 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-unary-move.stderr b/tests/ui/borrowck/borrowck-unary-move.stderr index aab225ed4..f3b962059 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>) -> isize { + | - binding `x` declared here LL | let y = &*x; | --- borrow of `*x` occurs here LL | free(x); diff --git a/tests/ui/borrowck/borrowck-union-borrow-nested.stderr b/tests/ui/borrowck/borrowck-union-borrow-nested.stderr index 4bd7d54cf..a87a14e7c 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 090c7b6b5..11a28f674 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 91d69c51e..4d300ae3c 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 0ac7df944..494d8c351 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 0e9284a2c..1bda7a497 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<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 } diff --git a/tests/ui/borrowck/borrowck-vec-pattern-nesting.stderr b/tests/ui/borrowck/borrowck-vec-pattern-nesting.stderr index 0dc5e64e4..70b9e4f44 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-103624.rs b/tests/ui/borrowck/issue-103624.rs index f1fa95f92..d95a40bd4 100644 --- a/tests/ui/borrowck/issue-103624.rs +++ b/tests/ui/borrowck/issue-103624.rs @@ -12,7 +12,7 @@ impl StructA { async fn foo(&self) { let bar = self.b.bar().await; spawn_blocking(move || { - //~^ ERROR borrowed data escapes outside of associated function + //~^ ERROR borrowed data escapes outside of method self.b; //~^ ERROR cannot move out of `self.b`, as `self` is a captured variable in an `Fn` closure }) diff --git a/tests/ui/borrowck/issue-103624.stderr b/tests/ui/borrowck/issue-103624.stderr index e6a35dd88..7a281e8aa 100644 --- a/tests/ui/borrowck/issue-103624.stderr +++ b/tests/ui/borrowck/issue-103624.stderr @@ -10,13 +10,13 @@ LL | LL | self.b; | ^^^^^^ move occurs because `self.b` has type `StructB`, which does not implement the `Copy` trait -error[E0521]: borrowed data escapes outside of associated function +error[E0521]: borrowed data escapes outside of method --> $DIR/issue-103624.rs:14:9 | LL | async fn foo(&self) { | ----- | | - | `self` is a reference that is only valid in the associated function body + | `self` is a reference that is only valid in the method body | let's call the lifetime of this reference `'1` LL | let bar = self.b.bar().await; LL | / spawn_blocking(move || { @@ -26,7 +26,7 @@ LL | | LL | | }) | | ^ | | | - | |__________`self` escapes the associated function body here + | |__________`self` escapes the method body here | argument requires that `'1` must outlive `'static` error: aborting due to 2 previous errors diff --git a/tests/ui/borrowck/issue-25793.stderr b/tests/ui/borrowck/issue-25793.stderr index da3412f11..27dab53e4 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 4abb6fb2c..3f7715645 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 57803247b..0870b4237 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 d79394834..0d803b042 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 27123ef2b..d0986e9f9 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 0770c1366..5f7e86f11 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 764eaaa7c..d9aeaf15f 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 9447174fd..0c0d1994b 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 0ab3fa927..98093daa9 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 20ff229ff..c00e48288 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 575aed73b..e61dc95ec 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 52d2d9e75..0565127e3 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 fd83e10a2..0ca732ff2 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 c7d48214f..4d305268a 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/issue-82126-mismatched-subst-and-hir.rs b/tests/ui/borrowck/issue-82126-mismatched-subst-and-hir.rs index dd0320bc5..d067ff447 100644 --- a/tests/ui/borrowck/issue-82126-mismatched-subst-and-hir.rs +++ b/tests/ui/borrowck/issue-82126-mismatched-subst-and-hir.rs @@ -14,8 +14,8 @@ impl MarketMultiplier { } async fn buy_lock(generator: &Mutex<MarketMultiplier>) -> LockedMarket<'_> { - //~^ ERROR this struct takes 0 lifetime arguments but 1 lifetime argument was supplied - //~^^ ERROR this struct takes 1 generic argument but 0 generic arguments were supplied + //~^ ERROR struct takes 0 lifetime arguments but 1 lifetime argument was supplied + //~^^ ERROR struct takes 1 generic argument but 0 generic arguments were supplied LockedMarket(generator.lock().unwrap().buy()) } diff --git a/tests/ui/borrowck/issue-82126-mismatched-subst-and-hir.stderr b/tests/ui/borrowck/issue-82126-mismatched-subst-and-hir.stderr index d2b927fb6..73e0aaf1e 100644 --- a/tests/ui/borrowck/issue-82126-mismatched-subst-and-hir.stderr +++ b/tests/ui/borrowck/issue-82126-mismatched-subst-and-hir.stderr @@ -1,4 +1,4 @@ -error[E0107]: this struct takes 0 lifetime arguments but 1 lifetime argument was supplied +error[E0107]: struct takes 0 lifetime arguments but 1 lifetime argument was supplied --> $DIR/issue-82126-mismatched-subst-and-hir.rs:16:59 | LL | async fn buy_lock(generator: &Mutex<MarketMultiplier>) -> LockedMarket<'_> { @@ -12,7 +12,7 @@ note: struct defined here, with 0 lifetime parameters LL | struct LockedMarket<T>(T); | ^^^^^^^^^^^^ -error[E0107]: this struct takes 1 generic argument but 0 generic arguments were supplied +error[E0107]: struct takes 1 generic argument but 0 generic arguments were supplied --> $DIR/issue-82126-mismatched-subst-and-hir.rs:16:59 | LL | async fn buy_lock(generator: &Mutex<MarketMultiplier>) -> LockedMarket<'_> { diff --git a/tests/ui/borrowck/issue-83924.fixed b/tests/ui/borrowck/issue-83924.fixed new file mode 100644 index 000000000..aa40da12b --- /dev/null +++ b/tests/ui/borrowck/issue-83924.fixed @@ -0,0 +1,20 @@ +// run-rustfix + +fn main() { + let mut values = vec![10, 11, 12]; + let v = &mut values; + + let mut max = 0; + + for n in &mut *v { + max = std::cmp::max(max, *n); + } + + println!("max is {}", max); + println!("Converting to percentages of maximum value..."); + for n in v { + //~^ ERROR: use of moved value: `v` [E0382] + *n = 100 * (*n) / max; + } + println!("values: {:#?}", values); +} diff --git a/tests/ui/borrowck/issue-83924.rs b/tests/ui/borrowck/issue-83924.rs new file mode 100644 index 000000000..22b80fe2f --- /dev/null +++ b/tests/ui/borrowck/issue-83924.rs @@ -0,0 +1,20 @@ +// run-rustfix + +fn main() { + let mut values = vec![10, 11, 12]; + let v = &mut values; + + let mut max = 0; + + for n in v { + max = std::cmp::max(max, *n); + } + + println!("max is {}", max); + println!("Converting to percentages of maximum value..."); + for n in v { + //~^ ERROR: use of moved value: `v` [E0382] + *n = 100 * (*n) / max; + } + println!("values: {:#?}", values); +} diff --git a/tests/ui/borrowck/issue-83924.stderr b/tests/ui/borrowck/issue-83924.stderr new file mode 100644 index 000000000..572414df2 --- /dev/null +++ b/tests/ui/borrowck/issue-83924.stderr @@ -0,0 +1,22 @@ +error[E0382]: use of moved value: `v` + --> $DIR/issue-83924.rs:15:14 + | +LL | let v = &mut values; + | - move occurs because `v` has type `&mut Vec<i32>`, which does not implement the `Copy` trait +... +LL | for n in v { + | - `v` moved due to this implicit call to `.into_iter()` +... +LL | for n in v { + | ^ value used here after move + | +note: `into_iter` takes ownership of the receiver `self`, which moves `v` + --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL +help: consider creating a fresh reborrow of `v` here + | +LL | for n in &mut *v { + | ++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/tests/ui/borrowck/issue-85765.rs b/tests/ui/borrowck/issue-85765.rs index 1598cd5d3..76e0b5173 100644 --- a/tests/ui/borrowck/issue-85765.rs +++ b/tests/ui/borrowck/issue-85765.rs @@ -1,7 +1,7 @@ fn main() { let mut test = Vec::new(); let rofl: &Vec<Vec<i32>> = &mut test; - //~^ NOTE consider changing this binding's type to be + //~^ HELP consider changing this binding's type rofl.push(Vec::new()); //~^ ERROR cannot borrow `*rofl` as mutable, as it is behind a `&` reference //~| NOTE `rofl` is a `&` reference, so the data it refers to cannot be borrowed as mutable @@ -15,14 +15,14 @@ fn main() { #[rustfmt::skip] let x: &usize = &mut{0}; - //~^ NOTE consider changing this binding's type to be + //~^ HELP consider changing this binding's type *x = 1; //~^ ERROR cannot assign to `*x`, which is behind a `&` reference //~| NOTE `x` is a `&` reference, so the data it refers to cannot be written #[rustfmt::skip] let y: &usize = &mut(0); - //~^ NOTE consider changing this binding's type to be + //~^ HELP consider changing this binding's type *y = 1; //~^ ERROR cannot assign to `*y`, which is behind a `&` reference //~| NOTE `y` is a `&` reference, so the data it refers to cannot be written diff --git a/tests/ui/borrowck/issue-85765.stderr b/tests/ui/borrowck/issue-85765.stderr index 7da7dba68..b4bb128cb 100644 --- a/tests/ui/borrowck/issue-85765.stderr +++ b/tests/ui/borrowck/issue-85765.stderr @@ -1,11 +1,13 @@ error[E0596]: cannot borrow `*rofl` as mutable, as it is behind a `&` reference --> $DIR/issue-85765.rs:5:5 | -LL | let rofl: &Vec<Vec<i32>> = &mut test; - | ---- consider changing this binding's type to be: `&mut Vec<Vec<i32>>` -LL | LL | rofl.push(Vec::new()); | ^^^^^^^^^^^^^^^^^^^^^ `rofl` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | +help: consider changing this binding's type + | +LL | let rofl: &mut Vec<Vec<i32>> = &mut test; + | ~~~~~~~~~~~~~~~~~~ error[E0594]: cannot assign to `*r`, which is behind a `&` reference --> $DIR/issue-85765.rs:12:5 @@ -21,20 +23,24 @@ LL | let r = &mut mutvar; error[E0594]: cannot assign to `*x`, which is behind a `&` reference --> $DIR/issue-85765.rs:19:5 | -LL | let x: &usize = &mut{0}; - | - consider changing this binding's type to be: `&mut usize` -LL | LL | *x = 1; | ^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written + | +help: consider changing this binding's type + | +LL | let x: &mut usize = &mut{0}; + | ~~~~~~~~~~ error[E0594]: cannot assign to `*y`, which is behind a `&` reference --> $DIR/issue-85765.rs:26:5 | -LL | let y: &usize = &mut(0); - | - consider changing this binding's type to be: `&mut usize` -LL | LL | *y = 1; | ^^^^^^ `y` is a `&` reference, so the data it refers to cannot be written + | +help: consider changing this binding's type + | +LL | let y: &mut usize = &mut(0); + | ~~~~~~~~~~ error: aborting due to 4 previous errors diff --git a/tests/ui/borrowck/issue-91206.rs b/tests/ui/borrowck/issue-91206.rs index 67407c1ea..e062a2537 100644 --- a/tests/ui/borrowck/issue-91206.rs +++ b/tests/ui/borrowck/issue-91206.rs @@ -9,7 +9,7 @@ impl TestClient { fn main() { let client = TestClient; let inner = client.get_inner_ref(); - //~^ NOTE consider changing this binding's type to be + //~^ HELP consider specifying this binding's type inner.clear(); //~^ ERROR cannot borrow `*inner` as mutable, as it is behind a `&` reference [E0596] //~| NOTE `inner` is a `&` reference, so the data it refers to cannot be borrowed as mutable diff --git a/tests/ui/borrowck/issue-91206.stderr b/tests/ui/borrowck/issue-91206.stderr index 12d8d27c5..6653d4978 100644 --- a/tests/ui/borrowck/issue-91206.stderr +++ b/tests/ui/borrowck/issue-91206.stderr @@ -1,11 +1,13 @@ error[E0596]: cannot borrow `*inner` as mutable, as it is behind a `&` reference --> $DIR/issue-91206.rs:13:5 | -LL | let inner = client.get_inner_ref(); - | ----- consider changing this binding's type to be: `&mut Vec<usize>` -LL | LL | inner.clear(); | ^^^^^^^^^^^^^ `inner` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | +help: consider specifying this binding's type + | +LL | let inner: &mut Vec<usize> = client.get_inner_ref(); + | +++++++++++++++++ error: aborting due to previous error diff --git a/tests/ui/borrowck/issue-92015.stderr b/tests/ui/borrowck/issue-92015.stderr index 62b1183e7..ea4f9abb8 100644 --- a/tests/ui/borrowck/issue-92015.stderr +++ b/tests/ui/borrowck/issue-92015.stderr @@ -1,10 +1,13 @@ error[E0594]: cannot assign to `*foo`, which is behind a `&` reference --> $DIR/issue-92015.rs:6:5 | -LL | let foo = Some(&0).unwrap(); - | --- consider changing this binding's type to be: `&mut i32` LL | *foo = 1; | ^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be written + | +help: consider specifying this binding's type + | +LL | let foo: &mut i32 = Some(&0).unwrap(); + | ++++++++++ error: aborting due to previous error diff --git a/tests/ui/borrowck/issue-95079-missing-move-in-nested-closure.fixed b/tests/ui/borrowck/issue-95079-missing-move-in-nested-closure.fixed new file mode 100644 index 000000000..1a0847006 --- /dev/null +++ b/tests/ui/borrowck/issue-95079-missing-move-in-nested-closure.fixed @@ -0,0 +1,26 @@ +// run-rustfix +#![allow(dead_code, path_statements)] +fn foo1(s: &str) -> impl Iterator<Item = String> + '_ { + None.into_iter() + .flat_map(move |()| s.chars().map(move |c| format!("{}{}", c, s))) + //~^ ERROR captured variable cannot escape `FnMut` closure body + //~| HELP consider adding 'move' keyword before the nested closure +} + +fn foo2(s: &str) -> impl Sized + '_ { + move |()| s.chars().map(move |c| format!("{}{}", c, s)) + //~^ ERROR lifetime may not live long enough + //~| HELP consider adding 'move' keyword before the nested closure +} + +pub struct X; +pub fn foo3<'a>( + bar: &'a X, +) -> impl Iterator<Item = ()> + 'a { + Some(()).iter().flat_map(move |()| { + Some(()).iter().map(move |()| { bar; }) //~ ERROR captured variable cannot escape + //~^ HELP consider adding 'move' keyword before the nested closure + }) +} + +fn main() {} diff --git a/tests/ui/borrowck/issue-95079-missing-move-in-nested-closure.rs b/tests/ui/borrowck/issue-95079-missing-move-in-nested-closure.rs index 95847d8d3..b93292e35 100644 --- a/tests/ui/borrowck/issue-95079-missing-move-in-nested-closure.rs +++ b/tests/ui/borrowck/issue-95079-missing-move-in-nested-closure.rs @@ -1,3 +1,5 @@ +// run-rustfix +#![allow(dead_code, path_statements)] fn foo1(s: &str) -> impl Iterator<Item = String> + '_ { None.into_iter() .flat_map(move |()| s.chars().map(|c| format!("{}{}", c, s))) @@ -11,4 +13,14 @@ fn foo2(s: &str) -> impl Sized + '_ { //~| HELP consider adding 'move' keyword before the nested closure } +pub struct X; +pub fn foo3<'a>( + bar: &'a X, +) -> impl Iterator<Item = ()> + 'a { + Some(()).iter().flat_map(move |()| { + Some(()).iter().map(|()| { bar; }) //~ ERROR captured variable cannot escape + //~^ HELP consider adding 'move' keyword before the nested closure + }) +} + fn main() {} diff --git a/tests/ui/borrowck/issue-95079-missing-move-in-nested-closure.stderr b/tests/ui/borrowck/issue-95079-missing-move-in-nested-closure.stderr index 2eae614a2..776c338de 100644 --- a/tests/ui/borrowck/issue-95079-missing-move-in-nested-closure.stderr +++ b/tests/ui/borrowck/issue-95079-missing-move-in-nested-closure.stderr @@ -1,5 +1,5 @@ error: captured variable cannot escape `FnMut` closure body - --> $DIR/issue-95079-missing-move-in-nested-closure.rs:3:29 + --> $DIR/issue-95079-missing-move-in-nested-closure.rs:5:29 | LL | fn foo1(s: &str) -> impl Iterator<Item = String> + '_ { | - variable defined here @@ -7,7 +7,7 @@ LL | None.into_iter() LL | .flat_map(move |()| s.chars().map(|c| format!("{}{}", c, s))) | - -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | - | | returns a reference to a captured variable which escapes the closure body + | | returns a closure that contains a reference to a captured variable, which then escapes the closure body | | variable captured here | inferred to be a `FnMut` closure | @@ -19,12 +19,12 @@ LL | .flat_map(move |()| s.chars().map(move |c| format!("{}{}", c, s))) | ++++ error: lifetime may not live long enough - --> $DIR/issue-95079-missing-move-in-nested-closure.rs:9:15 + --> $DIR/issue-95079-missing-move-in-nested-closure.rs:11:15 | LL | move |()| s.chars().map(|c| format!("{}{}", c, s)) | --------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'1` must outlive `'2` | | | - | | return type of closure `Map<Chars<'_>, [closure@$DIR/issue-95079-missing-move-in-nested-closure.rs:9:29: 9:32]>` contains a lifetime `'2` + | | return type of closure `Map<Chars<'_>, [closure@$DIR/issue-95079-missing-move-in-nested-closure.rs:11:29: 11:32]>` contains a lifetime `'2` | lifetime `'1` represents this closure's body | = note: closure implements `Fn`, so references to captured variables can't escape the closure @@ -33,5 +33,26 @@ help: consider adding 'move' keyword before the nested closure LL | move |()| s.chars().map(move |c| format!("{}{}", c, s)) | ++++ -error: aborting due to 2 previous errors +error: captured variable cannot escape `FnMut` closure body + --> $DIR/issue-95079-missing-move-in-nested-closure.rs:21:9 + | +LL | bar: &'a X, + | --- variable defined here +LL | ) -> impl Iterator<Item = ()> + 'a { +LL | Some(()).iter().flat_map(move |()| { + | - inferred to be a `FnMut` closure +LL | Some(()).iter().map(|()| { bar; }) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^---^^^^ + | | | + | | variable captured here + | returns a closure that contains a reference to a captured variable, which then escapes the closure body + | + = note: `FnMut` closures only have access to their captured variables while they are executing... + = note: ...therefore, they cannot allow references to captured variables to escape +help: consider adding 'move' keyword before the nested closure + | +LL | Some(()).iter().map(move |()| { bar; }) + | ++++ + +error: aborting due to 3 previous errors 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 a57ceb847..1356c8049 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 5a240d900..e75094d4f 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 | |