Rollup merge of #106978 - mejrs:mir_build3, r=davidtwco
Migrate mir_build's borrow conflicts This also changes the error message slightly, for two reasons: - I'm not a fan of saying "value borrowed, by `x`, here" - it simplifies the error implementation significantly.
This commit is contained in:
commit
e8c17de11d
@ -299,10 +299,18 @@ mir_build_borrow_of_moved_value = borrow of moved value
|
||||
.suggestion = borrow this binding in the pattern to avoid moving the value
|
||||
|
||||
mir_build_multiple_mut_borrows = cannot borrow value as mutable more than once at a time
|
||||
.label = first mutable borrow, by `{$name}`, occurs here
|
||||
.mutable_borrow = another mutable borrow, by `{$name_mut}`, occurs here
|
||||
.immutable_borrow = also borrowed as immutable, by `{$name_immut}`, here
|
||||
.moved = also moved into `{$name_moved}` here
|
||||
|
||||
mir_build_already_borrowed = cannot borrow value as mutable because it is also borrowed as immutable
|
||||
|
||||
mir_build_already_mut_borrowed = cannot borrow value as immutable because it is also borrowed as mutable
|
||||
|
||||
mir_build_moved_while_borrowed = cannot move out of value because it is borrowed
|
||||
|
||||
mir_build_mutable_borrow = value is mutably borrowed by `{$name}` here
|
||||
|
||||
mir_build_borrow = value is borrowed by `{$name}` here
|
||||
|
||||
mir_build_moved = value is moved into `{$name}` here
|
||||
|
||||
mir_build_union_pattern = cannot use unions in constant patterns
|
||||
|
||||
|
@ -600,32 +600,56 @@ pub struct BorrowOfMovedValue<'tcx> {
|
||||
pub struct MultipleMutBorrows {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
#[label]
|
||||
pub binding_span: Span,
|
||||
#[subdiagnostic]
|
||||
pub occurences: Vec<MultipleMutBorrowOccurence>,
|
||||
pub name: Ident,
|
||||
pub occurences: Vec<Conflict>,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(mir_build_already_borrowed)]
|
||||
pub struct AlreadyBorrowed {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
#[subdiagnostic]
|
||||
pub occurences: Vec<Conflict>,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(mir_build_already_mut_borrowed)]
|
||||
pub struct AlreadyMutBorrowed {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
#[subdiagnostic]
|
||||
pub occurences: Vec<Conflict>,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(mir_build_moved_while_borrowed)]
|
||||
pub struct MovedWhileBorrowed {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
#[subdiagnostic]
|
||||
pub occurences: Vec<Conflict>,
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
pub enum MultipleMutBorrowOccurence {
|
||||
#[label(mutable_borrow)]
|
||||
Mutable {
|
||||
pub enum Conflict {
|
||||
#[label(mir_build_mutable_borrow)]
|
||||
Mut {
|
||||
#[primary_span]
|
||||
span: Span,
|
||||
name_mut: Ident,
|
||||
name: Ident,
|
||||
},
|
||||
#[label(immutable_borrow)]
|
||||
Immutable {
|
||||
#[label(mir_build_borrow)]
|
||||
Ref {
|
||||
#[primary_span]
|
||||
span: Span,
|
||||
name_immut: Ident,
|
||||
name: Ident,
|
||||
},
|
||||
#[label(moved)]
|
||||
#[label(mir_build_moved)]
|
||||
Moved {
|
||||
#[primary_span]
|
||||
span: Span,
|
||||
name_moved: Ident,
|
||||
name: Ident,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -926,58 +926,55 @@ fn check_borrow_conflicts_in_at_patterns(cx: &MatchVisitor<'_, '_, '_>, pat: &Pa
|
||||
sub.each_binding(|_, hir_id, span, name| {
|
||||
match typeck_results.extract_binding_mode(sess, hir_id, span) {
|
||||
Some(ty::BindByReference(mut_inner)) => match (mut_outer, mut_inner) {
|
||||
(Mutability::Not, Mutability::Not) => {} // Both sides are `ref`.
|
||||
(Mutability::Mut, Mutability::Mut) => conflicts_mut_mut.push((span, name)), // 2x `ref mut`.
|
||||
_ => conflicts_mut_ref.push((span, name)), // `ref` + `ref mut` in either direction.
|
||||
// Both sides are `ref`.
|
||||
(Mutability::Not, Mutability::Not) => {}
|
||||
// 2x `ref mut`.
|
||||
(Mutability::Mut, Mutability::Mut) => {
|
||||
conflicts_mut_mut.push(Conflict::Mut { span, name })
|
||||
}
|
||||
(Mutability::Not, Mutability::Mut) => {
|
||||
conflicts_mut_ref.push(Conflict::Mut { span, name })
|
||||
}
|
||||
(Mutability::Mut, Mutability::Not) => {
|
||||
conflicts_mut_ref.push(Conflict::Ref { span, name })
|
||||
}
|
||||
},
|
||||
Some(ty::BindByValue(_)) if is_binding_by_move(cx, hir_id) => {
|
||||
conflicts_move.push((span, name)) // `ref mut?` + by-move conflict.
|
||||
conflicts_move.push(Conflict::Moved { span, name }) // `ref mut?` + by-move conflict.
|
||||
}
|
||||
Some(ty::BindByValue(_)) | None => {} // `ref mut?` + by-copy is fine.
|
||||
}
|
||||
});
|
||||
|
||||
// Report errors if any.
|
||||
if !conflicts_mut_mut.is_empty() {
|
||||
// Report mutability conflicts for e.g. `ref mut x @ Some(ref mut y)`.
|
||||
let mut occurences = vec![];
|
||||
let report_mut_mut = !conflicts_mut_mut.is_empty();
|
||||
let report_mut_ref = !conflicts_mut_ref.is_empty();
|
||||
let report_move_conflict = !conflicts_move.is_empty();
|
||||
|
||||
for (span, name_mut) in conflicts_mut_mut {
|
||||
occurences.push(MultipleMutBorrowOccurence::Mutable { span, name_mut });
|
||||
}
|
||||
for (span, name_immut) in conflicts_mut_ref {
|
||||
occurences.push(MultipleMutBorrowOccurence::Immutable { span, name_immut });
|
||||
}
|
||||
for (span, name_moved) in conflicts_move {
|
||||
occurences.push(MultipleMutBorrowOccurence::Moved { span, name_moved });
|
||||
}
|
||||
sess.emit_err(MultipleMutBorrows { span: pat.span, binding_span, occurences, name });
|
||||
} else if !conflicts_mut_ref.is_empty() {
|
||||
// Report mutability conflicts for e.g. `ref x @ Some(ref mut y)` or the converse.
|
||||
let (primary, also) = match mut_outer {
|
||||
Mutability::Mut => ("mutable", "immutable"),
|
||||
Mutability::Not => ("immutable", "mutable"),
|
||||
let mut occurences = match mut_outer {
|
||||
Mutability::Mut => vec![Conflict::Mut { span: binding_span, name }],
|
||||
Mutability::Not => vec![Conflict::Ref { span: binding_span, name }],
|
||||
};
|
||||
let msg =
|
||||
format!("cannot borrow value as {} because it is also borrowed as {}", also, primary);
|
||||
let mut err = sess.struct_span_err(pat.span, &msg);
|
||||
err.span_label(binding_span, format!("{} borrow, by `{}`, occurs here", primary, name));
|
||||
for (span, name) in conflicts_mut_ref {
|
||||
err.span_label(span, format!("{} borrow, by `{}`, occurs here", also, name));
|
||||
occurences.extend(conflicts_mut_mut);
|
||||
occurences.extend(conflicts_mut_ref);
|
||||
occurences.extend(conflicts_move);
|
||||
|
||||
// Report errors if any.
|
||||
if report_mut_mut {
|
||||
// Report mutability conflicts for e.g. `ref mut x @ Some(ref mut y)`.
|
||||
sess.emit_err(MultipleMutBorrows { span: pat.span, occurences });
|
||||
} else if report_mut_ref {
|
||||
// Report mutability conflicts for e.g. `ref x @ Some(ref mut y)` or the converse.
|
||||
match mut_outer {
|
||||
Mutability::Mut => {
|
||||
sess.emit_err(AlreadyMutBorrowed { span: pat.span, occurences });
|
||||
}
|
||||
for (span, name) in conflicts_move {
|
||||
err.span_label(span, format!("also moved into `{}` here", name));
|
||||
Mutability::Not => {
|
||||
sess.emit_err(AlreadyBorrowed { span: pat.span, occurences });
|
||||
}
|
||||
err.emit();
|
||||
} else if !conflicts_move.is_empty() {
|
||||
};
|
||||
} else if report_move_conflict {
|
||||
// Report by-ref and by-move conflicts, e.g. `ref x @ y`.
|
||||
let mut err =
|
||||
sess.struct_span_err(pat.span, "cannot move out of value because it is borrowed");
|
||||
err.span_label(binding_span, format!("value borrowed, by `{}`, here", name));
|
||||
for (span, name) in conflicts_move {
|
||||
err.span_label(span, format!("value moved into `{}` here", name));
|
||||
}
|
||||
err.emit();
|
||||
sess.emit_err(MovedWhileBorrowed { span: pat.span, occurences });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,8 +4,8 @@ error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
LL | ref foo @ [.., ref mut bar] => (),
|
||||
| -------^^^^^^^^-----------^
|
||||
| | |
|
||||
| | mutable borrow, by `bar`, occurs here
|
||||
| immutable borrow, by `foo`, occurs here
|
||||
| | value is mutably borrowed by `bar` here
|
||||
| value is borrowed by `foo` here
|
||||
|
||||
error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:120:9
|
||||
@ -13,8 +13,8 @@ error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
LL | ref foo @ Some(box ref mut s) => (),
|
||||
| -------^^^^^^^^^^^^---------^
|
||||
| | |
|
||||
| | mutable borrow, by `s`, occurs here
|
||||
| immutable borrow, by `foo`, occurs here
|
||||
| | value is mutably borrowed by `s` here
|
||||
| value is borrowed by `foo` here
|
||||
|
||||
error[E0382]: borrow of moved value: `x`
|
||||
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:18:5
|
||||
|
@ -4,8 +4,8 @@ error: cannot move out of value because it is borrowed
|
||||
LL | Some(ref _y @ _z) => {}
|
||||
| ------^^^--
|
||||
| | |
|
||||
| | value moved into `_z` here
|
||||
| value borrowed, by `_y`, here
|
||||
| | value is moved into `_z` here
|
||||
| value is borrowed by `_y` here
|
||||
|
||||
error: borrow of moved value
|
||||
--> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:19:14
|
||||
@ -28,8 +28,8 @@ error: cannot move out of value because it is borrowed
|
||||
LL | Some(ref mut _y @ _z) => {}
|
||||
| ----------^^^--
|
||||
| | |
|
||||
| | value moved into `_z` here
|
||||
| value borrowed, by `_y`, here
|
||||
| | value is moved into `_z` here
|
||||
| value is mutably borrowed by `_y` here
|
||||
|
||||
error: borrow of moved value
|
||||
--> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:33:14
|
||||
|
@ -4,8 +4,8 @@ error: cannot move out of value because it is borrowed
|
||||
LL | let ref a @ box b = Box::new(NC);
|
||||
| -----^^^^^^^-
|
||||
| | |
|
||||
| | value moved into `b` here
|
||||
| value borrowed, by `a`, here
|
||||
| | value is moved into `b` here
|
||||
| value is borrowed by `a` here
|
||||
|
||||
error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:34:9
|
||||
@ -13,8 +13,8 @@ error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
LL | let ref a @ box ref mut b = Box::new(nc());
|
||||
| -----^^^^^^^---------
|
||||
| | |
|
||||
| | mutable borrow, by `b`, occurs here
|
||||
| immutable borrow, by `a`, occurs here
|
||||
| | value is mutably borrowed by `b` here
|
||||
| value is borrowed by `a` here
|
||||
|
||||
error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:36:9
|
||||
@ -22,8 +22,8 @@ error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
LL | let ref a @ box ref mut b = Box::new(NC);
|
||||
| -----^^^^^^^---------
|
||||
| | |
|
||||
| | mutable borrow, by `b`, occurs here
|
||||
| immutable borrow, by `a`, occurs here
|
||||
| | value is mutably borrowed by `b` here
|
||||
| value is borrowed by `a` here
|
||||
|
||||
error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:38:9
|
||||
@ -31,8 +31,8 @@ error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
LL | let ref a @ box ref mut b = Box::new(NC);
|
||||
| -----^^^^^^^---------
|
||||
| | |
|
||||
| | mutable borrow, by `b`, occurs here
|
||||
| immutable borrow, by `a`, occurs here
|
||||
| | value is mutably borrowed by `b` here
|
||||
| value is borrowed by `a` here
|
||||
|
||||
error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:42:9
|
||||
@ -40,8 +40,8 @@ error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
LL | let ref a @ box ref mut b = Box::new(NC);
|
||||
| -----^^^^^^^---------
|
||||
| | |
|
||||
| | mutable borrow, by `b`, occurs here
|
||||
| immutable borrow, by `a`, occurs here
|
||||
| | value is mutably borrowed by `b` here
|
||||
| value is borrowed by `a` here
|
||||
|
||||
error: cannot borrow value as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:48:9
|
||||
@ -49,8 +49,8 @@ error: cannot borrow value as immutable because it is also borrowed as mutable
|
||||
LL | let ref mut a @ box ref b = Box::new(NC);
|
||||
| ---------^^^^^^^-----
|
||||
| | |
|
||||
| | immutable borrow, by `b`, occurs here
|
||||
| mutable borrow, by `a`, occurs here
|
||||
| | value is borrowed by `b` here
|
||||
| value is mutably borrowed by `a` here
|
||||
|
||||
error: cannot borrow value as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:62:9
|
||||
@ -58,8 +58,8 @@ error: cannot borrow value as immutable because it is also borrowed as mutable
|
||||
LL | ref mut a @ box ref b => {
|
||||
| ---------^^^^^^^-----
|
||||
| | |
|
||||
| | immutable borrow, by `b`, occurs here
|
||||
| mutable borrow, by `a`, occurs here
|
||||
| | value is borrowed by `b` here
|
||||
| value is mutably borrowed by `a` here
|
||||
|
||||
error: cannot borrow value as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:54:11
|
||||
@ -67,8 +67,8 @@ error: cannot borrow value as immutable because it is also borrowed as mutable
|
||||
LL | fn f5(ref mut a @ box ref b: Box<NC>) {
|
||||
| ---------^^^^^^^-----
|
||||
| | |
|
||||
| | immutable borrow, by `b`, occurs here
|
||||
| mutable borrow, by `a`, occurs here
|
||||
| | value is borrowed by `b` here
|
||||
| value is mutably borrowed by `a` here
|
||||
|
||||
error[E0382]: borrow of moved value
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:31:9
|
||||
|
@ -4,8 +4,8 @@ error: cannot move out of value because it is borrowed
|
||||
LL | let ref a @ b = U;
|
||||
| -----^^^-
|
||||
| | |
|
||||
| | value moved into `b` here
|
||||
| value borrowed, by `a`, here
|
||||
| | value is moved into `b` here
|
||||
| value is borrowed by `a` here
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:26:9
|
||||
@ -13,9 +13,9 @@ error: cannot move out of value because it is borrowed
|
||||
LL | let ref a @ (ref b @ mut c, ref d @ e) = (U, U);
|
||||
| -----^^^^^^^^^^^^-----^^^^^^^^^^-^
|
||||
| | | |
|
||||
| | | value moved into `e` here
|
||||
| | value moved into `c` here
|
||||
| value borrowed, by `a`, here
|
||||
| | | value is moved into `e` here
|
||||
| | value is moved into `c` here
|
||||
| value is borrowed by `a` here
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:26:18
|
||||
@ -23,8 +23,8 @@ error: cannot move out of value because it is borrowed
|
||||
LL | let ref a @ (ref b @ mut c, ref d @ e) = (U, U);
|
||||
| -----^^^-----
|
||||
| | |
|
||||
| | value moved into `c` here
|
||||
| value borrowed, by `b`, here
|
||||
| | value is moved into `c` here
|
||||
| value is borrowed by `b` here
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:26:33
|
||||
@ -32,8 +32,8 @@ error: cannot move out of value because it is borrowed
|
||||
LL | let ref a @ (ref b @ mut c, ref d @ e) = (U, U);
|
||||
| -----^^^-
|
||||
| | |
|
||||
| | value moved into `e` here
|
||||
| value borrowed, by `d`, here
|
||||
| | value is moved into `e` here
|
||||
| value is borrowed by `d` here
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:30:9
|
||||
@ -41,9 +41,9 @@ error: cannot move out of value because it is borrowed
|
||||
LL | let ref mut a @ [b, mut c] = [U, U];
|
||||
| ---------^^^^-^^-----^
|
||||
| | | |
|
||||
| | | value moved into `c` here
|
||||
| | value moved into `b` here
|
||||
| value borrowed, by `a`, here
|
||||
| | | value is moved into `c` here
|
||||
| | value is moved into `b` here
|
||||
| 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:33:9
|
||||
@ -51,8 +51,8 @@ error: cannot move out of value because it is borrowed
|
||||
LL | let ref a @ b = u();
|
||||
| -----^^^-
|
||||
| | |
|
||||
| | value moved into `b` here
|
||||
| value borrowed, by `a`, here
|
||||
| | value is moved into `b` here
|
||||
| value is borrowed by `a` here
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:36:9
|
||||
@ -60,9 +60,9 @@ error: cannot move out of value because it is borrowed
|
||||
LL | let ref a @ (ref b @ mut c, ref d @ e) = (u(), u());
|
||||
| -----^^^^^^^^^^^^-----^^^^^^^^^^-^
|
||||
| | | |
|
||||
| | | value moved into `e` here
|
||||
| | value moved into `c` here
|
||||
| value borrowed, by `a`, here
|
||||
| | | value is moved into `e` here
|
||||
| | value is moved into `c` here
|
||||
| value is borrowed by `a` here
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:36:18
|
||||
@ -70,8 +70,8 @@ error: cannot move out of value because it is borrowed
|
||||
LL | let ref a @ (ref b @ mut c, ref d @ e) = (u(), u());
|
||||
| -----^^^-----
|
||||
| | |
|
||||
| | value moved into `c` here
|
||||
| value borrowed, by `b`, here
|
||||
| | value is moved into `c` here
|
||||
| value is borrowed by `b` here
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:36:33
|
||||
@ -79,8 +79,8 @@ error: cannot move out of value because it is borrowed
|
||||
LL | let ref a @ (ref b @ mut c, ref d @ e) = (u(), u());
|
||||
| -----^^^-
|
||||
| | |
|
||||
| | value moved into `e` here
|
||||
| value borrowed, by `d`, here
|
||||
| | value is moved into `e` here
|
||||
| value is borrowed by `d` here
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:42:9
|
||||
@ -88,9 +88,9 @@ error: cannot move out of value because it is borrowed
|
||||
LL | let ref mut a @ [b, mut c] = [u(), u()];
|
||||
| ---------^^^^-^^-----^
|
||||
| | | |
|
||||
| | | value moved into `c` here
|
||||
| | value moved into `b` here
|
||||
| value borrowed, by `a`, here
|
||||
| | | value is moved into `c` here
|
||||
| | value is moved into `b` here
|
||||
| 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:47:9
|
||||
@ -98,8 +98,8 @@ error: cannot move out of value because it is borrowed
|
||||
LL | ref a @ Some(b) => {}
|
||||
| -----^^^^^^^^-^
|
||||
| | |
|
||||
| | value moved into `b` here
|
||||
| value borrowed, by `a`, here
|
||||
| | value is moved into `b` here
|
||||
| value is borrowed by `a` here
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:52:9
|
||||
@ -107,9 +107,9 @@ error: cannot move out of value because it is borrowed
|
||||
LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {}
|
||||
| -----^^^^^^^^^^^^^^^^^-----^^^^^^^^^^-^^
|
||||
| | | |
|
||||
| | | value moved into `e` here
|
||||
| | value moved into `c` here
|
||||
| value borrowed, by `a`, here
|
||||
| | | value is moved into `e` here
|
||||
| | value is moved into `c` here
|
||||
| value is borrowed by `a` here
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:52:23
|
||||
@ -117,8 +117,8 @@ error: cannot move out of value because it is borrowed
|
||||
LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {}
|
||||
| -----^^^-----
|
||||
| | |
|
||||
| | value moved into `c` here
|
||||
| value borrowed, by `b`, here
|
||||
| | value is moved into `c` here
|
||||
| value is borrowed by `b` here
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:52:38
|
||||
@ -126,8 +126,8 @@ error: cannot move out of value because it is borrowed
|
||||
LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {}
|
||||
| -----^^^-
|
||||
| | |
|
||||
| | value moved into `e` here
|
||||
| value borrowed, by `d`, here
|
||||
| | value is moved into `e` here
|
||||
| value is borrowed by `d` here
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:59:9
|
||||
@ -135,9 +135,9 @@ error: cannot move out of value because it is borrowed
|
||||
LL | ref mut a @ Some([b, mut c]) => {}
|
||||
| ---------^^^^^^^^^-^^-----^^
|
||||
| | | |
|
||||
| | | value moved into `c` here
|
||||
| | value moved into `b` here
|
||||
| value borrowed, by `a`, here
|
||||
| | | value is moved into `c` here
|
||||
| | value is moved into `b` here
|
||||
| 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
|
||||
@ -145,8 +145,8 @@ error: cannot move out of value because it is borrowed
|
||||
LL | ref a @ Some(b) => {}
|
||||
| -----^^^^^^^^-^
|
||||
| | |
|
||||
| | value moved into `b` here
|
||||
| value borrowed, by `a`, here
|
||||
| | value is moved into `b` here
|
||||
| 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
|
||||
@ -154,9 +154,9 @@ error: cannot move out of value because it is borrowed
|
||||
LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {}
|
||||
| -----^^^^^^^^^^^^^^^^^-----^^^^^^^^^^-^^
|
||||
| | | |
|
||||
| | | value moved into `e` here
|
||||
| | value moved into `c` here
|
||||
| value borrowed, by `a`, here
|
||||
| | | value is moved into `e` here
|
||||
| | value is moved into `c` here
|
||||
| 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
|
||||
@ -164,8 +164,8 @@ error: cannot move out of value because it is borrowed
|
||||
LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {}
|
||||
| -----^^^-----
|
||||
| | |
|
||||
| | value moved into `c` here
|
||||
| value borrowed, by `b`, here
|
||||
| | value is moved into `c` here
|
||||
| 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
|
||||
@ -173,8 +173,8 @@ error: cannot move out of value because it is borrowed
|
||||
LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {}
|
||||
| -----^^^-
|
||||
| | |
|
||||
| | value moved into `e` here
|
||||
| value borrowed, by `d`, here
|
||||
| | value is moved into `e` here
|
||||
| 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
|
||||
@ -182,9 +182,9 @@ error: cannot move out of value because it is borrowed
|
||||
LL | ref mut a @ Some([b, mut c]) => {}
|
||||
| ---------^^^^^^^^^-^^-----^^
|
||||
| | | |
|
||||
| | | value moved into `c` here
|
||||
| | value moved into `b` here
|
||||
| value borrowed, by `a`, here
|
||||
| | | value is moved into `c` here
|
||||
| | value is moved into `b` here
|
||||
| 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:11:11
|
||||
@ -192,8 +192,8 @@ error: cannot move out of value because it is borrowed
|
||||
LL | fn f1(ref a @ b: U) {}
|
||||
| -----^^^-
|
||||
| | |
|
||||
| | value moved into `b` here
|
||||
| value borrowed, by `a`, here
|
||||
| | value is moved into `b` here
|
||||
| value is borrowed by `a` here
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:14:11
|
||||
@ -201,9 +201,9 @@ error: cannot move out of value because it is borrowed
|
||||
LL | fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {}
|
||||
| -----^^^^^^^^^^^^-----^^^^^^^^^^-^
|
||||
| | | |
|
||||
| | | value moved into `e` here
|
||||
| | value moved into `c` here
|
||||
| value borrowed, by `a`, here
|
||||
| | | value is moved into `e` here
|
||||
| | value is moved into `c` here
|
||||
| value is borrowed by `a` here
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:14:20
|
||||
@ -211,8 +211,8 @@ error: cannot move out of value because it is borrowed
|
||||
LL | fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {}
|
||||
| -----^^^-----
|
||||
| | |
|
||||
| | value moved into `c` here
|
||||
| value borrowed, by `b`, here
|
||||
| | value is moved into `c` here
|
||||
| value is borrowed by `b` here
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:14:35
|
||||
@ -220,8 +220,8 @@ error: cannot move out of value because it is borrowed
|
||||
LL | fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {}
|
||||
| -----^^^-
|
||||
| | |
|
||||
| | value moved into `e` here
|
||||
| value borrowed, by `d`, here
|
||||
| | value is moved into `e` here
|
||||
| value is borrowed by `d` here
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:20:11
|
||||
@ -229,9 +229,9 @@ error: cannot move out of value because it is borrowed
|
||||
LL | fn f3(ref mut a @ [b, mut c]: [U; 2]) {}
|
||||
| ---------^^^^-^^-----^
|
||||
| | | |
|
||||
| | | value moved into `c` here
|
||||
| | value moved into `b` here
|
||||
| value borrowed, by `a`, here
|
||||
| | | value is moved into `c` here
|
||||
| | value is moved into `b` here
|
||||
| value is mutably borrowed by `a` here
|
||||
|
||||
error[E0382]: borrow of partially moved value
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:30:9
|
||||
|
@ -4,8 +4,8 @@ error: cannot borrow value as immutable because it is also borrowed as mutable
|
||||
LL | ref mut z @ &mut Some(ref a) => {
|
||||
| ---------^^^^^^^^^^^^^-----^
|
||||
| | |
|
||||
| | immutable borrow, by `a`, occurs here
|
||||
| mutable borrow, by `z`, occurs here
|
||||
| | value is borrowed by `a` here
|
||||
| value is mutably borrowed by `z` here
|
||||
|
||||
error: cannot borrow value as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:33:9
|
||||
@ -13,9 +13,9 @@ error: cannot borrow value as mutable more than once at a time
|
||||
LL | let ref mut a @ (ref b @ ref mut c) = u(); // sub-in-sub
|
||||
| ---------^^^^-----------------^
|
||||
| | | |
|
||||
| | | another mutable borrow, by `c`, occurs here
|
||||
| | also borrowed as immutable, by `b`, here
|
||||
| first mutable borrow, by `a`, occurs here
|
||||
| | | value is mutably borrowed by `c` here
|
||||
| | value is borrowed by `b` here
|
||||
| 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:33:22
|
||||
@ -23,8 +23,8 @@ error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
LL | let ref mut a @ (ref b @ ref mut c) = u(); // sub-in-sub
|
||||
| -----^^^---------
|
||||
| | |
|
||||
| | mutable borrow, by `c`, occurs here
|
||||
| immutable borrow, by `b`, occurs here
|
||||
| | value is mutably borrowed by `c` here
|
||||
| value is borrowed by `b` here
|
||||
|
||||
error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:37:9
|
||||
@ -32,8 +32,8 @@ error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
LL | let ref a @ ref mut b = U;
|
||||
| -----^^^---------
|
||||
| | |
|
||||
| | mutable borrow, by `b`, occurs here
|
||||
| immutable borrow, by `a`, occurs here
|
||||
| | value is mutably borrowed by `b` here
|
||||
| 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:39:9
|
||||
@ -41,8 +41,8 @@ error: cannot borrow value as immutable because it is also borrowed as mutable
|
||||
LL | let ref mut a @ ref b = U;
|
||||
| ---------^^^-----
|
||||
| | |
|
||||
| | immutable borrow, by `b`, occurs here
|
||||
| mutable borrow, by `a`, occurs here
|
||||
| | value is borrowed by `b` here
|
||||
| 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:41:9
|
||||
@ -50,9 +50,9 @@ error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
LL | let ref a @ (ref mut b, ref mut c) = (U, U);
|
||||
| -----^^^^---------^^---------^
|
||||
| | | |
|
||||
| | | mutable borrow, by `c`, occurs here
|
||||
| | mutable borrow, by `b`, occurs here
|
||||
| immutable borrow, by `a`, occurs here
|
||||
| | | value is mutably borrowed by `c` here
|
||||
| | value is mutably borrowed by `b` here
|
||||
| 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:43:9
|
||||
@ -60,9 +60,9 @@ error: cannot borrow value as immutable because it is also borrowed as mutable
|
||||
LL | let ref mut a @ (ref b, ref c) = (U, U);
|
||||
| ---------^^^^-----^^-----^
|
||||
| | | |
|
||||
| | | immutable borrow, by `c`, occurs here
|
||||
| | immutable borrow, by `b`, occurs here
|
||||
| mutable borrow, by `a`, occurs here
|
||||
| | | value is borrowed by `c` here
|
||||
| | value is borrowed by `b` here
|
||||
| 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:46:9
|
||||
@ -70,8 +70,8 @@ error: cannot borrow value as immutable because it is also borrowed as mutable
|
||||
LL | let ref mut a @ ref b = u();
|
||||
| ---------^^^-----
|
||||
| | |
|
||||
| | immutable borrow, by `b`, occurs here
|
||||
| mutable borrow, by `a`, occurs here
|
||||
| | value is borrowed by `b` here
|
||||
| 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:51:9
|
||||
@ -79,8 +79,8 @@ error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
LL | let ref a @ ref mut b = u();
|
||||
| -----^^^---------
|
||||
| | |
|
||||
| | mutable borrow, by `b`, occurs here
|
||||
| immutable borrow, by `a`, occurs here
|
||||
| | value is mutably borrowed by `b` here
|
||||
| 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:57:9
|
||||
@ -88,8 +88,8 @@ error: cannot borrow value as immutable because it is also borrowed as mutable
|
||||
LL | let ref mut a @ ref b = U;
|
||||
| ---------^^^-----
|
||||
| | |
|
||||
| | immutable borrow, by `b`, occurs here
|
||||
| mutable borrow, by `a`, occurs here
|
||||
| | value is borrowed by `b` here
|
||||
| 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:61:9
|
||||
@ -97,8 +97,8 @@ error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
LL | let ref a @ ref mut b = U;
|
||||
| -----^^^---------
|
||||
| | |
|
||||
| | mutable borrow, by `b`, occurs here
|
||||
| immutable borrow, by `a`, occurs here
|
||||
| | value is mutably borrowed by `b` here
|
||||
| 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:67:9
|
||||
@ -106,8 +106,8 @@ error: cannot borrow value as immutable because it is also borrowed as mutable
|
||||
LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) => {
|
||||
| ---------^^^^^^-----^
|
||||
| | |
|
||||
| | immutable borrow, by `b`, occurs here
|
||||
| mutable borrow, by `a`, occurs here
|
||||
| | value is borrowed by `b` here
|
||||
| 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:67:33
|
||||
@ -115,8 +115,8 @@ error: cannot borrow value as immutable because it is also borrowed as mutable
|
||||
LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) => {
|
||||
| ---------^^^^^^^-----^
|
||||
| | |
|
||||
| | immutable borrow, by `b`, occurs here
|
||||
| mutable borrow, by `a`, occurs here
|
||||
| | value is borrowed by `b` here
|
||||
| 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:76:9
|
||||
@ -124,8 +124,8 @@ error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => {
|
||||
| -----^^^^^^---------^
|
||||
| | |
|
||||
| | mutable borrow, by `b`, occurs here
|
||||
| immutable borrow, by `a`, occurs here
|
||||
| | value is mutably borrowed by `b` here
|
||||
| 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:76:33
|
||||
@ -133,8 +133,8 @@ error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => {
|
||||
| -----^^^^^^^---------^
|
||||
| | |
|
||||
| | mutable borrow, by `b`, occurs here
|
||||
| immutable borrow, by `a`, occurs here
|
||||
| | value is mutably borrowed by `b` here
|
||||
| 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:87:9
|
||||
@ -142,8 +142,8 @@ error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false } => {}
|
||||
| -----^^^^^^---------^
|
||||
| | |
|
||||
| | mutable borrow, by `b`, occurs here
|
||||
| immutable borrow, by `a`, occurs here
|
||||
| | value is mutably borrowed by `b` here
|
||||
| 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:87:33
|
||||
@ -151,8 +151,8 @@ error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false } => {}
|
||||
| -----^^^^^^^---------^
|
||||
| | |
|
||||
| | mutable borrow, by `b`, occurs here
|
||||
| immutable borrow, by `a`, occurs here
|
||||
| | value is mutably borrowed by `b` here
|
||||
| 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
|
||||
@ -160,8 +160,8 @@ error: cannot borrow value as immutable because it is also borrowed as mutable
|
||||
LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); false } => {}
|
||||
| ---------^^^^^^-----^
|
||||
| | |
|
||||
| | immutable borrow, by `b`, occurs here
|
||||
| mutable borrow, by `a`, occurs here
|
||||
| | value is borrowed by `b` here
|
||||
| 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
|
||||
@ -169,8 +169,8 @@ error: cannot borrow value as immutable because it is also borrowed as mutable
|
||||
LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); false } => {}
|
||||
| ---------^^^^^^^-----^
|
||||
| | |
|
||||
| | immutable borrow, by `b`, occurs here
|
||||
| mutable borrow, by `a`, occurs here
|
||||
| | value is borrowed by `b` here
|
||||
| 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
|
||||
@ -178,8 +178,8 @@ error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {}
|
||||
| -----^^^^^^---------^
|
||||
| | |
|
||||
| | mutable borrow, by `b`, occurs here
|
||||
| immutable borrow, by `a`, occurs here
|
||||
| | value is mutably borrowed by `b` here
|
||||
| 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
|
||||
@ -187,8 +187,8 @@ error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {}
|
||||
| -----^^^^^^^---------^
|
||||
| | |
|
||||
| | mutable borrow, by `b`, occurs here
|
||||
| immutable borrow, by `a`, occurs here
|
||||
| | value is mutably borrowed by `b` here
|
||||
| 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
|
||||
@ -196,8 +196,8 @@ error: cannot borrow value as immutable because it is also borrowed as mutable
|
||||
LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false } => {}
|
||||
| ---------^^^^^^-----^
|
||||
| | |
|
||||
| | immutable borrow, by `b`, occurs here
|
||||
| mutable borrow, by `a`, occurs here
|
||||
| | value is borrowed by `b` here
|
||||
| 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
|
||||
@ -205,8 +205,8 @@ error: cannot borrow value as immutable because it is also borrowed as mutable
|
||||
LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false } => {}
|
||||
| ---------^^^^^^^-----^
|
||||
| | |
|
||||
| | immutable borrow, by `b`, occurs here
|
||||
| mutable borrow, by `a`, occurs here
|
||||
| | value is borrowed by `b` here
|
||||
| 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
|
||||
@ -214,9 +214,9 @@ error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
LL | let ref a @ (ref mut b, ref mut c) = (U, U);
|
||||
| -----^^^^---------^^---------^
|
||||
| | | |
|
||||
| | | mutable borrow, by `c`, occurs here
|
||||
| | mutable borrow, by `b`, occurs here
|
||||
| immutable borrow, by `a`, occurs here
|
||||
| | | value is mutably borrowed by `c` here
|
||||
| | value is mutably borrowed by `b` here
|
||||
| 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
|
||||
@ -224,9 +224,9 @@ error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
LL | let ref a @ (ref mut b, ref mut c) = (U, U);
|
||||
| -----^^^^---------^^---------^
|
||||
| | | |
|
||||
| | | mutable borrow, by `c`, occurs here
|
||||
| | mutable borrow, by `b`, occurs here
|
||||
| immutable borrow, by `a`, occurs here
|
||||
| | | value is mutably borrowed by `c` here
|
||||
| | value is mutably borrowed by `b` here
|
||||
| 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
|
||||
@ -234,9 +234,9 @@ error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
LL | let ref a @ (ref mut b, ref mut c) = (U, U);
|
||||
| -----^^^^---------^^---------^
|
||||
| | | |
|
||||
| | | mutable borrow, by `c`, occurs here
|
||||
| | mutable borrow, by `b`, occurs here
|
||||
| immutable borrow, by `a`, occurs here
|
||||
| | | value is mutably borrowed by `c` here
|
||||
| | value is mutably borrowed by `b` here
|
||||
| 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
|
||||
@ -244,9 +244,9 @@ error: cannot borrow value as immutable because it is also borrowed as mutable
|
||||
LL | let ref mut a @ (ref b, ref c) = (U, U);
|
||||
| ---------^^^^-----^^-----^
|
||||
| | | |
|
||||
| | | immutable borrow, by `c`, occurs here
|
||||
| | immutable borrow, by `b`, occurs here
|
||||
| mutable borrow, by `a`, occurs here
|
||||
| | | value is borrowed by `c` here
|
||||
| | value is borrowed by `b` here
|
||||
| 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:22:11
|
||||
@ -254,8 +254,8 @@ error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
LL | fn f1(ref a @ ref mut b: U) {}
|
||||
| -----^^^---------
|
||||
| | |
|
||||
| | mutable borrow, by `b`, occurs here
|
||||
| immutable borrow, by `a`, occurs here
|
||||
| | value is mutably borrowed by `b` here
|
||||
| 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:24:11
|
||||
@ -263,8 +263,8 @@ error: cannot borrow value as immutable because it is also borrowed as mutable
|
||||
LL | fn f2(ref mut a @ ref b: U) {}
|
||||
| ---------^^^-----
|
||||
| | |
|
||||
| | immutable borrow, by `b`, occurs here
|
||||
| mutable borrow, by `a`, occurs here
|
||||
| | value is borrowed by `b` here
|
||||
| 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:26:11
|
||||
@ -272,8 +272,8 @@ error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
LL | fn f3(ref a @ [ref b, ref mut mid @ .., ref c]: [U; 4]) {}
|
||||
| -----^^^^^^^^^^^----------------^^^^^^^^
|
||||
| | |
|
||||
| | mutable borrow, by `mid`, occurs here
|
||||
| immutable borrow, by `a`, occurs here
|
||||
| | value is mutably borrowed by `mid` here
|
||||
| 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:28:22
|
||||
@ -281,9 +281,9 @@ error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
LL | fn f4_also_moved(ref a @ ref mut b @ c: U) {}
|
||||
| -----^^^-------------
|
||||
| | | |
|
||||
| | | also moved into `c` here
|
||||
| | mutable borrow, by `b`, occurs here
|
||||
| immutable borrow, by `a`, occurs here
|
||||
| | | value is moved into `c` here
|
||||
| | value is mutably borrowed by `b` here
|
||||
| value is borrowed by `a` here
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:28:30
|
||||
@ -291,8 +291,8 @@ error: cannot move out of value because it is borrowed
|
||||
LL | fn f4_also_moved(ref a @ ref mut b @ c: U) {}
|
||||
| ---------^^^-
|
||||
| | |
|
||||
| | value moved into `c` here
|
||||
| value borrowed, by `b`, here
|
||||
| | value is moved into `c` here
|
||||
| value is mutably borrowed by `b` 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
|
||||
|
@ -4,8 +4,8 @@ error: cannot borrow value as mutable more than once at a time
|
||||
LL | let ref mut a @ ref mut b = U;
|
||||
| ---------^^^---------
|
||||
| | |
|
||||
| | another mutable borrow, by `b`, occurs here
|
||||
| first mutable borrow, by `a`, occurs here
|
||||
| | value is mutably borrowed by `b` here
|
||||
| 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:29:9
|
||||
@ -13,8 +13,8 @@ error: cannot borrow value as mutable more than once at a time
|
||||
LL | let ref mut a @ ref mut b = U;
|
||||
| ---------^^^---------
|
||||
| | |
|
||||
| | another mutable borrow, by `b`, occurs here
|
||||
| first mutable borrow, by `a`, occurs here
|
||||
| | value is mutably borrowed by `b` here
|
||||
| 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:33:9
|
||||
@ -22,8 +22,8 @@ error: cannot borrow value as mutable more than once at a time
|
||||
LL | let ref mut a @ ref mut b = U;
|
||||
| ---------^^^---------
|
||||
| | |
|
||||
| | another mutable borrow, by `b`, occurs here
|
||||
| first mutable borrow, by `a`, occurs here
|
||||
| | value is mutably borrowed by `b` here
|
||||
| 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:36:9
|
||||
@ -31,8 +31,8 @@ error: cannot borrow value as mutable more than once at a time
|
||||
LL | let ref mut a @ ref mut b = U;
|
||||
| ---------^^^---------
|
||||
| | |
|
||||
| | another mutable borrow, by `b`, occurs here
|
||||
| first mutable borrow, by `a`, occurs here
|
||||
| | value is mutably borrowed by `b` here
|
||||
| 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:39:9
|
||||
@ -40,8 +40,8 @@ error: cannot borrow value as mutable more than once at a time
|
||||
LL | let ref mut a @ ref mut b = U;
|
||||
| ---------^^^---------
|
||||
| | |
|
||||
| | another mutable borrow, by `b`, occurs here
|
||||
| first mutable borrow, by `a`, occurs here
|
||||
| | value is mutably borrowed by `b` here
|
||||
| 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:44:9
|
||||
@ -49,18 +49,18 @@ error: cannot borrow value as mutable more than once at a time
|
||||
LL | let ref mut a @ (
|
||||
| ^--------
|
||||
| |
|
||||
| _________first mutable borrow, by `a`, occurs here
|
||||
| _________value is mutably borrowed by `a` here
|
||||
| |
|
||||
LL | |
|
||||
LL | | ref mut b,
|
||||
| | --------- another mutable borrow, by `b`, occurs here
|
||||
| | --------- value is mutably borrowed by `b` here
|
||||
LL | | [
|
||||
LL | | ref mut c,
|
||||
| | --------- another mutable borrow, by `c`, occurs here
|
||||
| | --------- value is mutably borrowed by `c` here
|
||||
LL | | ref mut d,
|
||||
| | --------- another mutable borrow, by `d`, occurs here
|
||||
| | --------- value is mutably borrowed by `d` here
|
||||
LL | | ref e,
|
||||
| | ----- also borrowed as immutable, by `e`, here
|
||||
| | ----- value is borrowed by `e` here
|
||||
LL | | ]
|
||||
LL | | ) = (U, [U, U, U]);
|
||||
| |_____^
|
||||
@ -71,18 +71,18 @@ error: cannot borrow value as mutable more than once at a time
|
||||
LL | let ref mut a @ (
|
||||
| ^--------
|
||||
| |
|
||||
| _________first mutable borrow, by `a`, occurs here
|
||||
| _________value is mutably borrowed by `a` here
|
||||
| |
|
||||
LL | |
|
||||
LL | | ref mut b,
|
||||
| | --------- another mutable borrow, by `b`, occurs here
|
||||
| | --------- value is mutably borrowed by `b` here
|
||||
LL | | [
|
||||
LL | | ref mut c,
|
||||
| | --------- another mutable borrow, by `c`, occurs here
|
||||
| | --------- value is mutably borrowed by `c` here
|
||||
LL | | ref mut d,
|
||||
| | --------- another mutable borrow, by `d`, occurs here
|
||||
| | --------- value is mutably borrowed by `d` here
|
||||
LL | | ref e,
|
||||
| | ----- also borrowed as immutable, by `e`, here
|
||||
| | ----- value is borrowed by `e` here
|
||||
LL | | ]
|
||||
LL | | ) = (u(), [u(), u(), u()]);
|
||||
| |_________^
|
||||
@ -157,8 +157,8 @@ error: cannot borrow value as mutable more than once at a time
|
||||
LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
|
||||
| ---------^^^^^^---------^
|
||||
| | |
|
||||
| | another mutable borrow, by `b`, occurs here
|
||||
| first mutable borrow, by `a`, occurs here
|
||||
| | value is mutably borrowed by `b` here
|
||||
| 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:76:37
|
||||
@ -166,8 +166,8 @@ error: cannot borrow value as mutable more than once at a time
|
||||
LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
|
||||
| ---------^^^^^^^---------^
|
||||
| | |
|
||||
| | another mutable borrow, by `b`, occurs here
|
||||
| first mutable borrow, by `a`, occurs here
|
||||
| | value is mutably borrowed by `b` here
|
||||
| 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:82:9
|
||||
@ -175,8 +175,8 @@ error: cannot borrow value as mutable more than once at a time
|
||||
LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
|
||||
| ---------^^^^^^---------^
|
||||
| | |
|
||||
| | another mutable borrow, by `b`, occurs here
|
||||
| first mutable borrow, by `a`, occurs here
|
||||
| | value is mutably borrowed by `b` here
|
||||
| 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:82:37
|
||||
@ -184,8 +184,8 @@ error: cannot borrow value as mutable more than once at a time
|
||||
LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
|
||||
| ---------^^^^^^^---------^
|
||||
| | |
|
||||
| | another mutable borrow, by `b`, occurs here
|
||||
| first mutable borrow, by `a`, occurs here
|
||||
| | value is mutably borrowed by `b` here
|
||||
| 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
|
||||
@ -193,8 +193,8 @@ error: cannot borrow value as mutable more than once at a time
|
||||
LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
|
||||
| ---------^^^^^^---------^
|
||||
| | |
|
||||
| | another mutable borrow, by `b`, occurs here
|
||||
| first mutable borrow, by `a`, occurs here
|
||||
| | value is mutably borrowed by `b` here
|
||||
| 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
|
||||
@ -202,8 +202,8 @@ error: cannot borrow value as mutable more than once at a time
|
||||
LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
|
||||
| ---------^^^^^^^---------^
|
||||
| | |
|
||||
| | another mutable borrow, by `b`, occurs here
|
||||
| first mutable borrow, by `a`, occurs here
|
||||
| | value is mutably borrowed by `b` here
|
||||
| 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:101:9
|
||||
@ -211,8 +211,8 @@ error: cannot borrow value as mutable more than once at a time
|
||||
LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
|
||||
| ---------^^^^^^---------^
|
||||
| | |
|
||||
| | another mutable borrow, by `b`, occurs here
|
||||
| first mutable borrow, by `a`, occurs here
|
||||
| | value is mutably borrowed by `b` here
|
||||
| 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:101:37
|
||||
@ -220,8 +220,8 @@ error: cannot borrow value as mutable more than once at a time
|
||||
LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
|
||||
| ---------^^^^^^^---------^
|
||||
| | |
|
||||
| | another mutable borrow, by `b`, occurs here
|
||||
| first mutable borrow, by `a`, occurs here
|
||||
| | value is mutably borrowed by `b` here
|
||||
| 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:8:11
|
||||
@ -229,8 +229,8 @@ error: cannot borrow value as mutable more than once at a time
|
||||
LL | fn f1(ref mut a @ ref mut b: U) {}
|
||||
| ---------^^^---------
|
||||
| | |
|
||||
| | another mutable borrow, by `b`, occurs here
|
||||
| first mutable borrow, by `a`, occurs here
|
||||
| | value is mutably borrowed by `b` here
|
||||
| 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:10:11
|
||||
@ -238,8 +238,8 @@ error: cannot borrow value as mutable more than once at a time
|
||||
LL | fn f2(ref mut a @ ref mut b: U) {}
|
||||
| ---------^^^---------
|
||||
| | |
|
||||
| | another mutable borrow, by `b`, occurs here
|
||||
| first mutable borrow, by `a`, occurs here
|
||||
| | value is mutably borrowed by `b` here
|
||||
| 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:13:9
|
||||
@ -247,13 +247,13 @@ error: cannot borrow value as mutable more than once at a time
|
||||
LL | ref mut a @ [
|
||||
| ^--------
|
||||
| |
|
||||
| _________first mutable borrow, by `a`, occurs here
|
||||
| _________value is mutably borrowed by `a` here
|
||||
| |
|
||||
LL | |
|
||||
LL | | [ref b @ .., _],
|
||||
| | ---------- also borrowed as immutable, by `b`, here
|
||||
| | ---------- value is borrowed by `b` here
|
||||
LL | | [_, ref mut mid @ ..],
|
||||
| | ---------------- another mutable borrow, by `mid`, occurs here
|
||||
| | ---------------- value is mutably borrowed by `mid` here
|
||||
LL | | ..,
|
||||
LL | | [..],
|
||||
LL | | ] : [[U; 4]; 5]
|
||||
@ -265,9 +265,9 @@ error: cannot borrow value as mutable more than once at a time
|
||||
LL | fn f4_also_moved(ref mut a @ ref mut b @ c: U) {}
|
||||
| ---------^^^-------------
|
||||
| | | |
|
||||
| | | also moved into `c` here
|
||||
| | another mutable borrow, by `b`, occurs here
|
||||
| first mutable borrow, by `a`, occurs here
|
||||
| | | value is moved into `c` here
|
||||
| | value is mutably borrowed by `b` here
|
||||
| value is mutably borrowed by `a` here
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:21:34
|
||||
@ -275,8 +275,8 @@ error: cannot move out of value because it is borrowed
|
||||
LL | fn f4_also_moved(ref mut a @ ref mut b @ c: U) {}
|
||||
| ---------^^^-
|
||||
| | |
|
||||
| | value moved into `c` here
|
||||
| value borrowed, by `b`, here
|
||||
| | value is moved into `c` here
|
||||
| value is mutably borrowed by `b` here
|
||||
|
||||
error[E0499]: cannot borrow value as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:29:9
|
||||
|
@ -4,8 +4,8 @@ error: cannot move out of value because it is borrowed
|
||||
LL | let ref a @ b = NotCopy;
|
||||
| -----^^^-
|
||||
| | |
|
||||
| | value moved into `b` here
|
||||
| value borrowed, by `a`, here
|
||||
| | value is moved into `b` here
|
||||
| value is borrowed by `a` here
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/default-binding-modes-both-sides-independent.rs:29:9
|
||||
@ -13,8 +13,8 @@ error: cannot move out of value because it is borrowed
|
||||
LL | let ref mut a @ b = NotCopy;
|
||||
| ---------^^^-
|
||||
| | |
|
||||
| | value moved into `b` here
|
||||
| value borrowed, by `a`, here
|
||||
| | value is moved into `b` here
|
||||
| value is mutably borrowed by `a` here
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/default-binding-modes-both-sides-independent.rs:34:12
|
||||
@ -22,8 +22,8 @@ error: cannot move out of value because it is borrowed
|
||||
LL | Ok(ref a @ b) | Err(b @ ref a) => {
|
||||
| -----^^^-
|
||||
| | |
|
||||
| | value moved into `b` here
|
||||
| value borrowed, by `a`, here
|
||||
| | value is moved into `b` here
|
||||
| value is borrowed by `a` here
|
||||
|
||||
error: borrow of moved value
|
||||
--> $DIR/default-binding-modes-both-sides-independent.rs:34:29
|
||||
@ -46,8 +46,8 @@ error: cannot move out of value because it is borrowed
|
||||
LL | ref a @ b => {
|
||||
| -----^^^-
|
||||
| | |
|
||||
| | value moved into `b` here
|
||||
| value borrowed, by `a`, here
|
||||
| | value is moved into `b` here
|
||||
| value is borrowed by `a` here
|
||||
|
||||
error[E0382]: borrow of moved value
|
||||
--> $DIR/default-binding-modes-both-sides-independent.rs:29:9
|
||||
|
@ -19,8 +19,8 @@ error: cannot move out of value because it is borrowed
|
||||
LL | let ref _moved @ _from = String::from("foo");
|
||||
| ----------^^^-----
|
||||
| | |
|
||||
| | value moved into `_from` here
|
||||
| value borrowed, by `_moved`, here
|
||||
| | value is moved into `_from` here
|
||||
| value is borrowed by `_moved` here
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/ref-pattern-binding.rs:15:9
|
||||
@ -28,8 +28,8 @@ error: cannot move out of value because it is borrowed
|
||||
LL | let ref _moved @ S { f } = S { f: String::from("foo") };
|
||||
| ----------^^^^^^^-^^
|
||||
| | |
|
||||
| | value moved into `f` here
|
||||
| value borrowed, by `_moved`, here
|
||||
| | value is moved into `f` here
|
||||
| value is borrowed by `_moved` here
|
||||
|
||||
error: borrow of moved value
|
||||
--> $DIR/ref-pattern-binding.rs:18:9
|
||||
|
Loading…
Reference in New Issue
Block a user