Put new bindings first in refutable cases too
This commit is contained in:
parent
e902878908
commit
09d4613f20
@ -87,7 +87,7 @@ pub(super) fn simplify_candidate<'pat>(
|
||||
// let z = (x as Variant).copy_field;
|
||||
// // and raises an error
|
||||
// }
|
||||
let mut original_bindings = mem::take(&mut candidate.bindings);
|
||||
let original_bindings = mem::take(&mut candidate.bindings);
|
||||
let mut new_bindings = Vec::new();
|
||||
// Repeatedly simplify match pairs until fixed point is reached
|
||||
loop {
|
||||
@ -115,9 +115,9 @@ pub(super) fn simplify_candidate<'pat>(
|
||||
}
|
||||
|
||||
// Restore original bindings and append the new ones.
|
||||
// This does: candidate.bindings = original_bindings ++ new_bindings
|
||||
mem::swap(&mut candidate.bindings, &mut original_bindings);
|
||||
candidate.bindings.extend_from_slice(&new_bindings);
|
||||
// This does: candidate.bindings = new_bindings ++ original_bindings
|
||||
mem::swap(&mut candidate.bindings, &mut new_bindings);
|
||||
candidate.bindings.extend_from_slice(&original_bindings);
|
||||
|
||||
let did_expand_or =
|
||||
if let [MatchPair { pattern: Pat { kind: PatKind::Or { pats }, .. }, place }] =
|
||||
|
@ -51,13 +51,13 @@
|
||||
- }
|
||||
-
|
||||
- bb3: {
|
||||
StorageLive(_8);
|
||||
_8 = (((_3.0: std::option::Option<u32>) as Some).0: u32);
|
||||
StorageLive(_9);
|
||||
_9 = (((_3.1: std::option::Option<u32>) as Some).0: u32);
|
||||
StorageLive(_8);
|
||||
_8 = (((_3.0: std::option::Option<u32>) as Some).0: u32);
|
||||
_0 = const 0_u32;
|
||||
StorageDead(_9);
|
||||
StorageDead(_8);
|
||||
StorageDead(_9);
|
||||
- goto -> bb4;
|
||||
+ goto -> bb3;
|
||||
}
|
||||
|
@ -58,13 +58,13 @@
|
||||
-
|
||||
- bb4: {
|
||||
+ bb2: {
|
||||
StorageLive(_9);
|
||||
_9 = (((_3.0: std::option::Option<u32>) as Some).0: u32);
|
||||
StorageLive(_10);
|
||||
_10 = (((_3.1: std::option::Option<u32>) as Some).0: u32);
|
||||
StorageLive(_9);
|
||||
_9 = (((_3.0: std::option::Option<u32>) as Some).0: u32);
|
||||
_0 = const 0_u32;
|
||||
StorageDead(_10);
|
||||
StorageDead(_9);
|
||||
StorageDead(_10);
|
||||
- goto -> bb6;
|
||||
+ goto -> bb4;
|
||||
}
|
||||
|
@ -51,13 +51,13 @@
|
||||
- }
|
||||
-
|
||||
- bb3: {
|
||||
StorageLive(_8);
|
||||
_8 = (((_3.0: std::option::Option<u32>) as Some).0: u32);
|
||||
StorageLive(_9);
|
||||
_9 = (((_3.1: std::option::Option<bool>) as Some).0: bool);
|
||||
StorageLive(_8);
|
||||
_8 = (((_3.0: std::option::Option<u32>) as Some).0: u32);
|
||||
_0 = const 0_u32;
|
||||
StorageDead(_9);
|
||||
StorageDead(_8);
|
||||
StorageDead(_9);
|
||||
- goto -> bb4;
|
||||
+ goto -> bb3;
|
||||
}
|
||||
|
@ -69,16 +69,16 @@
|
||||
|
||||
- bb4: {
|
||||
+ bb3: {
|
||||
StorageLive(_11);
|
||||
_11 = (((_4.0: std::option::Option<u32>) as Some).0: u32);
|
||||
StorageLive(_12);
|
||||
_12 = (((_4.1: std::option::Option<u32>) as Some).0: u32);
|
||||
StorageLive(_13);
|
||||
_13 = (((_4.2: std::option::Option<u32>) as Some).0: u32);
|
||||
StorageLive(_12);
|
||||
_12 = (((_4.1: std::option::Option<u32>) as Some).0: u32);
|
||||
StorageLive(_11);
|
||||
_11 = (((_4.0: std::option::Option<u32>) as Some).0: u32);
|
||||
_0 = const 0_u32;
|
||||
StorageDead(_13);
|
||||
StorageDead(_12);
|
||||
StorageDead(_11);
|
||||
StorageDead(_12);
|
||||
StorageDead(_13);
|
||||
- goto -> bb5;
|
||||
+ goto -> bb4;
|
||||
}
|
||||
|
@ -116,12 +116,12 @@
|
||||
}
|
||||
|
||||
bb6: {
|
||||
StorageLive(_12);
|
||||
_39 = deref_copy (_4.0: &ViewportPercentageLength);
|
||||
_12 = (((*_39) as Vw).0: f32);
|
||||
StorageLive(_13);
|
||||
_40 = deref_copy (_4.1: &ViewportPercentageLength);
|
||||
_13 = (((*_40) as Vw).0: f32);
|
||||
_39 = deref_copy (_4.1: &ViewportPercentageLength);
|
||||
_13 = (((*_39) as Vw).0: f32);
|
||||
StorageLive(_12);
|
||||
_40 = deref_copy (_4.0: &ViewportPercentageLength);
|
||||
_12 = (((*_40) as Vw).0: f32);
|
||||
StorageLive(_14);
|
||||
StorageLive(_15);
|
||||
_15 = _12;
|
||||
@ -132,18 +132,18 @@
|
||||
StorageDead(_15);
|
||||
_3 = ViewportPercentageLength::Vw(move _14);
|
||||
StorageDead(_14);
|
||||
StorageDead(_13);
|
||||
StorageDead(_12);
|
||||
StorageDead(_13);
|
||||
goto -> bb10;
|
||||
}
|
||||
|
||||
bb7: {
|
||||
StorageLive(_17);
|
||||
_41 = deref_copy (_4.0: &ViewportPercentageLength);
|
||||
_17 = (((*_41) as Vh).0: f32);
|
||||
StorageLive(_18);
|
||||
_42 = deref_copy (_4.1: &ViewportPercentageLength);
|
||||
_18 = (((*_42) as Vh).0: f32);
|
||||
_41 = deref_copy (_4.1: &ViewportPercentageLength);
|
||||
_18 = (((*_41) as Vh).0: f32);
|
||||
StorageLive(_17);
|
||||
_42 = deref_copy (_4.0: &ViewportPercentageLength);
|
||||
_17 = (((*_42) as Vh).0: f32);
|
||||
StorageLive(_19);
|
||||
StorageLive(_20);
|
||||
_20 = _17;
|
||||
@ -154,18 +154,18 @@
|
||||
StorageDead(_20);
|
||||
_3 = ViewportPercentageLength::Vh(move _19);
|
||||
StorageDead(_19);
|
||||
StorageDead(_18);
|
||||
StorageDead(_17);
|
||||
StorageDead(_18);
|
||||
goto -> bb10;
|
||||
}
|
||||
|
||||
bb8: {
|
||||
StorageLive(_22);
|
||||
_43 = deref_copy (_4.0: &ViewportPercentageLength);
|
||||
_22 = (((*_43) as Vmin).0: f32);
|
||||
StorageLive(_23);
|
||||
_44 = deref_copy (_4.1: &ViewportPercentageLength);
|
||||
_23 = (((*_44) as Vmin).0: f32);
|
||||
_43 = deref_copy (_4.1: &ViewportPercentageLength);
|
||||
_23 = (((*_43) as Vmin).0: f32);
|
||||
StorageLive(_22);
|
||||
_44 = deref_copy (_4.0: &ViewportPercentageLength);
|
||||
_22 = (((*_44) as Vmin).0: f32);
|
||||
StorageLive(_24);
|
||||
StorageLive(_25);
|
||||
_25 = _22;
|
||||
@ -176,18 +176,18 @@
|
||||
StorageDead(_25);
|
||||
_3 = ViewportPercentageLength::Vmin(move _24);
|
||||
StorageDead(_24);
|
||||
StorageDead(_23);
|
||||
StorageDead(_22);
|
||||
StorageDead(_23);
|
||||
goto -> bb10;
|
||||
}
|
||||
|
||||
bb9: {
|
||||
StorageLive(_27);
|
||||
_45 = deref_copy (_4.0: &ViewportPercentageLength);
|
||||
_27 = (((*_45) as Vmax).0: f32);
|
||||
StorageLive(_28);
|
||||
_46 = deref_copy (_4.1: &ViewportPercentageLength);
|
||||
_28 = (((*_46) as Vmax).0: f32);
|
||||
_45 = deref_copy (_4.1: &ViewportPercentageLength);
|
||||
_28 = (((*_45) as Vmax).0: f32);
|
||||
StorageLive(_27);
|
||||
_46 = deref_copy (_4.0: &ViewportPercentageLength);
|
||||
_27 = (((*_46) as Vmax).0: f32);
|
||||
StorageLive(_29);
|
||||
StorageLive(_30);
|
||||
_30 = _27;
|
||||
@ -198,8 +198,8 @@
|
||||
StorageDead(_30);
|
||||
_3 = ViewportPercentageLength::Vmax(move _29);
|
||||
StorageDead(_29);
|
||||
StorageDead(_28);
|
||||
StorageDead(_27);
|
||||
StorageDead(_28);
|
||||
goto -> bb10;
|
||||
}
|
||||
|
||||
|
@ -59,13 +59,13 @@
|
||||
}
|
||||
|
||||
bb5: {
|
||||
StorageLive(_9);
|
||||
_9 = (((_3.0: std::option::Option<u32>) as Some).0: u32);
|
||||
StorageLive(_10);
|
||||
_10 = (((_3.1: std::option::Option<u32>) as Some).0: u32);
|
||||
StorageLive(_9);
|
||||
_9 = (((_3.0: std::option::Option<u32>) as Some).0: u32);
|
||||
_0 = const 0_u32;
|
||||
StorageDead(_10);
|
||||
StorageDead(_9);
|
||||
StorageDead(_10);
|
||||
goto -> bb8;
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
// run-pass
|
||||
#![allow(unused)]
|
||||
|
||||
// Test copy
|
||||
@ -41,7 +42,6 @@ pub fn main() {
|
||||
|
||||
match (E::E { a: 10, e: C { c: 20 } }) {
|
||||
x @ E::E{ a, e: C { c } } => {
|
||||
//~^ ERROR use of moved value
|
||||
assert!(matches!(x, E::E { a: 10, e: C { c: 20 } }));
|
||||
assert!(a == 10);
|
||||
assert!(c == 20);
|
||||
@ -50,7 +50,6 @@ pub fn main() {
|
||||
}
|
||||
match (E::E { a: 10, e: C { c: 20 } }) {
|
||||
mut x @ E::E{ a, e: C { mut c } } => {
|
||||
//~^ ERROR use of moved value
|
||||
x = E::NotE;
|
||||
c += 30;
|
||||
assert_eq!(c, 50);
|
||||
|
@ -15,8 +15,8 @@ fn u() -> U {
|
||||
let a @ (b, c) = (u(), u()); //~ ERROR use of partially moved value
|
||||
|
||||
match Ok(U) {
|
||||
a @ Ok(b) | a @ Err(b) => {} //~ ERROR use of moved value
|
||||
//~^ ERROR use of moved value
|
||||
a @ Ok(b) | a @ Err(b) => {} //~ ERROR use of partially moved value
|
||||
//~^ ERROR use of partially moved value
|
||||
}
|
||||
|
||||
fn fun(a @ b: U) {} //~ ERROR use of moved value
|
||||
|
@ -40,35 +40,33 @@ help: borrow this binding in the pattern to avoid moving the value
|
||||
LL | let ref a @ (b, ref c) = (u(), u());
|
||||
| +++ +++
|
||||
|
||||
error[E0382]: use of moved value
|
||||
--> $DIR/borrowck-move-and-move.rs:18:16
|
||||
error[E0382]: use of partially moved value
|
||||
--> $DIR/borrowck-move-and-move.rs:18:9
|
||||
|
|
||||
LL | match Ok(U) {
|
||||
| ----- move occurs because value has type `Result<U, U>`, which does not implement the `Copy` trait
|
||||
LL | a @ Ok(b) | a @ Err(b) => {}
|
||||
| - ^ value used here after move
|
||||
| ^ - value partially moved here
|
||||
| |
|
||||
| value 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 binding in the pattern to avoid moving the value
|
||||
|
|
||||
LL | ref a @ Ok(b) | a @ Err(b) => {}
|
||||
| +++
|
||||
LL | ref a @ Ok(ref b) | a @ Err(b) => {}
|
||||
| +++ +++
|
||||
|
||||
error[E0382]: use of moved value
|
||||
--> $DIR/borrowck-move-and-move.rs:18:29
|
||||
error[E0382]: use of partially moved value
|
||||
--> $DIR/borrowck-move-and-move.rs:18:21
|
||||
|
|
||||
LL | match Ok(U) {
|
||||
| ----- move occurs because value has type `Result<U, U>`, which does not implement the `Copy` trait
|
||||
LL | a @ Ok(b) | a @ Err(b) => {}
|
||||
| - ^ value used here after move
|
||||
| ^ - value partially moved here
|
||||
| |
|
||||
| value 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 binding in the pattern to avoid moving the value
|
||||
|
|
||||
LL | a @ Ok(b) | ref a @ Err(b) => {}
|
||||
| +++
|
||||
LL | a @ Ok(b) | ref a @ Err(ref b) => {}
|
||||
| +++ +++
|
||||
|
||||
error[E0382]: use of partially moved value
|
||||
--> $DIR/borrowck-move-and-move.rs:25:9
|
||||
|
@ -48,19 +48,17 @@ fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {}
|
||||
//~^ ERROR borrow of moved value
|
||||
//~| ERROR borrow of moved value
|
||||
//~| ERROR borrow of moved value
|
||||
//~| ERROR use of moved value
|
||||
//~| ERROR use of partially 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,13 +66,12 @@ fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {}
|
||||
//~^ ERROR borrow of moved value
|
||||
//~| ERROR borrow of moved value
|
||||
//~| ERROR borrow of moved value
|
||||
//~| ERROR use of moved value
|
||||
//~| ERROR use of partially 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 => {}
|
||||
}
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ LL | ref mut a @ Some([ref b, ref mut c]) => {}
|
||||
| +++
|
||||
|
||||
error: borrow of moved value
|
||||
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:61:9
|
||||
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:60:9
|
||||
|
|
||||
LL | a @ Some(ref b) => {}
|
||||
| ^ ----- value borrowed here after move
|
||||
@ -229,7 +229,7 @@ LL | ref a @ Some(ref b) => {}
|
||||
| +++
|
||||
|
||||
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:65:9
|
||||
|
|
||||
LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {}
|
||||
| ^ --------- ----- value borrowed here after move
|
||||
@ -244,7 +244,7 @@ LL | ref a @ Some((mut b @ ref mut c, d @ ref e)) => {}
|
||||
| +++
|
||||
|
||||
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:65:19
|
||||
|
|
||||
LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {}
|
||||
| ^^^^^ --------- value borrowed here after move
|
||||
@ -258,7 +258,7 @@ LL | a @ Some((ref mut b @ ref mut c, d @ ref e)) => {}
|
||||
| +++
|
||||
|
||||
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:65:38
|
||||
|
|
||||
LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {}
|
||||
| ^ ----- value borrowed here after move
|
||||
@ -272,7 +272,7 @@ LL | a @ Some((mut b @ ref mut c, ref d @ ref e)) => {}
|
||||
| +++
|
||||
|
||||
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:73:9
|
||||
|
|
||||
LL | mut a @ Some([ref b, ref mut c]) => {}
|
||||
| ^^^^^ ----- --------- value borrowed here after move
|
||||
@ -314,66 +314,33 @@ help: borrow this binding in the pattern to avoid moving the value
|
||||
LL | let ref a @ (mut b @ ref mut c, ref d @ ref e) = (u(), u());
|
||||
| +++ +++
|
||||
|
||||
error[E0382]: use of moved value
|
||||
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:47:38
|
||||
error[E0382]: use of partially moved value
|
||||
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:47:9
|
||||
|
|
||||
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 moved here ^ value used here after move
|
||||
| ^ - 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 binding in the pattern to avoid moving the value
|
||||
|
|
||||
LL | ref a @ Some((mut b @ ref mut c, d @ ref e)) => {}
|
||||
| +++
|
||||
LL | ref a @ Some((mut b @ ref mut c, ref d @ ref e)) => {}
|
||||
| +++ +++
|
||||
|
||||
error[E0382]: borrow of moved value
|
||||
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:55:30
|
||||
error[E0382]: use of partially moved value
|
||||
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:65:9
|
||||
|
|
||||
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:61:18
|
||||
|
|
||||
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
|
||||
|
|
||||
help: borrow this binding in the pattern to avoid moving the value
|
||||
|
|
||||
LL | ref a @ Some(ref b) => {}
|
||||
| +++
|
||||
|
||||
error[E0382]: use of moved value
|
||||
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:67: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 moved here ^ value used here after move
|
||||
| ^ - 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 binding in the pattern to avoid moving the value
|
||||
|
|
||||
LL | ref a @ Some((mut b @ ref mut c, d @ ref e)) => {}
|
||||
| +++
|
||||
|
||||
error[E0382]: borrow of moved value
|
||||
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:75:30
|
||||
|
|
||||
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
|
||||
LL | ref a @ Some((mut b @ ref mut c, ref d @ ref e)) => {}
|
||||
| +++ +++
|
||||
|
||||
error: borrow of moved value
|
||||
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:11:11
|
||||
@ -457,6 +424,6 @@ help: borrow this binding in the pattern to avoid moving the value
|
||||
LL | fn f3(ref a @ [ref mut b, ref c]: [U; 2]) {}
|
||||
| +++
|
||||
|
||||
error: aborting due to 33 previous errors
|
||||
error: aborting due to 30 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0382`.
|
||||
|
@ -58,11 +58,13 @@ fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {}
|
||||
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())) {
|
||||
@ -77,6 +79,7 @@ fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {}
|
||||
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 => {}
|
||||
}
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ LL | ref mut a @ Some([b, mut c]) => {}
|
||||
| value is mutably borrowed by `a` here
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:64:9
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:65:9
|
||||
|
|
||||
LL | ref a @ Some(b) => {}
|
||||
| ^^^^^ - value is moved into `b` here
|
||||
@ -133,7 +133,7 @@ LL | ref a @ Some(b) => {}
|
||||
| value is borrowed by `a` here
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:69:9
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:71:9
|
||||
|
|
||||
LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {}
|
||||
| ^^^^^ ----- - value is moved into `e` here
|
||||
@ -142,7 +142,7 @@ LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {}
|
||||
| value is borrowed by `a` here
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:69:23
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:71:23
|
||||
|
|
||||
LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {}
|
||||
| ^^^^^ ----- value is moved into `c` here
|
||||
@ -150,7 +150,7 @@ LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {}
|
||||
| value is borrowed by `b` here
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:69:38
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:71:38
|
||||
|
|
||||
LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {}
|
||||
| ^^^^^ - value is moved into `e` here
|
||||
@ -158,7 +158,7 @@ LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {}
|
||||
| value is borrowed by `d` here
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:78:9
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:80:9
|
||||
|
|
||||
LL | ref mut a @ Some([b, mut c]) => {}
|
||||
| ^^^^^^^^^ - ----- value is moved into `c` here
|
||||
@ -236,8 +236,36 @@ help: borrow this binding in the pattern to avoid moving the value
|
||||
LL | let ref mut a @ [b, ref mut c] = [u(), u()];
|
||||
| +++
|
||||
|
||||
error[E0382]: borrow of partially moved value
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:59: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 binding 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:65: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 binding 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:69:23
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:71:23
|
||||
|
|
||||
LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {}
|
||||
| ^^^^^ ----- value moved here
|
||||
@ -251,7 +279,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:69:38
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:71:38
|
||||
|
|
||||
LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {}
|
||||
| ^^^^^ - value moved here
|
||||
@ -264,6 +292,20 @@ help: borrow this binding 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:80: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 binding in the pattern to avoid moving the value
|
||||
|
|
||||
LL | ref mut a @ Some([b, ref mut c]) => {}
|
||||
| +++
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:11:11
|
||||
|
|
||||
@ -345,6 +387,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 36 previous errors
|
||||
error: aborting due to 39 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0382`.
|
||||
|
@ -7,7 +7,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 immutable because it is also borrowed as mutable
|
||||
//~| ERROR cannot borrow value as mutable because it is also borrowed as immutable
|
||||
**z = None;
|
||||
println!("{}", *a);
|
||||
}
|
||||
@ -76,8 +76,8 @@ fn f4_also_moved(ref a @ ref mut b @ c: U) {}
|
||||
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 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
|
||||
*b = U;
|
||||
drop(a);
|
||||
}
|
||||
@ -87,6 +87,8 @@ fn f4_also_moved(ref a @ ref mut b @ c: U) {}
|
||||
ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; 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 assign to `*b`, as it is immutable for the pattern guard
|
||||
_ => {}
|
||||
}
|
||||
@ -101,6 +103,8 @@ fn f4_also_moved(ref a @ ref mut b @ c: U) {}
|
||||
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
|
||||
_ => {}
|
||||
|
@ -138,7 +138,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false }
|
||||
| value is borrowed by `a` here
|
||||
|
||||
error: cannot borrow value as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:94: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 } => {}
|
||||
| ^^^^^^^^^ ----- value is borrowed by `b` here
|
||||
@ -146,7 +146,7 @@ LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); fa
|
||||
| value is mutably borrowed by `a` here
|
||||
|
||||
error: cannot borrow value as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:94: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 } => {}
|
||||
| ^^^^^^^^^ ----- value is borrowed by `b` here
|
||||
@ -154,7 +154,7 @@ LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); fa
|
||||
| value is mutably borrowed by `a` here
|
||||
|
||||
error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:101: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 } => {}
|
||||
| ^^^^^ --------- value is mutably borrowed by `b` here
|
||||
@ -162,7 +162,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false
|
||||
| value is borrowed by `a` here
|
||||
|
||||
error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:101: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 } => {}
|
||||
| ^^^^^ --------- value is mutably borrowed by `b` here
|
||||
@ -170,7 +170,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false
|
||||
| value is borrowed by `a` here
|
||||
|
||||
error: cannot borrow value as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:109:9
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:113:9
|
||||
|
|
||||
LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false } => {}
|
||||
| ^^^^^^^^^ ----- value is borrowed by `b` here
|
||||
@ -178,7 +178,7 @@ LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false
|
||||
| value is mutably borrowed by `a` here
|
||||
|
||||
error: cannot borrow value as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:109:33
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:113:33
|
||||
|
|
||||
LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false } => {}
|
||||
| ^^^^^^^^^ ----- value is borrowed by `b` here
|
||||
@ -186,7 +186,7 @@ LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false
|
||||
| value is mutably borrowed by `a` here
|
||||
|
||||
error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:117:9
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:121:9
|
||||
|
|
||||
LL | let ref a @ (ref mut b, ref mut c) = (U, U);
|
||||
| ^^^^^ --------- --------- value is mutably borrowed by `c` here
|
||||
@ -195,7 +195,7 @@ LL | let ref a @ (ref mut b, ref mut c) = (U, U);
|
||||
| value is borrowed by `a` 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:127:9
|
||||
|
|
||||
LL | let ref a @ (ref mut b, ref mut c) = (U, U);
|
||||
| ^^^^^ --------- --------- value is mutably borrowed by `c` here
|
||||
@ -204,7 +204,7 @@ LL | let ref a @ (ref mut b, ref mut c) = (U, U);
|
||||
| value is borrowed by `a` 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:133:9
|
||||
|
|
||||
LL | let ref a @ (ref mut b, ref mut c) = (U, U);
|
||||
| ^^^^^ --------- --------- value is mutably borrowed by `c` here
|
||||
@ -213,7 +213,7 @@ LL | let ref a @ (ref mut b, ref mut c) = (U, U);
|
||||
| value is borrowed by `a` here
|
||||
|
||||
error: cannot borrow value as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:134:9
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:138:9
|
||||
|
|
||||
LL | let ref mut a @ (ref b, ref c) = (U, U);
|
||||
| ^^^^^^^^^ ----- ----- value is borrowed by `c` here
|
||||
@ -221,16 +221,16 @@ LL | let ref mut a @ (ref b, ref c) = (U, U);
|
||||
| | value is borrowed by `b` here
|
||||
| value is mutably borrowed by `a` here
|
||||
|
||||
error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:8:31
|
||||
error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:8:9
|
||||
|
|
||||
LL | ref mut z @ &mut Some(ref a) => {
|
||||
| --------- ^^^^^ immutable borrow occurs here
|
||||
| ^^^^^^^^^ ----- immutable borrow occurs here
|
||||
| |
|
||||
| mutable borrow occurs here
|
||||
...
|
||||
LL | **z = None;
|
||||
| ---------- mutable borrow later used here
|
||||
LL | println!("{}", *a);
|
||||
| -- immutable 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:46:9
|
||||
@ -254,27 +254,44 @@ LL | let ref a @ ref mut b = u();
|
||||
LL | *b = u();
|
||||
| -------- 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:76:20
|
||||
error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:76:9
|
||||
|
|
||||
LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => {
|
||||
| ----- ^^^^^^^^^ mutable borrow occurs here
|
||||
| ^^^^^ --------- mutable borrow occurs here
|
||||
| |
|
||||
| immutable borrow occurs here
|
||||
...
|
||||
LL | drop(a);
|
||||
| - immutable borrow later used here
|
||||
LL | *b = U;
|
||||
| ------ 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:76:45
|
||||
error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:76:33
|
||||
|
|
||||
LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => {
|
||||
| ----- ^^^^^^^^^ mutable borrow occurs here
|
||||
| ^^^^^ --------- mutable borrow occurs here
|
||||
| |
|
||||
| immutable borrow occurs here
|
||||
...
|
||||
LL | drop(a);
|
||||
| - immutable borrow later used 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:87:9
|
||||
|
|
||||
LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false } => {}
|
||||
| ^^^^^ --------- mutable borrow occurs here ------ mutable borrow later used 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:87: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
|
||||
|
||||
error[E0594]: cannot assign to `*b`, as it is immutable for the pattern guard
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:87:61
|
||||
@ -285,15 +302,32 @@ 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:94: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:103:9
|
||||
|
|
||||
LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {}
|
||||
| ^^^^^ --------- mutable borrow occurs here - mutable borrow later used 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:103: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:101: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
|
||||
@ -301,7 +335,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:101: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
|
||||
@ -310,7 +344,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error[E0507]: cannot move out of `a` in pattern guard
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:109:66
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:113: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 Result<U, U>`, which does not implement the `Copy` trait
|
||||
@ -318,7 +352,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:109:66
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:113: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 Result<U, U>`, which does not implement the `Copy` trait
|
||||
@ -327,7 +361,7 @@ LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:117:9
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:121:9
|
||||
|
|
||||
LL | let ref a @ (ref mut b, ref mut c) = (U, U);
|
||||
| ^^^^^ --------- mutable borrow occurs here
|
||||
@ -338,7 +372,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:123:9
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:127:9
|
||||
|
|
||||
LL | let ref a @ (ref mut b, ref mut c) = (U, U);
|
||||
| ^^^^^ --------- mutable borrow occurs here
|
||||
@ -349,7 +383,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:133:9
|
||||
|
|
||||
LL | let ref a @ (ref mut b, ref mut c) = (U, U);
|
||||
| ^^^^^ --------- mutable borrow occurs here
|
||||
@ -409,7 +443,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 47 previous errors
|
||||
error: aborting due to 51 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0382, E0502, E0507, E0594.
|
||||
For more information about an error, try `rustc --explain E0382`.
|
||||
|
@ -82,6 +82,8 @@ fn f4_also_moved(ref mut a @ ref mut b @ c: U) {}
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -89,8 +91,6 @@ fn f4_also_moved(ref mut a @ ref mut b @ c: U) {}
|
||||
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.
|
||||
@ -101,8 +101,6 @@ fn f4_also_moved(ref mut a @ ref mut b @ c: U) {}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
|
||||
| value is mutably borrowed by `a` here
|
||||
|
||||
error: cannot borrow value as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:89: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) => {
|
||||
| ^^^^^^^^^ --------- value is mutably borrowed by `b` here
|
||||
@ -171,7 +171,7 @@ LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
|
||||
| value is mutably borrowed by `a` here
|
||||
|
||||
error: cannot borrow value as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:89: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) => {
|
||||
| ^^^^^^^^^ --------- value is mutably borrowed by `b` here
|
||||
@ -217,48 +217,26 @@ 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:89:24
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:82:9
|
||||
|
|
||||
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
|
||||
| |
|
||||
| first mutable borrow occurs here
|
||||
| second mutable borrow occurs here
|
||||
...
|
||||
LL | *a = Err(U);
|
||||
| ----------- first borrow later used here
|
||||
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:89:53
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:82:37
|
||||
|
|
||||
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
|
||||
| |
|
||||
| first mutable borrow occurs here
|
||||
| second 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:101: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:101: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 | drop(a);
|
||||
| - first borrow later used here
|
||||
LL | *b = U;
|
||||
| ------ first borrow later used here
|
||||
|
||||
error: cannot borrow value as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:8:11
|
||||
@ -313,7 +291,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 31 previous errors
|
||||
error: aborting due to 29 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0382, E0499.
|
||||
For more information about an error, try `rustc --explain E0382`.
|
||||
|
Loading…
Reference in New Issue
Block a user