2018-08-08 12:28:26 +00:00
|
|
|
error[E0499]: cannot borrow `x` as mutable more than once at a time
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-describe-lvalue.rs:254:13
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let y = &mut x;
|
|
|
|
| ------ first mutable borrow occurs here
|
2019-03-17 09:52:07 +00:00
|
|
|
LL | &mut x;
|
2018-08-08 12:28:26 +00:00
|
|
|
| ^^^^^^ second mutable borrow occurs here
|
|
|
|
LL | *y = 1;
|
2018-09-29 10:47:47 +00:00
|
|
|
| ------ first borrow later used here
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
error[E0499]: cannot borrow `x` as mutable more than once at a time
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-describe-lvalue.rs:264:20
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let y = &mut x;
|
|
|
|
| ------ first mutable borrow occurs here
|
2019-03-17 09:52:07 +00:00
|
|
|
LL | &mut x;
|
2018-08-08 12:28:26 +00:00
|
|
|
| ^^^^^^ second mutable borrow occurs here
|
|
|
|
LL | *y = 1;
|
2018-09-29 10:47:47 +00:00
|
|
|
| ------ first borrow later used here
|
2018-08-08 12:28:26 +00:00
|
|
|
|
2018-10-29 23:37:38 +00:00
|
|
|
error: captured variable cannot escape `FnMut` closure body
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-describe-lvalue.rs:262:16
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
2020-05-24 01:40:55 +00:00
|
|
|
LL | let mut x = 0;
|
|
|
|
| ----- variable defined here
|
2018-08-08 12:50:16 +00:00
|
|
|
LL | || {
|
2018-10-03 23:50:23 +00:00
|
|
|
| - inferred to be a `FnMut` closure
|
2019-03-17 09:52:07 +00:00
|
|
|
LL | / || {
|
2018-08-08 12:50:16 +00:00
|
|
|
LL | | let y = &mut x;
|
2020-05-24 01:40:55 +00:00
|
|
|
| | - variable captured here
|
2019-03-17 09:52:07 +00:00
|
|
|
LL | | &mut x;
|
2018-08-08 12:50:16 +00:00
|
|
|
LL | | *y = 1;
|
|
|
|
LL | | drop(y);
|
|
|
|
LL | | }
|
2018-10-04 19:48:50 +00:00
|
|
|
| |_________________^ returns a closure that contains a reference to a captured variable, which then escapes the closure body
|
2018-08-08 12:50:16 +00:00
|
|
|
|
|
2018-10-03 23:50:23 +00:00
|
|
|
= 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
|
2022-07-22 16:53:39 +00:00
|
|
|
help: consider adding 'move' keyword before the nested closure
|
|
|
|
|
|
|
|
|
LL | move || {
|
|
|
|
| ++++
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
error[E0503]: cannot use `f.x` because it was mutably borrowed
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-describe-lvalue.rs:37:9
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let x = f.x();
|
Use larger span for adjustments on method calls
Currently, we use a relatively 'small' span for THIR
expressions generated by an 'adjustment' (e.g. an autoderef,
autoborrow, unsizing). As a result, if a borrow generated
by an adustment ends up causing a borrowcheck error, for example:
```rust
let mut my_var = String::new();
let my_ref = &my_var
my_var.push('a');
my_ref;
```
then the span for the mutable borrow may end up referring
to only the base expression (e.g. `my_var`), rather than
the method call which triggered the mutable borrow
(e.g. `my_var.push('a')`)
Due to a quirk of the MIR borrowck implementation,
this doesn't always get exposed in migration mode,
but it does in many cases.
This commit makes THIR building consistently use 'larger'
spans for adjustment expressions
The intent of this change it make it clearer to users
when it's the specific way in which a variable is
used (for example, in a method call) that produdes
a borrowcheck error. For example, an error message
claiming that a 'mutable borrow occurs here' might
be confusing if it just points at a usage of a variable
(e.g. `my_var`), when no `&mut` is in sight. Pointing
at the entire expression should help to emphasize
that the method call itself is responsible for
the mutable borrow.
In several cases, this makes the `#![feature(nll)]` diagnostic
output match up exactly with the default (migration mode) output.
As a result, several `.nll.stderr` files end up getting removed
entirely.
2021-09-16 20:01:22 +00:00
|
|
|
| ----- borrow of `f` occurs here
|
2019-03-17 09:52:07 +00:00
|
|
|
LL | f.x;
|
2018-08-08 12:28:26 +00:00
|
|
|
| ^^^ use of borrowed `f`
|
|
|
|
LL | drop(x);
|
|
|
|
| - borrow later used here
|
|
|
|
|
|
|
|
error[E0503]: cannot use `g.0` because it was mutably borrowed
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-describe-lvalue.rs:44:9
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let x = g.x();
|
Use larger span for adjustments on method calls
Currently, we use a relatively 'small' span for THIR
expressions generated by an 'adjustment' (e.g. an autoderef,
autoborrow, unsizing). As a result, if a borrow generated
by an adustment ends up causing a borrowcheck error, for example:
```rust
let mut my_var = String::new();
let my_ref = &my_var
my_var.push('a');
my_ref;
```
then the span for the mutable borrow may end up referring
to only the base expression (e.g. `my_var`), rather than
the method call which triggered the mutable borrow
(e.g. `my_var.push('a')`)
Due to a quirk of the MIR borrowck implementation,
this doesn't always get exposed in migration mode,
but it does in many cases.
This commit makes THIR building consistently use 'larger'
spans for adjustment expressions
The intent of this change it make it clearer to users
when it's the specific way in which a variable is
used (for example, in a method call) that produdes
a borrowcheck error. For example, an error message
claiming that a 'mutable borrow occurs here' might
be confusing if it just points at a usage of a variable
(e.g. `my_var`), when no `&mut` is in sight. Pointing
at the entire expression should help to emphasize
that the method call itself is responsible for
the mutable borrow.
In several cases, this makes the `#![feature(nll)]` diagnostic
output match up exactly with the default (migration mode) output.
As a result, several `.nll.stderr` files end up getting removed
entirely.
2021-09-16 20:01:22 +00:00
|
|
|
| ----- borrow of `g` occurs here
|
2019-03-17 09:52:07 +00:00
|
|
|
LL | g.0;
|
2018-08-08 12:28:26 +00:00
|
|
|
| ^^^ use of borrowed `g`
|
|
|
|
LL | drop(x);
|
|
|
|
| - borrow later used here
|
|
|
|
|
|
|
|
error[E0503]: cannot use `h.0` because it was mutably borrowed
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-describe-lvalue.rs:51:9
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let x = &mut h.0;
|
|
|
|
| -------- borrow of `h.0` occurs here
|
2019-03-17 09:52:07 +00:00
|
|
|
LL | h.0;
|
2018-08-08 12:28:26 +00:00
|
|
|
| ^^^ use of borrowed `h.0`
|
|
|
|
LL | drop(x);
|
|
|
|
| - borrow later used here
|
|
|
|
|
|
|
|
error[E0503]: cannot use `e.0` because it was mutably borrowed
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-describe-lvalue.rs:59:20
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let x = e.x();
|
Use larger span for adjustments on method calls
Currently, we use a relatively 'small' span for THIR
expressions generated by an 'adjustment' (e.g. an autoderef,
autoborrow, unsizing). As a result, if a borrow generated
by an adustment ends up causing a borrowcheck error, for example:
```rust
let mut my_var = String::new();
let my_ref = &my_var
my_var.push('a');
my_ref;
```
then the span for the mutable borrow may end up referring
to only the base expression (e.g. `my_var`), rather than
the method call which triggered the mutable borrow
(e.g. `my_var.push('a')`)
Due to a quirk of the MIR borrowck implementation,
this doesn't always get exposed in migration mode,
but it does in many cases.
This commit makes THIR building consistently use 'larger'
spans for adjustment expressions
The intent of this change it make it clearer to users
when it's the specific way in which a variable is
used (for example, in a method call) that produdes
a borrowcheck error. For example, an error message
claiming that a 'mutable borrow occurs here' might
be confusing if it just points at a usage of a variable
(e.g. `my_var`), when no `&mut` is in sight. Pointing
at the entire expression should help to emphasize
that the method call itself is responsible for
the mutable borrow.
In several cases, this makes the `#![feature(nll)]` diagnostic
output match up exactly with the default (migration mode) output.
As a result, several `.nll.stderr` files end up getting removed
entirely.
2021-09-16 20:01:22 +00:00
|
|
|
| ----- borrow of `e` occurs here
|
2018-09-13 21:04:09 +00:00
|
|
|
LL | match e {
|
2018-08-08 12:28:26 +00:00
|
|
|
LL | Baz::X(value) => value
|
|
|
|
| ^^^^^ use of borrowed `e`
|
2019-04-22 07:40:08 +00:00
|
|
|
LL | };
|
2018-08-08 12:28:26 +00:00
|
|
|
LL | drop(x);
|
|
|
|
| - borrow later used here
|
|
|
|
|
|
|
|
error[E0503]: cannot use `u.a` because it was mutably borrowed
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-describe-lvalue.rs:67:9
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let x = &mut u.a;
|
|
|
|
| -------- borrow of `u.a` occurs here
|
2019-03-17 09:52:07 +00:00
|
|
|
LL | u.a;
|
2018-08-08 12:28:26 +00:00
|
|
|
| ^^^ use of borrowed `u.a`
|
|
|
|
LL | drop(x);
|
|
|
|
| - borrow later used here
|
|
|
|
|
|
|
|
error[E0503]: cannot use `f.x` because it was mutably borrowed
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-describe-lvalue.rs:74:9
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let x = f.x();
|
Use larger span for adjustments on method calls
Currently, we use a relatively 'small' span for THIR
expressions generated by an 'adjustment' (e.g. an autoderef,
autoborrow, unsizing). As a result, if a borrow generated
by an adustment ends up causing a borrowcheck error, for example:
```rust
let mut my_var = String::new();
let my_ref = &my_var
my_var.push('a');
my_ref;
```
then the span for the mutable borrow may end up referring
to only the base expression (e.g. `my_var`), rather than
the method call which triggered the mutable borrow
(e.g. `my_var.push('a')`)
Due to a quirk of the MIR borrowck implementation,
this doesn't always get exposed in migration mode,
but it does in many cases.
This commit makes THIR building consistently use 'larger'
spans for adjustment expressions
The intent of this change it make it clearer to users
when it's the specific way in which a variable is
used (for example, in a method call) that produdes
a borrowcheck error. For example, an error message
claiming that a 'mutable borrow occurs here' might
be confusing if it just points at a usage of a variable
(e.g. `my_var`), when no `&mut` is in sight. Pointing
at the entire expression should help to emphasize
that the method call itself is responsible for
the mutable borrow.
In several cases, this makes the `#![feature(nll)]` diagnostic
output match up exactly with the default (migration mode) output.
As a result, several `.nll.stderr` files end up getting removed
entirely.
2021-09-16 20:01:22 +00:00
|
|
|
| ----- borrow of `*f` occurs here
|
2019-03-17 09:52:07 +00:00
|
|
|
LL | f.x;
|
2018-08-08 12:28:26 +00:00
|
|
|
| ^^^ use of borrowed `*f`
|
|
|
|
LL | drop(x);
|
|
|
|
| - borrow later used here
|
|
|
|
|
|
|
|
error[E0503]: cannot use `g.0` because it was mutably borrowed
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-describe-lvalue.rs:81:9
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let x = g.x();
|
Use larger span for adjustments on method calls
Currently, we use a relatively 'small' span for THIR
expressions generated by an 'adjustment' (e.g. an autoderef,
autoborrow, unsizing). As a result, if a borrow generated
by an adustment ends up causing a borrowcheck error, for example:
```rust
let mut my_var = String::new();
let my_ref = &my_var
my_var.push('a');
my_ref;
```
then the span for the mutable borrow may end up referring
to only the base expression (e.g. `my_var`), rather than
the method call which triggered the mutable borrow
(e.g. `my_var.push('a')`)
Due to a quirk of the MIR borrowck implementation,
this doesn't always get exposed in migration mode,
but it does in many cases.
This commit makes THIR building consistently use 'larger'
spans for adjustment expressions
The intent of this change it make it clearer to users
when it's the specific way in which a variable is
used (for example, in a method call) that produdes
a borrowcheck error. For example, an error message
claiming that a 'mutable borrow occurs here' might
be confusing if it just points at a usage of a variable
(e.g. `my_var`), when no `&mut` is in sight. Pointing
at the entire expression should help to emphasize
that the method call itself is responsible for
the mutable borrow.
In several cases, this makes the `#![feature(nll)]` diagnostic
output match up exactly with the default (migration mode) output.
As a result, several `.nll.stderr` files end up getting removed
entirely.
2021-09-16 20:01:22 +00:00
|
|
|
| ----- borrow of `*g` occurs here
|
2019-03-17 09:52:07 +00:00
|
|
|
LL | g.0;
|
2018-08-08 12:28:26 +00:00
|
|
|
| ^^^ use of borrowed `*g`
|
|
|
|
LL | drop(x);
|
|
|
|
| - borrow later used here
|
|
|
|
|
|
|
|
error[E0503]: cannot use `h.0` because it was mutably borrowed
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-describe-lvalue.rs:88:9
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let x = &mut h.0;
|
|
|
|
| -------- borrow of `h.0` occurs here
|
2019-03-17 09:52:07 +00:00
|
|
|
LL | h.0;
|
2018-08-08 12:28:26 +00:00
|
|
|
| ^^^ use of borrowed `h.0`
|
|
|
|
LL | drop(x);
|
|
|
|
| - borrow later used here
|
|
|
|
|
|
|
|
error[E0503]: cannot use `e.0` because it was mutably borrowed
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-describe-lvalue.rs:96:20
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let x = e.x();
|
Use larger span for adjustments on method calls
Currently, we use a relatively 'small' span for THIR
expressions generated by an 'adjustment' (e.g. an autoderef,
autoborrow, unsizing). As a result, if a borrow generated
by an adustment ends up causing a borrowcheck error, for example:
```rust
let mut my_var = String::new();
let my_ref = &my_var
my_var.push('a');
my_ref;
```
then the span for the mutable borrow may end up referring
to only the base expression (e.g. `my_var`), rather than
the method call which triggered the mutable borrow
(e.g. `my_var.push('a')`)
Due to a quirk of the MIR borrowck implementation,
this doesn't always get exposed in migration mode,
but it does in many cases.
This commit makes THIR building consistently use 'larger'
spans for adjustment expressions
The intent of this change it make it clearer to users
when it's the specific way in which a variable is
used (for example, in a method call) that produdes
a borrowcheck error. For example, an error message
claiming that a 'mutable borrow occurs here' might
be confusing if it just points at a usage of a variable
(e.g. `my_var`), when no `&mut` is in sight. Pointing
at the entire expression should help to emphasize
that the method call itself is responsible for
the mutable borrow.
In several cases, this makes the `#![feature(nll)]` diagnostic
output match up exactly with the default (migration mode) output.
As a result, several `.nll.stderr` files end up getting removed
entirely.
2021-09-16 20:01:22 +00:00
|
|
|
| ----- borrow of `*e` occurs here
|
2018-09-13 21:04:09 +00:00
|
|
|
LL | match *e {
|
2018-08-08 12:28:26 +00:00
|
|
|
LL | Baz::X(value) => value
|
|
|
|
| ^^^^^ use of borrowed `*e`
|
|
|
|
...
|
|
|
|
LL | drop(x);
|
|
|
|
| - borrow later used here
|
|
|
|
|
|
|
|
error[E0503]: cannot use `u.a` because it was mutably borrowed
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-describe-lvalue.rs:105:9
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let x = &mut u.a;
|
|
|
|
| -------- borrow of `u.a` occurs here
|
2019-03-17 09:52:07 +00:00
|
|
|
LL | u.a;
|
2018-08-08 12:28:26 +00:00
|
|
|
| ^^^ use of borrowed `u.a`
|
|
|
|
LL | drop(x);
|
|
|
|
| - borrow later used here
|
|
|
|
|
|
|
|
error[E0503]: cannot use `v[..]` because it was mutably borrowed
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-describe-lvalue.rs:113:15
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let x = &mut v;
|
|
|
|
| ------ borrow of `v` occurs here
|
2018-09-13 21:04:09 +00:00
|
|
|
LL | match v {
|
2018-08-08 12:28:26 +00:00
|
|
|
LL | &[x, _, .., _, _] => println!("{}", x),
|
|
|
|
| ^ use of borrowed `v`
|
|
|
|
...
|
|
|
|
LL | drop(x);
|
|
|
|
| - borrow later used here
|
|
|
|
|
|
|
|
error[E0503]: cannot use `v[..]` because it was mutably borrowed
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-describe-lvalue.rs:118:18
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let x = &mut v;
|
|
|
|
| ------ borrow of `v` occurs here
|
|
|
|
...
|
|
|
|
LL | &[_, x, .., _, _] => println!("{}", x),
|
|
|
|
| ^ use of borrowed `v`
|
|
|
|
...
|
|
|
|
LL | drop(x);
|
|
|
|
| - borrow later used here
|
|
|
|
|
|
|
|
error[E0503]: cannot use `v[..]` because it was mutably borrowed
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-describe-lvalue.rs:123:25
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let x = &mut v;
|
|
|
|
| ------ borrow of `v` occurs here
|
|
|
|
...
|
|
|
|
LL | &[_, _, .., x, _] => println!("{}", x),
|
|
|
|
| ^ use of borrowed `v`
|
|
|
|
...
|
|
|
|
LL | drop(x);
|
|
|
|
| - borrow later used here
|
|
|
|
|
|
|
|
error[E0503]: cannot use `v[..]` because it was mutably borrowed
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-describe-lvalue.rs:128:28
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let x = &mut v;
|
|
|
|
| ------ borrow of `v` occurs here
|
|
|
|
...
|
|
|
|
LL | &[_, _, .., _, x] => println!("{}", x),
|
|
|
|
| ^ use of borrowed `v`
|
|
|
|
...
|
|
|
|
LL | drop(x);
|
|
|
|
| - borrow later used here
|
|
|
|
|
|
|
|
error[E0503]: cannot use `v[..]` because it was mutably borrowed
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-describe-lvalue.rs:139:15
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let x = &mut v;
|
|
|
|
| ------ borrow of `v` occurs here
|
2018-09-13 21:04:09 +00:00
|
|
|
LL | match v {
|
2019-07-07 23:58:28 +00:00
|
|
|
LL | &[x @ ..] => println!("{:?}", x),
|
2022-09-03 22:55:53 +00:00
|
|
|
| ^ use of borrowed `v`
|
2018-08-08 12:28:26 +00:00
|
|
|
...
|
|
|
|
LL | drop(x);
|
|
|
|
| - borrow later used here
|
|
|
|
|
|
|
|
error[E0503]: cannot use `v[..]` because it was mutably borrowed
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-describe-lvalue.rs:144:18
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let x = &mut v;
|
|
|
|
| ------ borrow of `v` occurs here
|
|
|
|
...
|
2019-07-07 23:58:28 +00:00
|
|
|
LL | &[_, x @ ..] => println!("{:?}", x),
|
2022-09-03 22:55:53 +00:00
|
|
|
| ^ use of borrowed `v`
|
2018-08-08 12:28:26 +00:00
|
|
|
...
|
|
|
|
LL | drop(x);
|
|
|
|
| - borrow later used here
|
|
|
|
|
|
|
|
error[E0503]: cannot use `v[..]` because it was mutably borrowed
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-describe-lvalue.rs:149:15
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let x = &mut v;
|
|
|
|
| ------ borrow of `v` occurs here
|
|
|
|
...
|
2019-07-07 23:58:28 +00:00
|
|
|
LL | &[x @ .., _] => println!("{:?}", x),
|
2022-09-03 22:55:53 +00:00
|
|
|
| ^ use of borrowed `v`
|
2018-08-08 12:28:26 +00:00
|
|
|
...
|
|
|
|
LL | drop(x);
|
|
|
|
| - borrow later used here
|
|
|
|
|
|
|
|
error[E0503]: cannot use `v[..]` because it was mutably borrowed
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-describe-lvalue.rs:154:18
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let x = &mut v;
|
|
|
|
| ------ borrow of `v` occurs here
|
|
|
|
...
|
2019-07-07 23:58:28 +00:00
|
|
|
LL | &[_, x @ .., _] => println!("{:?}", x),
|
2022-09-03 22:55:53 +00:00
|
|
|
| ^ use of borrowed `v`
|
2018-08-08 12:28:26 +00:00
|
|
|
...
|
|
|
|
LL | drop(x);
|
|
|
|
| - borrow later used here
|
|
|
|
|
|
|
|
error[E0503]: cannot use `e` because it was mutably borrowed
|
2021-07-23 22:55:36 +00:00
|
|
|
--> $DIR/borrowck-describe-lvalue.rs:166:15
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let x = &mut e;
|
|
|
|
| ------ borrow of `e` occurs here
|
2018-09-13 21:04:09 +00:00
|
|
|
LL | match e {
|
2021-07-23 22:55:36 +00:00
|
|
|
| ^ use of borrowed `e`
|
2018-08-08 12:28:26 +00:00
|
|
|
...
|
|
|
|
LL | drop(x);
|
|
|
|
| - borrow later used here
|
|
|
|
|
|
|
|
error[E0502]: cannot borrow `e.0` as immutable because it is also borrowed as mutable
|
2021-07-23 22:55:36 +00:00
|
|
|
--> $DIR/borrowck-describe-lvalue.rs:168:18
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let x = &mut e;
|
|
|
|
| ------ mutable borrow occurs here
|
2021-07-23 22:55:36 +00:00
|
|
|
...
|
2018-08-08 12:28:26 +00:00
|
|
|
LL | E::A(ref ax) =>
|
|
|
|
| ^^^^^^ immutable borrow occurs here
|
|
|
|
...
|
|
|
|
LL | drop(x);
|
2018-09-29 10:47:47 +00:00
|
|
|
| - mutable borrow later used here
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
error[E0502]: cannot borrow `e.x` as immutable because it is also borrowed as mutable
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-describe-lvalue.rs:171:23
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let x = &mut e;
|
|
|
|
| ------ mutable borrow occurs here
|
|
|
|
...
|
|
|
|
LL | E::B { x: ref bx } =>
|
|
|
|
| ^^^^^^ immutable borrow occurs here
|
|
|
|
...
|
|
|
|
LL | drop(x);
|
2018-09-29 10:47:47 +00:00
|
|
|
| - mutable borrow later used here
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
error[E0502]: cannot borrow `s.y.0` as immutable because it is also borrowed as mutable
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-describe-lvalue.rs:184:22
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let x = &mut s;
|
|
|
|
| ------ mutable borrow occurs here
|
2018-09-13 21:04:09 +00:00
|
|
|
LL | match s {
|
2018-08-08 12:28:26 +00:00
|
|
|
LL | S { y: (ref y0, _), .. } =>
|
|
|
|
| ^^^^^^ immutable borrow occurs here
|
|
|
|
...
|
|
|
|
LL | drop(x);
|
2018-09-29 10:47:47 +00:00
|
|
|
| - mutable borrow later used here
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
error[E0502]: cannot borrow `s.x.y` as immutable because it is also borrowed as mutable
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-describe-lvalue.rs:190:28
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let x = &mut s;
|
|
|
|
| ------ mutable borrow occurs here
|
|
|
|
...
|
|
|
|
LL | S { x: F { y: ref x0, .. }, .. } =>
|
|
|
|
| ^^^^^^ immutable borrow occurs here
|
|
|
|
...
|
|
|
|
LL | drop(x);
|
2018-09-29 10:47:47 +00:00
|
|
|
| - mutable borrow later used here
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
error[E0503]: cannot use `*v` because it was mutably borrowed
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-describe-lvalue.rs:232:9
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let x = &mut v;
|
|
|
|
| ------ borrow of `v` occurs here
|
|
|
|
LL | v[0].y;
|
|
|
|
| ^^^^ use of borrowed `v`
|
|
|
|
...
|
|
|
|
LL | drop(x);
|
|
|
|
| - borrow later used here
|
|
|
|
|
2018-12-27 11:08:51 +00:00
|
|
|
error[E0503]: cannot use `v[_].y` because it was mutably borrowed
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-describe-lvalue.rs:232:9
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let x = &mut v;
|
|
|
|
| ------ borrow of `v` occurs here
|
|
|
|
LL | v[0].y;
|
|
|
|
| ^^^^^^ use of borrowed `v`
|
|
|
|
...
|
|
|
|
LL | drop(x);
|
|
|
|
| - borrow later used here
|
|
|
|
|
|
|
|
error[E0502]: cannot borrow `v[..].x` as immutable because it is also borrowed as mutable
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-describe-lvalue.rs:243:24
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let x = &mut v;
|
|
|
|
| ------ mutable borrow occurs here
|
2018-09-13 21:04:09 +00:00
|
|
|
LL | match v {
|
2018-08-08 12:28:26 +00:00
|
|
|
LL | &[_, F {x: ref xf, ..}] => println!("{}", xf),
|
|
|
|
| ^^^^^^ immutable borrow occurs here
|
|
|
|
...
|
|
|
|
LL | drop(x);
|
2018-09-29 10:47:47 +00:00
|
|
|
| - mutable borrow later used here
|
2018-08-08 12:28:26 +00:00
|
|
|
|
2019-09-06 13:47:50 +00:00
|
|
|
error[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-describe-lvalue.rs:206:29
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let x = &mut block;
|
|
|
|
| ---------- mutable borrow occurs here
|
|
|
|
LL | let p: &'a u8 = &*block.current;
|
|
|
|
| ^^^^^^^^^^^^^^^ immutable borrow occurs here
|
|
|
|
...
|
|
|
|
LL | drop(x);
|
2018-09-29 10:47:47 +00:00
|
|
|
| - mutable borrow later used here
|
2018-08-08 12:28:26 +00:00
|
|
|
|
2019-09-06 13:47:50 +00:00
|
|
|
error[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-describe-lvalue.rs:221:33
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let x = &mut block;
|
|
|
|
| ---------- mutable borrow occurs here
|
|
|
|
LL | let p : *const u8 = &*(*block).current;
|
|
|
|
| ^^^^^^^^^^^^^^^^^^ immutable borrow occurs here
|
|
|
|
...
|
|
|
|
LL | drop(x);
|
2018-09-29 10:47:47 +00:00
|
|
|
| - mutable borrow later used here
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
error[E0382]: use of moved value: `x`
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-describe-lvalue.rs:274:22
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | drop(x);
|
|
|
|
| - value moved here
|
2019-03-17 09:52:07 +00:00
|
|
|
LL | drop(x);
|
2018-08-08 12:28:26 +00:00
|
|
|
| ^ value used here after move
|
|
|
|
|
|
2020-09-02 07:40:56 +00:00
|
|
|
= note: move occurs because `x` has type `Vec<i32>`, which does not implement the `Copy` trait
|
2018-08-08 12:28:26 +00:00
|
|
|
|
2019-09-06 13:47:50 +00:00
|
|
|
error: aborting due to 32 previous errors
|
2018-08-08 12:28:26 +00:00
|
|
|
|
2019-04-17 17:26:38 +00:00
|
|
|
Some errors have detailed explanations: E0382, E0499, E0502, E0503.
|
2018-08-08 12:28:26 +00:00
|
|
|
For more information about an error, try `rustc --explain E0382`.
|