diff options
| author | Vishnunarayan K I <appukuttancr@gmail.com> | 2020-11-03 12:15:41 +0530 |
|---|---|---|
| committer | Vishnunarayan K I <appukuttancr@gmail.com> | 2020-11-03 12:15:41 +0530 |
| commit | f422e811e4932907e11e8da92f24d2834f7612f2 (patch) | |
| tree | 6408ccd8eb5e43395ea15fa8f31a3a741076f31d /src/test/ui/pattern | |
| parent | 6bdce7bedd765438ce4f138cb0ce9335659e32d6 (diff) | |
| download | rust-f422e811e4932907e11e8da92f24d2834f7612f2.tar.gz rust-f422e811e4932907e11e8da92f24d2834f7612f2.zip | |
preserve bindings order for Some
Diffstat (limited to 'src/test/ui/pattern')
10 files changed, 159 insertions, 201 deletions
diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.rs b/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.rs index 83f9b82b242..bce43f9df85 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.rs +++ b/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.rs @@ -17,8 +17,8 @@ fn main() { let a @ (b, c) = (u(), u()); //~ ERROR use of partially moved value match Ok(U) { - a @ Ok(b) | a @ Err(b) => {} //~ ERROR use of partially moved value - //~^ ERROR use of partially moved value + a @ Ok(b) | a @ Err(b) => {} //~ ERROR use of moved value + //~^ ERROR use of moved value } fn fun(a @ b: U) {} //~ ERROR use of moved value diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.stderr index 482ebd9b423..bfb7b479731 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.stderr @@ -29,35 +29,27 @@ LL | let a @ (b, c) = (u(), u()); | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait -error[E0382]: use of partially moved value - --> $DIR/borrowck-move-and-move.rs:20:9 +error[E0382]: use of moved value + --> $DIR/borrowck-move-and-move.rs:20:16 | +LL | match Ok(U) { + | ----- move occurs because value has type `std::result::Result<U, U>`, which does not implement the `Copy` trait LL | a @ Ok(b) | a @ Err(b) => {} - | ^^^^^^^-^ + | -------^- | | | - | | value partially moved here - | value used here after partial move - | - = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait -help: borrow this field in the pattern to avoid moving the value - | -LL | a @ Ok(ref b) | a @ Err(b) => {} - | ^^^ + | | value used here after move + | value moved here -error[E0382]: use of partially moved value - --> $DIR/borrowck-move-and-move.rs:20:21 +error[E0382]: use of moved value + --> $DIR/borrowck-move-and-move.rs:20:29 | +LL | match Ok(U) { + | ----- move occurs because value has type `std::result::Result<U, U>`, which does not implement the `Copy` trait LL | a @ Ok(b) | a @ Err(b) => {} - | ^^^^^^^^-^ + | --------^- | | | - | | value partially moved here - | value used here after partial move - | - = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait -help: borrow this field in the pattern to avoid moving the value - | -LL | a @ Ok(b) | a @ Err(ref b) => {} - | ^^^ + | | value used here after move + | value moved here error[E0382]: use of partially moved value --> $DIR/borrowck-move-and-move.rs:27:9 diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.rs b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.rs index e75ff78abd7..8a574f880ed 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.rs +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.rs @@ -50,17 +50,19 @@ fn main() { //~^ ERROR borrow of moved value //~| ERROR borrow of moved value //~| ERROR borrow of moved value - //~| ERROR use of partially moved value + //~| ERROR use of moved value None => {} } match Some([U, U]) { mut a @ Some([ref b, ref mut c]) => {} //~^ ERROR borrow of moved value + //~| ERROR borrow of moved value None => {} } match Some(u()) { a @ Some(ref b) => {} //~^ ERROR borrow of moved value + //~| ERROR borrow of moved value None => {} } match Some((u(), u())) { @@ -68,12 +70,13 @@ fn main() { //~^ ERROR borrow of moved value //~| ERROR borrow of moved value //~| ERROR borrow of moved value - //~| ERROR use of partially moved value + //~| ERROR use of moved value None => {} } match Some([u(), u()]) { mut a @ Some([ref b, ref mut c]) => {} //~^ ERROR borrow of moved value + //~| ERROR borrow of moved value None => {} } } diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr index c1ea5d8ec6d..79addf9d574 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr @@ -155,7 +155,7 @@ LL | mut a @ Some([ref b, ref mut c]) => {} | move occurs because `a` has type `Option<[U; 2]>` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:62:9 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:63:9 | LL | a @ Some(ref b) => {} | -^^^^^^^^-----^ @@ -165,7 +165,7 @@ LL | a @ Some(ref b) => {} | move occurs because `a` has type `Option<U>` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:67:9 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:69:9 | LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | -^^^^^^^^^^^^^^^^^---------^^^^^^-----^^ @@ -176,7 +176,7 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | move occurs because `a` has type `Option<(U, U)>` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:67:19 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:69:19 | LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | -----^^^--------- @@ -186,7 +186,7 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | move occurs because `b` has type `U` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:67:38 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:69:38 | LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | -^^^----- @@ -196,7 +196,7 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | move occurs because `d` has type `U` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:75:9 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:77:9 | LL | mut a @ Some([ref b, ref mut c]) => {} | -----^^^^^^^^^-----^^---------^^ @@ -280,35 +280,60 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u()); | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait -error[E0382]: use of partially moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:49:9 +error[E0382]: use of moved value + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:49:38 | +LL | match Some((U, U)) { + | ------------ move occurs because value has type `Option<(U, U)>`, which does not implement the `Copy` trait LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------^^ + | -----------------------------^^^^^^^^^-- | | | - | | value partially moved here - | value used here after partial move + | | value used here after move + | value moved here + +error[E0382]: borrow of moved value + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:57:30 | - = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait -help: borrow this field in the pattern to avoid moving the value +LL | match Some([U, U]) { + | ------------ move occurs because value has type `Option<[U; 2]>`, which does not implement the `Copy` trait +LL | mut a @ Some([ref b, ref mut c]) => {} + | ---------------------^^^^^^^^^-- + | | | + | | value borrowed here after move + | value moved here + +error[E0382]: borrow of moved value + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:63:18 | -LL | a @ Some((mut b @ ref mut c, ref d @ ref e)) => {} - | ^^^ +LL | match Some(u()) { + | --------- move occurs because value has type `Option<U>`, which does not implement the `Copy` trait +LL | a @ Some(ref b) => {} + | ---------^^^^^- + | | | + | | value borrowed here after move + | value moved here -error[E0382]: use of partially moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:67:9 +error[E0382]: use of moved value + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:69:38 | +LL | match Some((u(), u())) { + | ---------------- move occurs because value has type `Option<(U, U)>`, which does not implement the `Copy` trait LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------^^ + | -----------------------------^^^^^^^^^-- | | | - | | value partially moved here - | value used here after partial move - | - = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait -help: borrow this field in the pattern to avoid moving the value + | | value used here after move + | value moved here + +error[E0382]: borrow of moved value + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:77:30 | -LL | a @ Some((mut b @ ref mut c, ref d @ ref e)) => {} - | ^^^ +LL | match Some([u(), u()]) { + | ---------------- move occurs because value has type `Option<[U; 2]>`, which does not implement the `Copy` trait +LL | mut a @ Some([ref b, ref mut c]) => {} + | ---------------------^^^^^^^^^-- + | | | + | | value borrowed here after move + | value moved here error[E0382]: use of partially moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:16:11 @@ -321,6 +346,6 @@ LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait -error: aborting due to 30 previous errors +error: aborting due to 33 previous errors For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.rs b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.rs index 691d0a32fa8..b9235eabd88 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.rs +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.rs @@ -60,13 +60,11 @@ fn main() { match Some([U, U]) { ref mut a @ Some([b, mut c]) => {} //~^ ERROR cannot move out of value because it is borrowed - //~| ERROR borrow of partially moved value None => {} } match Some(u()) { ref a @ Some(b) => {} //~^ ERROR cannot move out of value because it is borrowed - //~| ERROR borrow of partially moved value None => {} } match Some((u(), u())) { @@ -81,7 +79,6 @@ fn main() { match Some([u(), u()]) { ref mut a @ Some([b, mut c]) => {} //~^ ERROR cannot move out of value because it is borrowed - //~| ERROR borrow of partially moved value None => {} } } diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr index a39ff8774f7..50b2f8929f2 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr @@ -140,7 +140,7 @@ LL | ref mut a @ Some([b, mut c]) => {} | value borrowed, by `a`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:67:9 + --> $DIR/borrowck-pat-by-move-and-ref.rs:66:9 | LL | ref a @ Some(b) => {} | -----^^^^^^^^-^ @@ -149,7 +149,7 @@ LL | ref a @ Some(b) => {} | value borrowed, by `a`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:73:9 + --> $DIR/borrowck-pat-by-move-and-ref.rs:71:9 | LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | -----^^^^^^^^^^^^^^^^^-----^^^^^^^^^^-^^ @@ -159,7 +159,7 @@ LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | value borrowed, by `a`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:73:23 + --> $DIR/borrowck-pat-by-move-and-ref.rs:71:23 | LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | -----^^^----- @@ -168,7 +168,7 @@ LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | value borrowed, by `b`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:73:38 + --> $DIR/borrowck-pat-by-move-and-ref.rs:71:38 | LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | -----^^^- @@ -177,7 +177,7 @@ LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | value borrowed, by `d`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:82:9 + --> $DIR/borrowck-pat-by-move-and-ref.rs:80:9 | LL | ref mut a @ Some([b, mut c]) => {} | ---------^^^^^^^^^-^^-----^^ @@ -286,38 +286,8 @@ LL | let ref mut a @ [b, mut c] = [u(), u()]; | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait -error[E0382]: borrow of partially moved value - --> $DIR/borrowck-pat-by-move-and-ref.rs:61:9 - | -LL | ref mut a @ Some([b, mut c]) => {} - | ^^^^^^^^^^^^^^^^^^^^^-----^^ - | | | - | | value partially moved here - | value borrowed here after partial move - | - = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait -help: borrow this field in the pattern to avoid moving the value - | -LL | ref mut a @ Some([b, ref mut c]) => {} - | ^^^ - -error[E0382]: borrow of partially moved value - --> $DIR/borrowck-pat-by-move-and-ref.rs:67:9 - | -LL | ref a @ Some(b) => {} - | ^^^^^^^^^^^^^-^ - | | | - | | value partially moved here - | value borrowed here after partial move - | - = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait -help: borrow this field in the pattern to avoid moving the value - | -LL | ref a @ Some(ref b) => {} - | ^^^ - error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref.rs:73:23 + --> $DIR/borrowck-pat-by-move-and-ref.rs:71:23 | LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | ^^^^^^^^----- @@ -332,7 +302,7 @@ LL | ref a @ Some((ref b @ ref mut c, ref d @ e)) => {} | ^^^ error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref.rs:73:38 + --> $DIR/borrowck-pat-by-move-and-ref.rs:71:38 | LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | ^^^^^^^^- @@ -346,21 +316,6 @@ help: borrow this field in the pattern to avoid moving the value LL | ref a @ Some((ref b @ mut c, ref d @ ref e)) => {} | ^^^ -error[E0382]: borrow of partially moved value - --> $DIR/borrowck-pat-by-move-and-ref.rs:82:9 - | -LL | ref mut a @ Some([b, mut c]) => {} - | ^^^^^^^^^^^^^^^^^^^^^-----^^ - | | | - | | value partially moved here - | value borrowed here after partial move - | - = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait -help: borrow this field in the pattern to avoid moving the value - | -LL | ref mut a @ Some([b, ref mut c]) => {} - | ^^^ - error[E0382]: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref.rs:13:11 | @@ -404,6 +359,6 @@ LL | fn f3(ref mut a @ [b, mut c]: [U; 2]) {} | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait -error: aborting due to 39 previous errors +error: aborting due to 36 previous errors For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.rs b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.rs index f543eaece80..2d391cd7d07 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.rs +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.rs @@ -9,7 +9,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 value as mutable because it is also borrowed as immutable + //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable **z = None; println!("{}", *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 value as immutable because it is also borrowed as mutable - //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable + //~| 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); } @@ -90,8 +90,6 @@ fn main() { //~^ 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 assign to `*b`, as it is immutable for the pattern guard - //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable - //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable _ => {} } match Ok(U) { @@ -105,8 +103,6 @@ fn main() { ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {} //~^ 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 value as immutable because it is also borrowed as mutable - //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable //~| ERROR cannot move out of `b` in pattern guard //~| ERROR cannot move out of `b` in pattern guard _ => {} diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr index 26182a1bc74..00136c25764 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr @@ -155,7 +155,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false } | immutable borrow, by `a`, occurs here error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:98:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:96:9 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); false } => {} | ---------^^^^^^-----^ @@ -164,7 +164,7 @@ LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); fa | mutable borrow, by `a`, occurs here error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:98:33 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:96:33 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); false } => {} | ---------^^^^^^^-----^ @@ -173,7 +173,7 @@ LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); fa | mutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:105:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:103:9 | LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {} | -----^^^^^^---------^ @@ -182,7 +182,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false | immutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:105:33 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:103:33 | LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {} | -----^^^^^^^---------^ @@ -191,7 +191,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false | immutable borrow, by `a`, occurs here error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:115:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:111:9 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false } => {} | ---------^^^^^^-----^ @@ -200,7 +200,7 @@ LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false | mutable borrow, by `a`, occurs here error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:115:33 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:111:33 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false } => {} | ---------^^^^^^^-----^ @@ -209,7 +209,7 @@ LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false | mutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:123:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:119:9 | LL | let ref a @ (ref mut b, ref mut c) = (U, U); | -----^^^^---------^^---------^ @@ -219,7 +219,7 @@ LL | let ref a @ (ref mut b, ref mut c) = (U, U); | immutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:129:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:125:9 | LL | let ref a @ (ref mut b, ref mut c) = (U, U); | -----^^^^---------^^---------^ @@ -229,7 +229,7 @@ LL | let ref a @ (ref mut b, ref mut c) = (U, U); | immutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:135:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:131:9 | LL | let ref a @ (ref mut b, ref mut c) = (U, U); | -----^^^^---------^^---------^ @@ -239,7 +239,7 @@ LL | let ref a @ (ref mut b, ref mut c) = (U, U); | immutable borrow, by `a`, occurs here error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:140:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:136:9 | LL | let ref mut a @ (ref b, ref c) = (U, U); | ---------^^^^-----^^-----^ @@ -294,17 +294,17 @@ 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 value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:10:9 +error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:10:31 | LL | ref mut z @ &mut Some(ref a) => { - | ^^^^^^^^^^^^^^^^^^^^^^-----^ + | ----------------------^^^^^- | | | | | immutable borrow occurs here | mutable borrow occurs here ... -LL | println!("{}", *a); - | -- immutable borrow later used here +LL | **z = None; + | ---------- mutable borrow later used here error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable --> $DIR/borrowck-pat-ref-mut-and-ref.rs:48:9 @@ -330,47 +330,29 @@ LL | let ref a @ ref mut b = u(); LL | *b = u(); | -------- mutable borrow later used here -error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:78:9 +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) => { - | ^^^^^^^^^^^---------^ + | -----------^^^^^^^^^- | | | | | mutable borrow occurs here | immutable borrow occurs here ... -LL | *b = U; - | ------ mutable borrow later used here +LL | drop(a); + | - immutable borrow later used here -error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:78:33 +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) => { - | ^^^^^^^^^^^^---------^ + | ------------^^^^^^^^^- | | | | | mutable borrow occurs here | immutable borrow occurs here ... -LL | *b = U; - | ------ mutable borrow later used here - -error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:89:9 - | -LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false } => {} - | ^^^^^^^^^^^---------^ ------ mutable borrow later used here - | | | - | | mutable borrow occurs here - | immutable borrow occurs here - -error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:89:33 - | -LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false } => {} - | ^^^^^^^^^^^^---------^ ------ mutable borrow later used here - | | | - | | mutable borrow occurs here - | immutable borrow occurs here +LL | drop(a); + | - immutable borrow later used here error[E0594]: cannot assign to `*b`, as it is immutable for the pattern guard --> $DIR/borrowck-pat-ref-mut-and-ref.rs:89:61 @@ -381,33 +363,15 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false } = note: variables bound in patterns are immutable until the end of the pattern guard error[E0594]: cannot assign to `*a`, as it is immutable for the pattern guard - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:98:61 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:96:61 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); false } => {} | ^^^^^^^^^^^ cannot assign | = note: variables bound in patterns are immutable until the end of the pattern guard -error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:105:9 - | -LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {} - | ^^^^^^^^^^^---------^ - mutable borrow later used here - | | | - | | mutable borrow occurs here - | immutable borrow occurs here - -error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:105:33 - | -LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {} - | ^^^^^^^^^^^^---------^ - mutable borrow later used here - | | | - | | mutable borrow occurs here - | immutable borrow occurs here - error[E0507]: cannot move out of `b` in pattern guard - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:105:66 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:103:66 | LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {} | ^ move occurs because `b` has type `&mut U`, which does not implement the `Copy` trait @@ -415,7 +379,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false = note: variables bound in patterns cannot be moved from until after the end of the pattern guard error[E0507]: cannot move out of `b` in pattern guard - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:105:66 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:103:66 | LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {} | ^ move occurs because `b` has type `&mut U`, which does not implement the `Copy` trait @@ -423,7 +387,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false = note: variables bound in patterns cannot be moved from until after the end of the pattern guard error[E0507]: cannot move out of `a` in pattern guard - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:115:66 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:111:66 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false } => {} | ^ move occurs because `a` has type `&mut std::result::Result<U, U>`, which does not implement the `Copy` trait @@ -431,7 +395,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[E0507]: cannot move out of `a` in pattern guard - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:115:66 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:111:66 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false } => {} | ^ move occurs because `a` has type `&mut std::result::Result<U, U>`, which does not implement the `Copy` trait @@ -439,7 +403,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 value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:123:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:119:9 | LL | let ref a @ (ref mut b, ref mut c) = (U, U); | ^^^^^^^^^---------^^^^^^^^^^^^ @@ -451,7 +415,7 @@ LL | *b = U; | ------ mutable borrow later used here error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:129:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:125:9 | LL | let ref a @ (ref mut b, ref mut c) = (U, U); | ^^^^^^^^^---------^^^^^^^^^^^^ @@ -463,7 +427,7 @@ LL | *b = U; | ------ mutable borrow later used here error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:135:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:131:9 | LL | let ref a @ (ref mut b, ref mut c) = (U, U); | ^^^^^^^^^---------^^^^^^^^^^^^ @@ -484,7 +448,7 @@ LL | fn f4_also_moved(ref a @ ref mut b @ c: U) {} | | value borrowed here after move | move occurs because value has type `U`, which does not implement the `Copy` trait -error: aborting due to 51 previous errors +error: aborting due to 47 previous errors Some errors have detailed explanations: E0382, E0502, E0507, E0594. For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.rs b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.rs index c58f0413499..339814e1e31 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.rs +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.rs @@ -84,8 +84,6 @@ 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 value as mutable more than once at a time - //~| ERROR cannot borrow value as mutable more than once at a time *b = U; } } @@ -93,6 +91,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 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 value used above makes for problematic diagnostics. @@ -103,6 +103,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 value as mutable more than once at a time + //~| ERROR cannot borrow value as mutable more than once at a time drop(a); } } diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr index 5ae71c2a9fd..0370037f242 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr @@ -168,7 +168,7 @@ LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | first mutable borrow, by `a`, occurs here error: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:93:9 + --> $DIR/borrowck-pat-ref-mut-twice.rs:91:9 | LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | ---------^^^^^^---------^ @@ -177,7 +177,7 @@ LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | first mutable borrow, by `a`, occurs here error: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:93:37 + --> $DIR/borrowck-pat-ref-mut-twice.rs:91:37 | LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | ---------^^^^^^^---------^ @@ -283,28 +283,52 @@ LL | *b = U; | ------ first borrow later used here error[E0499]: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:84:9 + --> $DIR/borrowck-pat-ref-mut-twice.rs:91:24 | LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { - | ^^^^^^^^^^^^^^^---------^ + | ---------------^^^^^^^^^- | | | - | | first mutable borrow occurs here - | second mutable borrow occurs here + | | second mutable borrow occurs here + | first mutable borrow occurs here ... -LL | *b = U; - | ------ first borrow later used here +LL | *a = Err(U); + | ----------- first borrow later used here error[E0499]: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:84:37 + --> $DIR/borrowck-pat-ref-mut-twice.rs:91:53 + | +LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { + | ----------------^^^^^^^^^- + | | | + | | second mutable borrow occurs here + | first mutable borrow occurs here +... +LL | *a = Err(U); + | ----------- first borrow later used here + +error[E0499]: cannot borrow value as mutable more than once at a time + --> $DIR/borrowck-pat-ref-mut-twice.rs:103:24 + | +LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { + | ---------------^^^^^^^^^- + | | | + | | second mutable borrow occurs here + | first mutable borrow occurs here +... +LL | drop(a); + | - first borrow later used here + +error[E0499]: cannot borrow value as mutable more than once at a time + --> $DIR/borrowck-pat-ref-mut-twice.rs:103:53 | LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { - | ^^^^^^^^^^^^^^^^---------^ + | ----------------^^^^^^^^^- | | | - | | first mutable borrow occurs here - | second mutable borrow occurs here + | | second mutable borrow occurs here + | first mutable borrow occurs here ... -LL | *b = U; - | ------ first borrow later used here +LL | drop(a); + | - first borrow later used here error[E0382]: borrow of moved value --> $DIR/borrowck-pat-ref-mut-twice.rs:23:34 @@ -316,7 +340,7 @@ LL | fn f4_also_moved(ref mut a @ ref mut b @ c: U) {} | | value borrowed here after move | move occurs because value has type `U`, which does not implement the `Copy` trait -error: aborting due to 29 previous errors +error: aborting due to 31 previous errors Some errors have detailed explanations: E0382, E0499. For more information about an error, try `rustc --explain E0382`. |
