borrowck: prefer "value" over "_".

This commit is contained in:
Mazdak Farrokhzad 2020-03-25 11:17:06 +01:00
parent 02046a5d40
commit c70aa344e4
13 changed files with 113 additions and 134 deletions

View file

@ -45,19 +45,19 @@ fn main() {
*b = NC;
let ref a @ box ref mut b = Box::new(NC);
//~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable
//~| ERROR cannot borrow `_` as mutable because it is also borrowed as immutable
//~| ERROR cannot borrow value as mutable because it is also borrowed as immutable
*b = NC;
drop(a);
let ref mut a @ box ref b = Box::new(NC);
//~^ ERROR cannot borrow value as immutable because it is also borrowed as mutable
//~| ERROR cannot borrow `_` as immutable because it is also borrowed as mutable
//~| ERROR cannot borrow value as immutable because it is also borrowed as mutable
*a = Box::new(NC);
drop(b);
fn f5(ref mut a @ box ref b: Box<NC>) {
//~^ ERROR cannot borrow value as immutable because it is also borrowed as mutable
//~| ERROR cannot borrow `_` as immutable because it is also borrowed as mutable
//~| ERROR cannot borrow value as immutable because it is also borrowed as mutable
*a = Box::new(NC);
drop(b);
}
@ -65,7 +65,7 @@ fn main() {
match Box::new(nc()) {
ref mut a @ box ref b => {
//~^ ERROR cannot borrow value as immutable because it is also borrowed as mutable
//~| ERROR cannot borrow `_` as immutable because it is also borrowed as mutable
//~| ERROR cannot borrow value as immutable because it is also borrowed as mutable
*a = Box::new(NC);
drop(b);
}

View file

@ -99,7 +99,7 @@ LL | a @ box b => {}
| | value used here after move
| value moved here
error[E0502]: cannot borrow `_` as mutable because it is also borrowed as immutable
error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable
--> $DIR/borrowck-pat-at-and-box.rs:46:21
|
LL | let ref a @ box ref mut b = Box::new(NC);
@ -111,7 +111,7 @@ LL | let ref a @ box ref mut b = Box::new(NC);
LL | drop(a);
| - immutable borrow later used here
error[E0502]: cannot borrow `_` as immutable because it is also borrowed as mutable
error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable
--> $DIR/borrowck-pat-at-and-box.rs:52:25
|
LL | let ref mut a @ box ref b = Box::new(NC);
@ -123,7 +123,7 @@ LL | let ref mut a @ box ref b = Box::new(NC);
LL | *a = Box::new(NC);
| -- mutable borrow later used here
error[E0502]: cannot borrow `_` as immutable because it is also borrowed as mutable
error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable
--> $DIR/borrowck-pat-at-and-box.rs:66:25
|
LL | ref mut a @ box ref b => {
@ -155,7 +155,7 @@ LL | fn f2(a @ box b: Box<C>) {}
| value moved here
| move occurs because value has type `std::boxed::Box<C>`, which does not implement the `Copy` trait
error[E0502]: cannot borrow `_` as immutable because it is also borrowed as mutable
error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable
--> $DIR/borrowck-pat-at-and-box.rs:58:27
|
LL | fn f5(ref mut a @ box ref b: Box<NC>) {

View file

@ -10,7 +10,7 @@ fn main() {
match &mut Some(1) {
ref mut z @ &mut Some(ref a) => {
//~^ ERROR cannot borrow value as immutable because it is also borrowed as mutable
//~| ERROR cannot borrow `_` as immutable because it is also borrowed as mutable
//~| ERROR cannot borrow value as immutable because it is also borrowed as mutable
**z = None;
println!("{}", *a);
}
@ -47,12 +47,12 @@ fn main() {
let ref mut a @ ref b = u();
//~^ ERROR cannot borrow value as immutable because it is also borrowed as mutable
//~| ERROR cannot borrow `_` as immutable because it is also borrowed as mutable
//~| ERROR cannot borrow value as immutable because it is also borrowed as mutable
*a = u();
drop(b);
let ref a @ ref mut b = u();
//~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable
//~| ERROR cannot borrow `_` as mutable because it is also borrowed as immutable
//~| ERROR cannot borrow value as mutable because it is also borrowed as immutable
*b = u();
drop(a);
@ -78,8 +78,8 @@ fn main() {
ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => {
//~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable
//~| ERROR cannot borrow value as mutable because it is also borrowed as immutable
//~| ERROR cannot borrow `_` as mutable because it is also borrowed as immutable
//~| ERROR cannot borrow `_` as mutable because it is also borrowed as immutable
//~| ERROR cannot borrow value as mutable because it is also borrowed as immutable
//~| ERROR cannot borrow value as mutable because it is also borrowed as immutable
*b = U;
drop(a);
}
@ -123,15 +123,15 @@ fn main() {
let ref a @ (ref mut b, ref mut c) = (U, U);
//~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable
//~| ERROR cannot borrow `_` as mutable because it is also borrowed as immutable
//~| ERROR cannot borrow `_` as mutable because it is also borrowed as immutable
//~| ERROR cannot borrow value as mutable because it is also borrowed as immutable
//~| ERROR cannot borrow value as mutable because it is also borrowed as immutable
*b = U;
drop(a);
let ref a @ (ref mut b, ref mut c) = (U, U);
//~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable
*b = U; //~| ERROR cannot borrow `_` as mutable because it is also borrowed as immutable
*c = U; //~| ERROR cannot borrow `_` as mutable because it is also borrowed as immutable
*b = U; //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable
*c = U; //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable
drop(a);
let ref mut a @ (ref b, ref c) = (U, U);
//~^ ERROR cannot borrow value as immutable because it is also borrowed as mutable

View file

@ -294,7 +294,7 @@ LL | fn f4_also_moved(ref a @ ref mut b @ c: U) {}
| | value moved into `c` here
| value borrowed, by `b`, here
error[E0502]: cannot borrow `_` as immutable because it is also borrowed as mutable
error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:11:31
|
LL | ref mut z @ &mut Some(ref a) => {
@ -306,7 +306,7 @@ LL | ref mut z @ &mut Some(ref a) => {
LL | **z = None;
| ---------- mutable borrow later used here
error[E0502]: cannot borrow `_` as immutable because it is also borrowed as mutable
error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:48:21
|
LL | let ref mut a @ ref b = u();
@ -318,7 +318,7 @@ LL | let ref mut a @ ref b = u();
LL | *a = u();
| -------- mutable borrow later used here
error[E0502]: cannot borrow `_` as mutable because it is also borrowed as immutable
error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:53:17
|
LL | let ref a @ ref mut b = u();
@ -330,7 +330,7 @@ LL | let ref a @ ref mut b = u();
LL | drop(a);
| - immutable borrow later used here
error[E0502]: cannot borrow `_` as mutable because it is also borrowed as immutable
error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:78:20
|
LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => {
@ -342,7 +342,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => {
LL | drop(a);
| - immutable borrow later used here
error[E0502]: cannot borrow `_` as mutable because it is also borrowed as immutable
error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:78:45
|
LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => {
@ -402,7 +402,7 @@ LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false
|
= note: variables bound in patterns cannot be moved from until after the end of the pattern guard
error[E0502]: cannot borrow `_` as mutable because it is also borrowed as immutable
error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:124:18
|
LL | let ref a @ (ref mut b, ref mut c) = (U, U);
@ -414,7 +414,7 @@ LL | let ref a @ (ref mut b, ref mut c) = (U, U);
LL | drop(a);
| - immutable borrow later used here
error[E0502]: cannot borrow `_` as mutable because it is also borrowed as immutable
error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:124:29
|
LL | let ref a @ (ref mut b, ref mut c) = (U, U);
@ -426,7 +426,7 @@ LL | let ref a @ (ref mut b, ref mut c) = (U, U);
LL | drop(a);
| - immutable borrow later used here
error[E0502]: cannot borrow `_` as mutable because it is also borrowed as immutable
error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:131:18
|
LL | let ref a @ (ref mut b, ref mut c) = (U, U);
@ -438,7 +438,7 @@ LL | let ref a @ (ref mut b, ref mut c) = (U, U);
LL | drop(a);
| - immutable borrow later used here
error[E0502]: cannot borrow `_` as mutable because it is also borrowed as immutable
error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:131:29
|
LL | let ref a @ (ref mut b, ref mut c) = (U, U);

View file

@ -27,7 +27,7 @@ fn main() {
let ref mut a @ ref mut b = U;
//~^ ERROR cannot borrow value as mutable more than once at a time
//~| ERROR cannot borrow `_` as mutable more than once at a time
//~| ERROR cannot borrow value as mutable more than once at a time
drop(a);
let ref mut a @ ref mut b = U;
//~^ ERROR cannot borrow value as mutable more than once at a time
@ -37,7 +37,7 @@ fn main() {
let ref mut a @ ref mut b = U;
//~^ ERROR cannot borrow value as mutable more than once at a time
//~| ERROR cannot borrow `_` as mutable more than once at a time
//~| ERROR cannot borrow value as mutable more than once at a time
*a = U;
let ref mut a @ ref mut b = U;
//~^ ERROR cannot borrow value as mutable more than once at a time
@ -95,11 +95,11 @@ fn main() {
ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
//~^ ERROR cannot borrow value as mutable more than once at a time
//~| ERROR cannot borrow value as mutable more than once at a time
//~| ERROR cannot borrow `_` as mutable more than once at a time
//~| ERROR cannot borrow `_` as mutable more than once at a time
//~| ERROR cannot borrow value as mutable more than once at a time
//~| ERROR cannot borrow value as mutable more than once at a time
*a = Err(U);
// FIXME: The binding name `_` used above makes for problematic diagnostics.
// FIXME: The binding name value used above makes for problematic diagnostics.
// Resolve that somehow...
}
}
@ -107,8 +107,8 @@ fn main() {
ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
//~^ ERROR cannot borrow value as mutable more than once at a time
//~| ERROR cannot borrow value as mutable more than once at a time
//~| ERROR cannot borrow `_` as mutable more than once at a time
//~| ERROR cannot borrow `_` as mutable more than once at a time
//~| ERROR cannot borrow value as mutable more than once at a time
//~| ERROR cannot borrow value as mutable more than once at a time
drop(a);
}
}

View file

@ -258,7 +258,7 @@ LL | fn f4_also_moved(ref mut a @ ref mut b @ c: U) {}
| | value moved into `c` here
| value borrowed, by `b`, here
error[E0499]: cannot borrow `_` as mutable more than once at a time
error[E0499]: cannot borrow value as mutable more than once at a time
--> $DIR/borrowck-pat-ref-mut-twice.rs:28:21
|
LL | let ref mut a @ ref mut b = U;
@ -270,7 +270,7 @@ LL | let ref mut a @ ref mut b = U;
LL | drop(a);
| - first borrow later used here
error[E0499]: cannot borrow `_` as mutable more than once at a time
error[E0499]: cannot borrow value as mutable more than once at a time
--> $DIR/borrowck-pat-ref-mut-twice.rs:38:21
|
LL | let ref mut a @ ref mut b = U;
@ -318,7 +318,7 @@ LL | let a @ &mut (ref mut b, ref mut c) = &mut (U, U);
| | value borrowed here after move
| value moved here
error[E0499]: cannot borrow `_` as mutable more than once at a time
error[E0499]: cannot borrow value as mutable more than once at a time
--> $DIR/borrowck-pat-ref-mut-twice.rs:95:24
|
LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
@ -330,7 +330,7 @@ LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
LL | *a = Err(U);
| ----------- first borrow later used here
error[E0499]: cannot borrow `_` as mutable more than once at a time
error[E0499]: cannot borrow value as mutable more than once at a time
--> $DIR/borrowck-pat-ref-mut-twice.rs:95:53
|
LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
@ -342,7 +342,7 @@ LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
LL | *a = Err(U);
| ----------- first borrow later used here
error[E0499]: cannot borrow `_` as mutable more than once at a time
error[E0499]: cannot borrow value as mutable more than once at a time
--> $DIR/borrowck-pat-ref-mut-twice.rs:107:24
|
LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
@ -354,7 +354,7 @@ LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
LL | drop(a);
| - first borrow later used here
error[E0499]: cannot borrow `_` as mutable more than once at a time
error[E0499]: cannot borrow value as mutable more than once at a time
--> $DIR/borrowck-pat-ref-mut-twice.rs:107:53
|
LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {

View file

@ -29,7 +29,7 @@ fn main() {
let _a: &NotCopy = a;
let _b: NotCopy = b;
let ref mut a @ b = NotCopy; //~ ERROR cannot move out of value because it is borrowed
//~^ ERROR cannot move out of `_` because it is borrowed
//~^ ERROR cannot move out of value because it is borrowed
let _a: &NotCopy = a;
let _b: NotCopy = b;
match Ok(NotCopy) {

View file

@ -44,7 +44,7 @@ LL | ref a @ b => {
| | value moved into `b` here
| value borrowed, by `a`, here
error[E0505]: cannot move out of `_` because it is borrowed
error[E0505]: cannot move out of value because it is borrowed
--> $DIR/default-binding-modes-both-sides-independent.rs:31:21
|
LL | let ref mut a @ b = NotCopy;