Rollup merge of #103908 - estebank:consider-cloning, r=compiler-errors

Suggest `.clone()` or `ref binding` on E0382
This commit is contained in:
Matthias Krüger 2022-11-24 08:42:33 +01:00 committed by GitHub
commit 5197ef66b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
92 changed files with 1407 additions and 78 deletions

View File

@ -1376,7 +1376,7 @@ pub enum ExprKind {
/// Conditionless loop (can be exited with `break`, `continue`, or `return`).
///
/// `'label: loop { block }`
Loop(P<Block>, Option<Label>),
Loop(P<Block>, Option<Label>, Span),
/// A `match` block.
Match(P<Expr>, Vec<Arm>),
/// A closure (e.g., `move |a, b, c| a + b + c`).

View File

@ -1355,9 +1355,10 @@ pub fn noop_visit_expr<T: MutVisitor>(
vis.visit_block(body);
visit_opt(label, |label| vis.visit_label(label));
}
ExprKind::Loop(body, label) => {
ExprKind::Loop(body, label, span) => {
vis.visit_block(body);
visit_opt(label, |label| vis.visit_label(label));
vis.visit_span(span);
}
ExprKind::Match(expr, arms) => {
vis.visit_expr(expr);

View File

@ -824,7 +824,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) {
visitor.visit_expr(subexpression);
visitor.visit_block(block);
}
ExprKind::Loop(block, opt_label) => {
ExprKind::Loop(block, opt_label, _) => {
walk_list!(visitor, visit_label, opt_label);
visitor.visit_block(block);
}

View File

@ -131,12 +131,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
let span = this.mark_span_with_reason(DesugaringKind::WhileLoop, e.span, None);
this.lower_expr_while_in_loop_scope(span, cond, body, *opt_label)
}),
ExprKind::Loop(body, opt_label) => self.with_loop_scope(e.id, |this| {
ExprKind::Loop(body, opt_label, span) => self.with_loop_scope(e.id, |this| {
hir::ExprKind::Loop(
this.lower_block(body, false),
this.lower_label(*opt_label),
hir::LoopSource::Loop,
DUMMY_SP,
this.lower_span(*span),
)
}),
ExprKind::TryBlock(body) => self.lower_expr_try_block(body),

View File

@ -377,7 +377,7 @@ impl<'a> State<'a> {
self.space();
self.print_block_with_attrs(blk, attrs);
}
ast::ExprKind::Loop(ref blk, opt_label) => {
ast::ExprKind::Loop(ref blk, opt_label, _) => {
if let Some(label) = opt_label {
self.print_ident(label.ident);
self.word_space(":");

View File

@ -167,10 +167,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
);
}
self.add_moved_or_invoked_closure_note(location, used_place, &mut err);
let closure = self.add_moved_or_invoked_closure_note(location, used_place, &mut err);
let mut is_loop_move = false;
let mut in_pattern = false;
let mut seen_spans = FxHashSet::default();
for move_site in &move_site_vec {
let move_out = self.move_data.moves[(*move_site).moi];
@ -191,37 +192,25 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
is_loop_move = true;
}
self.explain_captures(
&mut err,
span,
move_span,
move_spans,
*moved_place,
partially_str,
loop_message,
move_msg,
is_loop_move,
maybe_reinitialized_locations.is_empty(),
);
if let (UseSpans::PatUse(span), []) =
(move_spans, &maybe_reinitialized_locations[..])
{
if maybe_reinitialized_locations.is_empty() {
err.span_suggestion_verbose(
span.shrink_to_lo(),
&format!(
"borrow this field in the pattern to avoid moving {}",
self.describe_place(moved_place.as_ref())
.map(|n| format!("`{}`", n))
.unwrap_or_else(|| "the value".to_string())
),
"ref ",
Applicability::MachineApplicable,
);
in_pattern = true;
if !seen_spans.contains(&move_span) {
if !closure {
self.suggest_ref_or_clone(mpi, move_span, &mut err, &mut in_pattern);
}
self.explain_captures(
&mut err,
span,
move_span,
move_spans,
*moved_place,
partially_str,
loop_message,
move_msg,
is_loop_move,
maybe_reinitialized_locations.is_empty(),
);
}
seen_spans.insert(move_span);
}
use_spans.var_path_only_subdiag(&mut err, desired_action);
@ -317,6 +306,160 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
}
}
fn suggest_ref_or_clone(
&mut self,
mpi: MovePathIndex,
move_span: Span,
err: &mut DiagnosticBuilder<'_, ErrorGuaranteed>,
in_pattern: &mut bool,
) {
struct ExpressionFinder<'hir> {
expr_span: Span,
expr: Option<&'hir hir::Expr<'hir>>,
pat: Option<&'hir hir::Pat<'hir>>,
parent_pat: Option<&'hir hir::Pat<'hir>>,
}
impl<'hir> Visitor<'hir> for ExpressionFinder<'hir> {
fn visit_expr(&mut self, e: &'hir hir::Expr<'hir>) {
if e.span == self.expr_span {
self.expr = Some(e);
}
hir::intravisit::walk_expr(self, e);
}
fn visit_pat(&mut self, p: &'hir hir::Pat<'hir>) {
if p.span == self.expr_span {
self.pat = Some(p);
}
if let hir::PatKind::Binding(hir::BindingAnnotation::NONE, _, i, sub) = p.kind {
if i.span == self.expr_span || p.span == self.expr_span {
self.pat = Some(p);
}
// Check if we are in a situation of `ident @ ident` where we want to suggest
// `ref ident @ ref ident` or `ref ident @ Struct { ref ident }`.
if let Some(subpat) = sub && self.pat.is_none() {
self.visit_pat(subpat);
if self.pat.is_some() {
self.parent_pat = Some(p);
}
return;
}
}
hir::intravisit::walk_pat(self, p);
}
}
let hir = self.infcx.tcx.hir();
if let Some(hir::Node::Item(hir::Item {
kind: hir::ItemKind::Fn(_, _, body_id),
..
})) = hir.find(hir.local_def_id_to_hir_id(self.mir_def_id()))
&& let Some(hir::Node::Expr(expr)) = hir.find(body_id.hir_id)
{
let place = &self.move_data.move_paths[mpi].place;
let span = place.as_local()
.map(|local| self.body.local_decls[local].source_info.span);
let mut finder = ExpressionFinder {
expr_span: move_span,
expr: None,
pat: None,
parent_pat: None,
};
finder.visit_expr(expr);
if let Some(span) = span && let Some(expr) = finder.expr {
for (_, expr) in hir.parent_iter(expr.hir_id) {
if let hir::Node::Expr(expr) = expr {
if expr.span.contains(span) {
// If the let binding occurs within the same loop, then that
// loop isn't relevant, like in the following, the outermost `loop`
// doesn't play into `x` being moved.
// ```
// loop {
// let x = String::new();
// loop {
// foo(x);
// }
// }
// ```
break;
}
if let hir::ExprKind::Loop(.., loop_span) = expr.kind {
err.span_label(loop_span, "inside of this loop");
}
}
}
let typeck = self.infcx.tcx.typeck(self.mir_def_id());
let hir_id = hir.get_parent_node(expr.hir_id);
if let Some(parent) = hir.find(hir_id) {
let (def_id, args, offset) = if let hir::Node::Expr(parent_expr) = parent
&& let hir::ExprKind::MethodCall(_, _, args, _) = parent_expr.kind
&& let Some(def_id) = typeck.type_dependent_def_id(parent_expr.hir_id)
{
(def_id.as_local(), args, 1)
} else if let hir::Node::Expr(parent_expr) = parent
&& let hir::ExprKind::Call(call, args) = parent_expr.kind
&& let ty::FnDef(def_id, _) = typeck.node_type(call.hir_id).kind()
{
(def_id.as_local(), args, 0)
} else {
(None, &[][..], 0)
};
if let Some(def_id) = def_id
&& let Some(node) = hir.find(hir.local_def_id_to_hir_id(def_id))
&& let Some(fn_sig) = node.fn_sig()
&& let Some(ident) = node.ident()
&& let Some(pos) = args.iter().position(|arg| arg.hir_id == expr.hir_id)
&& let Some(arg) = fn_sig.decl.inputs.get(pos + offset)
{
let mut span: MultiSpan = arg.span.into();
span.push_span_label(
arg.span,
"this parameter takes ownership of the value".to_string(),
);
let descr = match node.fn_kind() {
Some(hir::intravisit::FnKind::ItemFn(..)) | None => "function",
Some(hir::intravisit::FnKind::Method(..)) => "method",
Some(hir::intravisit::FnKind::Closure) => "closure",
};
span.push_span_label(
ident.span,
format!("in this {descr}"),
);
err.span_note(
span,
format!(
"consider changing this parameter type in {descr} `{ident}` to \
borrow instead if owning the value isn't necessary",
),
);
}
let place = &self.move_data.move_paths[mpi].place;
let ty = place.ty(self.body, self.infcx.tcx).ty;
if let hir::Node::Expr(parent_expr) = parent
&& let hir::ExprKind::Call(call_expr, _) = parent_expr.kind
&& let hir::ExprKind::Path(
hir::QPath::LangItem(LangItem::IntoIterIntoIter, _, _)
) = call_expr.kind
{
// Do not suggest `.clone()` in a `for` loop, we already suggest borrowing.
} else {
self.suggest_cloning(err, ty, move_span);
}
}
}
if let Some(pat) = finder.pat {
*in_pattern = true;
let mut sugg = vec![(pat.span.shrink_to_lo(), "ref ".to_string())];
if let Some(pat) = finder.parent_pat {
sugg.insert(0, (pat.span.shrink_to_lo(), "ref ".to_string()));
}
err.multipart_suggestion_verbose(
"borrow this binding in the pattern to avoid moving the value",
sugg,
Applicability::MachineApplicable,
);
}
}
}
fn report_use_of_uninitialized(
&self,
mpi: MovePathIndex,
@ -590,6 +733,27 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
true
}
fn suggest_cloning(&self, err: &mut Diagnostic, ty: Ty<'tcx>, span: Span) {
let tcx = self.infcx.tcx;
// Try to find predicates on *generic params* that would allow copying `ty`
let infcx = tcx.infer_ctxt().build();
if infcx
.type_implements_trait(
tcx.lang_items().clone_trait().unwrap(),
[tcx.erase_regions(ty)],
self.param_env,
)
.must_apply_modulo_regions()
{
err.span_suggestion_verbose(
span.shrink_to_hi(),
"consider cloning the value if the performance cost is acceptable",
".clone()".to_string(),
Applicability::MachineApplicable,
);
}
}
fn suggest_adding_copy_bounds(&self, err: &mut Diagnostic, ty: Ty<'tcx>, span: Span) {
let tcx = self.infcx.tcx;
let generics = tcx.generics_of(self.mir_def_id());

View File

@ -70,7 +70,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
location: Location,
place: PlaceRef<'tcx>,
diag: &mut Diagnostic,
) {
) -> bool {
debug!("add_moved_or_invoked_closure_note: location={:?} place={:?}", location, place);
let mut target = place.local_or_deref_local();
for stmt in &self.body[location.block].statements[location.statement_index..] {
@ -106,7 +106,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
{
place.local_or_deref_local().unwrap()
}
_ => return,
_ => return false,
};
debug!("add_moved_or_invoked_closure_note: closure={:?}", closure);
@ -125,7 +125,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
ty::place_to_string_for_capture(self.infcx.tcx, hir_place)
),
);
return;
return true;
}
}
}
@ -149,9 +149,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
ty::place_to_string_for_capture(self.infcx.tcx, hir_place)
),
);
return true;
}
}
}
false
}
/// End-user visible description of `place` if one can be found.

View File

@ -307,7 +307,7 @@ impl<'cx, 'a> Context<'cx, 'a> {
| ExprKind::InlineAsm(_)
| ExprKind::Let(_, _, _)
| ExprKind::Lit(_)
| ExprKind::Loop(_, _)
| ExprKind::Loop(_, _, _)
| ExprKind::MacCall(_)
| ExprKind::Match(_, _)
| ExprKind::Path(_, _)

View File

@ -1044,11 +1044,19 @@ fn check_borrow_conflicts_in_at_patterns(cx: &MatchVisitor<'_, '_, '_>, pat: &Pa
name,
typeck_results.node_type(pat.hir_id),
);
sess.struct_span_err(pat.span, "borrow of moved value")
.span_label(binding_span, format!("value moved into `{}` here", name))
let mut err = sess.struct_span_err(pat.span, "borrow of moved value");
err.span_label(binding_span, format!("value moved into `{}` here", name))
.span_label(binding_span, occurs_because)
.span_labels(conflicts_ref, "value borrowed here after move")
.emit();
.span_labels(conflicts_ref, "value borrowed here after move");
if pat.span.contains(binding_span) {
err.span_suggestion_verbose(
binding_span.shrink_to_lo(),
"borrow this binding in the pattern to avoid moving the value",
"ref ".to_string(),
Applicability::MachineApplicable,
);
}
err.emit();
}
return;
}

View File

@ -1734,7 +1734,7 @@ impl<'a> Parser<'a> {
expr.kind,
ExprKind::While(_, _, None)
| ExprKind::ForLoop(_, _, _, None)
| ExprKind::Loop(_, None)
| ExprKind::Loop(_, None, _)
| ExprKind::Block(_, None)
)
{
@ -2444,10 +2444,11 @@ impl<'a> Parser<'a> {
/// Parses `loop { ... }` (`loop` token already eaten).
fn parse_loop_expr(&mut self, opt_label: Option<Label>, lo: Span) -> PResult<'a, P<Expr>> {
let loop_span = self.prev_token.span;
let (attrs, body) = self.parse_inner_attrs_and_block()?;
Ok(self.mk_expr_with_attrs(
lo.to(self.prev_token.span),
ExprKind::Loop(body, opt_label),
ExprKind::Loop(body, opt_label, loop_span),
attrs,
))
}

View File

@ -3841,7 +3841,9 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
}
}
ExprKind::Loop(ref block, label) => self.resolve_labeled_block(label, expr.id, &block),
ExprKind::Loop(ref block, label, _) => {
self.resolve_labeled_block(label, expr.id, &block)
}
ExprKind::While(ref cond, ref block, label) => {
self.with_resolved_label(label, expr.id, |this| {

View File

@ -17,6 +17,10 @@ LL | match mm { (_, _y) => { } }
| ^^ value used here after partial move
|
= note: partial move occurs because `mm.0` has type `M`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | match mm { (ref _x, _) => { } }
| +++
error[E0382]: use of partially moved value: `mm`
--> $DIR/issue-53114-borrow-checks.rs:29:11
@ -28,6 +32,10 @@ LL | match mm { (_, _) => { } }
| ^^ value used here after partial move
|
= note: partial move occurs because `mm.1` has type `M`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | match mm { (_, ref _y) => { } }
| +++
error[E0382]: use of moved value: `m`
--> $DIR/issue-53114-borrow-checks.rs:36:16
@ -48,6 +56,10 @@ LL | if let (_, _y) = mm { }
| ^^ value used here after partial move
|
= note: partial move occurs because `mm.0` has type `M`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | if let (ref _x, _) = mm { }
| +++
error[E0382]: use of partially moved value: `mm`
--> $DIR/issue-53114-borrow-checks.rs:43:21
@ -59,6 +71,10 @@ LL | if let (_, _) = mm { }
| ^^ value used here after partial move
|
= note: partial move occurs because `mm.1` has type `M`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | if let (_, ref _y) = mm { }
| +++
error: aborting due to 6 previous errors

View File

@ -32,6 +32,10 @@ LL | +
LL | x.clone();
| ^^^^^^^^^ value borrowed here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | x.clone()
| ++++++++
help: consider further restricting this bound
|
LL | fn move_then_borrow<T: Add<Output=()> + Clone + Copy>(x: T) {

View File

@ -27,6 +27,11 @@ LL | a @ [.., _] => (),
...
LL | &x;
| ^^ value borrowed here after move
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | ref a @ [.., _] => (),
| +++
error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:28:5
@ -71,13 +76,15 @@ LL | fn bindings_after_at_or_patterns_move(x: Option<Test>) {
| - move occurs because `x` has type `Option<Test>`, which does not implement the `Copy` trait
LL | match x {
LL | foo @ Some(Test::Foo | Test::Bar) => (),
| ---
| |
| value moved here
| value moved here
| --- value moved here
...
LL | &x;
| ^^ value borrowed here after move
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | ref foo @ Some(Test::Foo | Test::Bar) => (),
| +++
error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:86:5
@ -122,13 +129,15 @@ LL | fn bindings_after_at_slice_patterns_or_patterns_moves(x: [Option<Test>; 4])
| - move occurs because `x` has type `[Option<Test>; 4]`, which does not implement the `Copy` trait
LL | match x {
LL | a @ [.., Some(Test::Foo | Test::Bar)] => (),
| -
| |
| value moved here
| value moved here
| - value moved here
...
LL | &x;
| ^^ value borrowed here after move
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | ref a @ [.., Some(Test::Foo | Test::Bar)] => (),
| +++
error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:144:5

View File

@ -7,6 +7,18 @@ LL | consume(b);
| - value moved here
LL | consume(b);
| ^ value used here after move
|
note: consider changing this parameter type in function `consume` to borrow instead if owning the value isn't necessary
--> $DIR/borrowck-consume-unsize-vec.rs:3:15
|
LL | fn consume(_: Box<[i32]>) {
| ------- ^^^^^^^^^^ this parameter takes ownership of the value
| |
| in this function
help: consider cloning the value if the performance cost is acceptable
|
LL | consume(b.clone());
| ++++++++
error: aborting due to previous error

View File

@ -7,6 +7,14 @@ LL | consume(b);
| - value moved here
LL | consume(b);
| ^ value used here after move
|
note: consider changing this parameter type in function `consume` to borrow instead if owning the value isn't necessary
--> $DIR/borrowck-consume-upcast-box.rs:5:15
|
LL | fn consume(_: Box<dyn Foo>) {
| ------- ^^^^^^^^^^^^ this parameter takes ownership of the value
| |
| in this function
error: aborting due to previous error

View File

@ -9,6 +9,11 @@ LL | Some(_) if { drop(my_str); false } => {}
LL | Some(_) => {}
LL | None => { foo(my_str); }
| ^^^^^^ value used here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | Some(_) if { drop(my_str.clone()); false } => {}
| ++++++++
error: aborting due to previous error

View File

@ -7,6 +7,11 @@ LL | let _y = {x} + x.clone(); // the `{x}` forces a move to occur
| - ^^^^^^^^^ value borrowed here after move
| |
| value moved here
|
help: consider cloning the value if the performance cost is acceptable
|
LL | let _y = {x.clone()} + x.clone(); // the `{x}` forces a move to occur
| ++++++++
error: aborting due to previous error

View File

@ -8,6 +8,10 @@ LL | [.., _y] => {}
| ^^ value used here after move
|
= note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [_, _, ref _x] => {}
| +++
error[E0382]: use of partially moved value: `a[..]`
--> $DIR/borrowck-move-out-from-array-match.rs:23:14
@ -19,6 +23,10 @@ LL | [.., _y] => {}
| ^^ value used here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [_, _, (ref _x, _)] => {}
| +++
error[E0382]: use of moved value: `a[..].0`
--> $DIR/borrowck-move-out-from-array-match.rs:33:15
@ -30,6 +38,10 @@ LL | [.., (_y, _)] => {}
| ^^ value used here after move
|
= note: move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [_, _, (ref _x, _)] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-match.rs:44:11
@ -41,6 +53,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [ref _x, _, _] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-match.rs:55:11
@ -52,6 +68,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [.., ref _x] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-match.rs:66:11
@ -63,6 +83,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [(ref _x, _), _, _] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-match.rs:77:11
@ -74,6 +98,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [.., (ref _x, _)] => {}
| +++
error[E0382]: use of moved value: `a[..].0`
--> $DIR/borrowck-move-out-from-array-match.rs:89:11
@ -85,6 +113,10 @@ LL | [(_x, _), _, _] => {}
| ^^ value used here after move
|
= note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [ref _y @ .., _, _] => {}
| +++
error[E0382]: use of moved value: `a[..].0`
--> $DIR/borrowck-move-out-from-array-match.rs:99:15
@ -96,6 +128,10 @@ LL | [.., (_x, _)] => {}
| ^^ value used here after move
|
= note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [_, _, ref _y @ ..] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-match.rs:110:11
@ -107,6 +143,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [ref x @ .., _] => {}
| +++
error: aborting due to 10 previous errors

View File

@ -8,6 +8,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [_, _, ref _x] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:28:11
@ -19,6 +23,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [_, _, (ref _x, _)] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:41:11
@ -30,6 +38,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [ref _x, _, _] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:52:11
@ -41,6 +53,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [.., ref _x] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:63:11
@ -52,6 +68,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [(ref _x, _), _, _] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:74:11
@ -63,6 +83,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [.., (ref _x, _)] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:85:11
@ -74,6 +98,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [_, ref _y @ ..] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:96:11
@ -85,6 +113,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [ref _y @ .., _] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:109:11
@ -96,6 +128,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [ref x @ .., _, _] => {}
| +++
error: aborting due to 9 previous errors

View File

@ -8,6 +8,10 @@ LL | [.., ref _y] => {}
| ^^^^^^ value borrowed here after move
|
= note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [_, _, ref _x] => {}
| +++
error[E0382]: borrow of partially moved value: `a[..]`
--> $DIR/borrowck-move-out-from-array-use-match.rs:23:14
@ -19,6 +23,10 @@ LL | [.., ref _y] => {}
| ^^^^^^ value borrowed here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [_, _, (ref _x, _)] => {}
| +++
error[E0382]: borrow of moved value: `a[..].0`
--> $DIR/borrowck-move-out-from-array-use-match.rs:33:15
@ -30,6 +38,10 @@ LL | [.., (ref _y, _)] => {}
| ^^^^^^ value borrowed here after move
|
= note: move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [_, _, (ref _x, _)] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-match.rs:44:11
@ -41,6 +53,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [ref _x, _, _] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-match.rs:55:11
@ -52,6 +68,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [.., ref _x] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-match.rs:66:11
@ -63,6 +83,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [(ref _x, _), _, _] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-match.rs:77:11
@ -74,6 +98,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [.., (ref _x, _)] => {}
| +++
error[E0382]: borrow of moved value: `a[..]`
--> $DIR/borrowck-move-out-from-array-use-match.rs:89:11
@ -85,6 +113,10 @@ LL | [(ref _x, _), _, _] => {}
| ^^^^^^ value borrowed here after move
|
= note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [ref _y @ .., _, _] => {}
| +++
error[E0382]: borrow of moved value: `a[..]`
--> $DIR/borrowck-move-out-from-array-use-match.rs:99:15
@ -96,6 +128,10 @@ LL | [.., (ref _x, _)] => {}
| ^^^^^^ value borrowed here after move
|
= note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [_, _, ref _y @ ..] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-match.rs:110:11
@ -107,6 +143,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [ref x @ .., _] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-match.rs:123:5
@ -118,6 +158,10 @@ LL | a[2] = Default::default();
| ^^^^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [_, _, ref _x] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-match.rs:131:5
@ -129,6 +173,10 @@ LL | a[2].1 = Default::default();
| ^^^^ value used here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [_, _, (ref _x, _)] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-match.rs:139:5
@ -140,6 +188,10 @@ LL | a[0] = Default::default();
| ^^^^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [_, _, ref _x @ ..] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-match.rs:147:5
@ -151,6 +203,10 @@ LL | a[0].1 = Default::default();
| ^^^^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [_, _, ref _x @ ..] => {}
| +++
error: aborting due to 14 previous errors

View File

@ -8,6 +8,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [_, _, ref _x] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:28:11
@ -19,6 +23,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [_, _, (ref _x, _)] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:41:11
@ -30,6 +38,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [ref _x, _, _] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:52:11
@ -41,6 +53,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [.., ref _x] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:63:11
@ -52,6 +68,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [(ref _x, _), _, _] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:74:11
@ -63,6 +83,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [.., (ref _x, _)] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:85:11
@ -74,6 +98,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [_, ref _y @ ..] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:96:11
@ -85,6 +113,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [ref _y @ .., _] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:109:11
@ -96,6 +128,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [ref x @ .., _, _] => {}
| +++
error: aborting due to 9 previous errors

View File

@ -7,6 +7,10 @@ LL | let [.., ref _y] = a;
| ^^^^^^ value borrowed here after move
|
= note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [_, _, ref _x] = a;
| +++
error[E0382]: borrow of partially moved value: `a[..]`
--> $DIR/borrowck-move-out-from-array-use.rs:16:14
@ -17,6 +21,10 @@ LL | let [.., ref _y] = a;
| ^^^^^^ value borrowed here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [_, _, (ref _x, _)] = a;
| +++
error[E0382]: borrow of moved value: `a[..].0`
--> $DIR/borrowck-move-out-from-array-use.rs:22:15
@ -27,6 +35,10 @@ LL | let [.., (ref _y, _)] = a;
| ^^^^^^ value borrowed here after move
|
= note: move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [_, _, (ref _x, _)] = a;
| +++
error[E0382]: borrow of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use.rs:30:10
@ -37,6 +49,10 @@ LL | let [ref _y @ .., _, _] = a;
| ^^^^^^ value borrowed here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [ref _x, _, _] = a;
| +++
error[E0382]: borrow of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use.rs:36:16
@ -47,6 +63,10 @@ LL | let [_, _, ref _y @ ..] = a;
| ^^^^^^ value borrowed here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [.., ref _x] = a;
| +++
error[E0382]: borrow of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use.rs:42:10
@ -57,6 +77,10 @@ LL | let [ref _y @ .., _, _] = a;
| ^^^^^^ value borrowed here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [(ref _x, _), _, _] = a;
| +++
error[E0382]: borrow of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use.rs:48:16
@ -67,6 +91,10 @@ LL | let [_, _, ref _y @ ..] = a;
| ^^^^^^ value borrowed here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [.., (ref _x, _)] = a;
| +++
error[E0382]: borrow of moved value: `a[..]`
--> $DIR/borrowck-move-out-from-array-use.rs:54:11
@ -77,6 +105,10 @@ LL | let [(ref _x, _), _, _] = a;
| ^^^^^^ value borrowed here after move
|
= note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [ref _y @ .., _, _] = a;
| +++
error[E0382]: borrow of moved value: `a[..]`
--> $DIR/borrowck-move-out-from-array-use.rs:60:15
@ -87,6 +119,10 @@ LL | let [.., (ref _x, _)] = a;
| ^^^^^^ value borrowed here after move
|
= note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [_, _, ref _y @ ..] = a;
| +++
error[E0382]: borrow of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use.rs:68:13
@ -97,6 +133,10 @@ LL | let [_, ref _y @ ..] = a;
| ^^^^^^ value borrowed here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [ref x @ .., _] = a;
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use.rs:76:5
@ -107,6 +147,10 @@ LL | a[2] = Default::default();
| ^^^^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [_, _, ref _x] = a;
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use.rs:82:5
@ -117,6 +161,10 @@ LL | a[2].1 = Default::default();
| ^^^^ value used here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [_, _, (ref _x, _)] = a;
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use.rs:88:5
@ -127,6 +175,10 @@ LL | a[0] = Default::default();
| ^^^^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [_, _, ref _x @ ..] = a;
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use.rs:94:5
@ -137,6 +189,10 @@ LL | a[0].1 = Default::default();
| ^^^^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [_, _, ref _x @ ..] = a;
| +++
error: aborting due to 14 previous errors

View File

@ -7,6 +7,10 @@ LL | let [.., _y] = a;
| ^^ value used here after move
|
= note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [_, _, ref _x] = a;
| +++
error[E0382]: use of partially moved value: `a[..]`
--> $DIR/borrowck-move-out-from-array.rs:16:14
@ -17,6 +21,10 @@ LL | let [.., _y] = a;
| ^^ value used here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [_, _, (ref _x, _)] = a;
| +++
error[E0382]: use of moved value: `a[..].0`
--> $DIR/borrowck-move-out-from-array.rs:22:15
@ -27,6 +35,10 @@ LL | let [.., (_y, _)] = a;
| ^^ value used here after move
|
= note: move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [_, _, (ref _x, _)] = a;
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array.rs:30:10
@ -37,6 +49,10 @@ LL | let [_y @ .., _, _] = a;
| ^^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [ref _x, _, _] = a;
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array.rs:36:16
@ -47,6 +63,10 @@ LL | let [_, _, _y @ ..] = a;
| ^^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [.., ref _x] = a;
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array.rs:42:10
@ -57,6 +77,10 @@ LL | let [_y @ .., _, _] = a;
| ^^ value used here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [(ref _x, _), _, _] = a;
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array.rs:48:16
@ -67,6 +91,10 @@ LL | let [_, _, _y @ ..] = a;
| ^^ value used here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [.., (ref _x, _)] = a;
| +++
error[E0382]: use of moved value: `a[..].0`
--> $DIR/borrowck-move-out-from-array.rs:54:11
@ -77,6 +105,10 @@ LL | let [(_x, _), _, _] = a;
| ^^ value used here after move
|
= note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [ref _y @ .., _, _] = a;
| +++
error[E0382]: use of moved value: `a[..].0`
--> $DIR/borrowck-move-out-from-array.rs:60:15
@ -87,6 +119,10 @@ LL | let [.., (_x, _)] = a;
| ^^ value used here after move
|
= note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [_, _, ref _y @ ..] = a;
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array.rs:68:13
@ -97,6 +133,10 @@ LL | let [_, _y @ ..] = a;
| ^^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [ref x @ .., _] = a;
| +++
error: aborting due to 10 previous errors

View File

@ -40,6 +40,11 @@ LL | thread::spawn(move|| {
...
LL | drop(x1);
| -- use occurs due to use in closure
|
help: consider cloning the value if the performance cost is acceptable
|
LL | drop(x1.clone());
| ++++++++
error[E0382]: use of moved value: `x2`
--> $DIR/borrowck-multiple-captures.rs:27:19
@ -53,6 +58,11 @@ LL | thread::spawn(move|| {
...
LL | drop(x2);
| -- use occurs due to use in closure
|
help: consider cloning the value if the performance cost is acceptable
|
LL | drop(x2.clone());
| ++++++++
error[E0382]: use of moved value: `x`
--> $DIR/borrowck-multiple-captures.rs:41:14
@ -100,6 +110,11 @@ LL | thread::spawn(move|| {
LL |
LL | drop(x);
| - use occurs due to use in closure
|
help: consider cloning the value if the performance cost is acceptable
|
LL | drop(x.clone());
| ++++++++
error: aborting due to 8 previous errors

View File

@ -33,6 +33,11 @@ LL | println!("{}", f[s]);
...
LL | f[s] = 10;
| ^ value used here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | println!("{}", f[s.clone()]);
| ++++++++
error: aborting due to 3 previous errors

View File

@ -8,6 +8,11 @@ LL | drop(x);
| - value moved here
LL | let _ = (1,x);
| ^ value used here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | drop(x.clone());
| ++++++++
error: aborting due to previous error

View File

@ -8,6 +8,11 @@ LL | Some(_) if { drop(a); false } => None,
| - value moved here
LL | x => x,
| ^ value used here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | Some(_) if { drop(a.clone()); false } => None,
| ++++++++
error: aborting due to previous error

View File

@ -5,7 +5,7 @@ LL | if let Some(thing) = maybe {
| ^^^^^ value moved here, in previous iteration of loop
|
= note: move occurs because value has type `Vec<bool>`, which does not implement the `Copy` trait
help: borrow this field in the pattern to avoid moving `maybe.0`
help: borrow this binding in the pattern to avoid moving the value
|
LL | if let Some(ref thing) = maybe {
| +++

View File

@ -8,6 +8,10 @@ LL | val = None;
| ---------- this reinitialization might get skipped
|
= note: move occurs because value has type `Struct`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | while let Some(ref foo) = val {
| +++
error[E0382]: use of moved value: `foo`
--> $DIR/issue-83760.rs:21:14

View File

@ -5,7 +5,7 @@ LL | if let Some(mut _x) = opt {}
| ^^^^^^ value moved here, in previous iteration of loop
|
= note: move occurs because value has type `&mut i32`, which does not implement the `Copy` trait
help: borrow this field in the pattern to avoid moving `opt.0`
help: borrow this binding in the pattern to avoid moving the value
|
LL | if let Some(ref mut _x) = opt {}
| +++

View File

@ -8,7 +8,7 @@ LL | foo(s);
| ^ value used here after partial move
|
= note: partial move occurs because value has type `S`, which does not implement the `Copy` trait
help: borrow this field in the pattern to avoid moving `s.0`
help: borrow this binding in the pattern to avoid moving the value
|
LL | if let Some(ref mut x) = s {
| +++
@ -23,7 +23,7 @@ LL | bar(e);
| ^ value used here after partial move
|
= note: partial move occurs because value has type `S`, which does not implement the `Copy` trait
help: borrow this field in the pattern to avoid moving `e.s`
help: borrow this binding in the pattern to avoid moving the value
|
LL | let E::V { s: ref mut x } = e;
| +++

View File

@ -8,7 +8,7 @@ LL | foo(s);
| ^ value used here after partial move
|
= note: partial move occurs because value has type `S`, which does not implement the `Copy` trait
help: borrow this field in the pattern to avoid moving `s.0`
help: borrow this binding in the pattern to avoid moving the value
|
LL | if let Some(ref x) = s {
| +++
@ -23,7 +23,7 @@ LL | bar(e);
| ^ value used here after partial move
|
= note: partial move occurs because value has type `S`, which does not implement the `Copy` trait
help: borrow this field in the pattern to avoid moving `e.s`
help: borrow this binding in the pattern to avoid moving the value
|
LL | let E::V { s: ref x } = e;
| +++

View File

@ -4,9 +4,17 @@ error[E0382]: use of moved value: `value`
LL | fn this_does_not<'a, R>(value: &'a mut Events<R>) {
| ----- move occurs because `value` has type `&mut Events<R>`, which does not implement the `Copy` trait
LL | for _ in 0..3 {
| ------------- inside of this loop
LL | Other::handle(value);
| ^^^^^ value moved here, in previous iteration of loop
|
note: consider changing this parameter type in function `handle` to borrow instead if owning the value isn't necessary
--> $DIR/mut-borrow-in-loop-2.rs:9:22
|
LL | fn handle(value: T) -> Self;
| ------ ^ this parameter takes ownership of the value
| |
| in this function
help: consider creating a fresh reborrow of `value` here
|
LL | Other::handle(&mut *value);

View File

@ -8,6 +8,10 @@ LL | &x.0 .0;
| ^^^^^^^ value borrowed here after move
|
= note: move occurs because `x.0.0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | ((ref y, _) | (_, y),) => (),
| +++
error[E0382]: borrow of moved value: `x.0.1`
--> $DIR/or-patterns.rs:10:5
@ -19,6 +23,10 @@ LL | &x.0 .1;
| ^^^^^^^ value borrowed here after move
|
= note: move occurs because `x.0.1` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | ((y, _) | (_, ref y),) => (),
| +++
error[E0502]: cannot borrow `x.0.0` as mutable because it is also borrowed as immutable
--> $DIR/or-patterns.rs:18:5
@ -77,6 +85,10 @@ LL | &x.0 .0;
| ^^^^^^^ value borrowed here after move
|
= note: move occurs because `x.0.0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ((ref y, _) | (_, y),) = x;
| +++
error[E0382]: borrow of moved value: `x.0.1`
--> $DIR/or-patterns.rs:40:5
@ -88,6 +100,10 @@ LL | &x.0 .1;
| ^^^^^^^ value borrowed here after move
|
= note: move occurs because `x.0.1` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ((y, _) | (_, ref y),) = x;
| +++
error[E0502]: cannot borrow `x.0.0` as mutable because it is also borrowed as immutable
--> $DIR/or-patterns.rs:46:5

View File

@ -15,6 +15,10 @@ note: this function takes ownership of the receiver `self`, which moves `some_ve
LL | fn into_iter(self) -> Self::IntoIter;
| ^^^^
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider cloning the value if the performance cost is acceptable
|
LL | some_vec.clone().into_iter();
| ++++++++
error: aborting due to previous error

View File

@ -7,6 +7,11 @@ LL | let _bar = foo;
| --- value moved here
LL | let _baz = [foo; 0];
| ^^^ value used here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | let _bar = foo.clone();
| ++++++++
error[E0493]: destructor of `String` cannot be evaluated at compile-time
--> $DIR/repeat-drop-2.rs:7:25

View File

@ -9,6 +9,11 @@ LL | 0 if { drop(s); false } => String::from("oops"),
...
LL | s
| ^ value used here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | 0 if { drop(s.clone()); false } => String::from("oops"),
| ++++++++
error: aborting due to previous error

View File

@ -10,6 +10,10 @@ LL | println!("{}", s);
| ^ value borrowed here after move
|
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider cloning the value if the performance cost is acceptable
|
LL | let mut s_copy = s.clone();
| ++++++++
error: aborting due to previous error

View File

@ -3,9 +3,23 @@ error[E0382]: use of moved value: `x`
|
LL | let x: Box<isize> = Box::new(25);
| - move occurs because `x` has type `Box<isize>`, which does not implement the `Copy` trait
...
LL |
LL | loop {
| ---- inside of this loop
LL | take(x);
| ^ value moved here, in previous iteration of loop
|
note: consider changing this parameter type in function `take` to borrow instead if owning the value isn't necessary
--> $DIR/liveness-move-call-arg.rs:1:13
|
LL | fn take(_x: Box<isize>) {}
| ---- ^^^^^^^^^^ this parameter takes ownership of the value
| |
| in this function
help: consider cloning the value if the performance cost is acceptable
|
LL | take(x.clone());
| ++++++++
error: aborting due to previous error

View File

@ -4,8 +4,22 @@ error[E0382]: use of moved value: `y`
LL | let y: Box<isize> = 42.into();
| - move occurs because `y` has type `Box<isize>`, which does not implement the `Copy` trait
...
LL | loop {
| ---- inside of this loop
LL | println!("{}", y);
LL | loop {
| ---- inside of this loop
LL | loop {
| ---- inside of this loop
LL | loop {
| ---- inside of this loop
LL | x = y;
| ^ value moved here, in previous iteration of loop
|
help: consider cloning the value if the performance cost is acceptable
|
LL | x = y.clone();
| ++++++++
error: aborting due to previous error

View File

@ -24,12 +24,22 @@ error[E0382]: borrow of moved value: `y`
LL | let y: Box<isize> = 42.into();
| - move occurs because `y` has type `Box<isize>`, which does not implement the `Copy` trait
...
LL | loop {
| ---- inside of this loop
LL | println!("{}", y);
| ^ value borrowed here after move
LL | while true { while true { while true { x = y; x.clone(); } } }
| - value moved here, in previous iteration of loop
| ---------- ---------- ---------- - value moved here, in previous iteration of loop
| | | |
| | | inside of this loop
| | inside of this loop
| inside of this loop
|
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider cloning the value if the performance cost is acceptable
|
LL | while true { while true { while true { x = y.clone(); x.clone(); } } }
| ++++++++
error: aborting due to previous error; 3 warnings emitted

View File

@ -10,6 +10,10 @@ LL | println!("{}", *x);
| ^^ value borrowed here after move
|
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider cloning the value if the performance cost is acceptable
|
LL | let y = x.clone();
| ++++++++
error: aborting due to previous error

View File

@ -8,7 +8,16 @@ LL | send(ch, message);
LL | println!("{}", message);
| ^^^^^^^ value borrowed here after move
|
note: consider changing this parameter type in function `send` to borrow instead if owning the value isn't necessary
--> $DIR/liveness-use-after-send.rs:3:54
|
LL | fn send<T:Send + std::fmt::Debug>(ch: Chan<T>, data: T) {
| ---- in this function ^ this parameter takes ownership of the value
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider cloning the value if the performance cost is acceptable
|
LL | send(ch, message.clone());
| ++++++++
error: aborting due to previous error

View File

@ -4,9 +4,17 @@ error[E0382]: use of moved value: `f`
LL | fn takes_fn(f: impl Fn()) {
| - move occurs because `f` has type `impl Fn()`, which does not implement the `Copy` trait
LL | loop {
| ---- inside of this loop
LL | takes_fnonce(f);
| ^ value moved here, in previous iteration of loop
|
note: consider changing this parameter type in function `takes_fnonce` to borrow instead if owning the value isn't necessary
--> $DIR/borrow-closures-instead-of-move.rs:34:20
|
LL | fn takes_fnonce(_: impl FnOnce()) {}
| ------------ ^^^^^^^^^^^^^ this parameter takes ownership of the value
| |
| in this function
help: consider borrowing `f`
|
LL | takes_fnonce(&f);
@ -24,6 +32,13 @@ LL | takes_fnonce(m);
LL | takes_fnonce(m);
| ^ value used here after move
|
note: consider changing this parameter type in function `takes_fnonce` to borrow instead if owning the value isn't necessary
--> $DIR/borrow-closures-instead-of-move.rs:34:20
|
LL | fn takes_fnonce(_: impl FnOnce()) {}
| ------------ ^^^^^^^^^^^^^ this parameter takes ownership of the value
| |
| in this function
help: consider mutably borrowing `m`
|
LL | takes_fnonce(&mut m);

View File

@ -5,6 +5,11 @@ LL | let b = Box::new(true);
| - move occurs because `b` has type `Box<bool>`, which does not implement the `Copy` trait
LL | test!({b});
| ^ value used here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | test!({b.clone()});
| ++++++++
error: aborting due to previous error

View File

@ -25,7 +25,7 @@ fn moved_here_1() {
fn moved_here_2() {
let value = NonCopy{};
//~^ NOTE move occurs because `value` has type `NonCopy`, which does not implement the `Copy` trait
loop {
loop { //~ NOTE inside of this loop
let _used = value;
//~^ NOTE value moved here
loop {
@ -38,7 +38,7 @@ fn moved_here_2() {
fn moved_loop_1() {
let value = NonCopy{};
//~^ NOTE move occurs because `value` has type `NonCopy`, which does not implement the `Copy` trait
loop {
loop { //~ NOTE inside of this loop
let _used = value; //~ ERROR use of moved value: `value`
//~^ NOTE value moved here, in previous iteration of loop
}
@ -49,7 +49,7 @@ fn moved_loop_2() {
//~^ NOTE move occurs because `value` has type `NonCopy`, which does not implement the `Copy` trait
let _used = value;
value = NonCopy{};
loop {
loop { //~ NOTE inside of this loop
let _used2 = value; //~ ERROR use of moved value: `value`
//~^ NOTE value moved here, in previous iteration of loop
}

View File

@ -15,7 +15,9 @@ error[E0382]: use of moved value: `value`
|
LL | let value = NonCopy{};
| ----- move occurs because `value` has type `NonCopy`, which does not implement the `Copy` trait
...
LL |
LL | loop {
| ---- inside of this loop
LL | let _used = value;
| ----- value moved here
...
@ -27,7 +29,9 @@ error[E0382]: use of moved value: `value`
|
LL | let value = NonCopy{};
| ----- move occurs because `value` has type `NonCopy`, which does not implement the `Copy` trait
...
LL |
LL | loop {
| ---- inside of this loop
LL | let _used = value;
| ^^^^^ value moved here, in previous iteration of loop
@ -37,6 +41,8 @@ error[E0382]: use of moved value: `value`
LL | let mut value = NonCopy{};
| --------- move occurs because `value` has type `NonCopy`, which does not implement the `Copy` trait
...
LL | loop {
| ---- inside of this loop
LL | let _used2 = value;
| ^^^^^ value moved here, in previous iteration of loop

View File

@ -96,6 +96,10 @@ note: this function takes ownership of the receiver `self`, which moves `rc_foo`
|
LL | fn use_rc_self(self: Rc<Self>) {}
| ^^^^
help: consider cloning the value if the performance cost is acceptable
|
LL | rc_foo.clone().use_rc_self();
| ++++++++
error[E0382]: use of moved value: `foo_add`
--> $DIR/move-fn-self-receiver.rs:59:5
@ -137,6 +141,11 @@ LL | for _val in explicit_into_iter.into_iter() {}
| ----------- `explicit_into_iter` moved due to this method call
LL | explicit_into_iter;
| ^^^^^^^^^^^^^^^^^^ value used here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | for _val in explicit_into_iter.clone().into_iter() {}
| ++++++++
error[E0382]: use of moved value: `container`
--> $DIR/move-fn-self-receiver.rs:71:5
@ -160,6 +169,7 @@ error[E0382]: use of moved value: `foo2`
LL | let foo2 = Foo;
| ---- move occurs because `foo2` has type `Foo`, which does not implement the `Copy` trait
LL | loop {
| ---- inside of this loop
LL | foo2.use_self();
| ^^^^ ---------- `foo2` moved due to this method call, in previous iteration of loop

View File

@ -8,6 +8,18 @@ LL | (1, 2) if take(x) => (),
| - value moved here
LL | (1, 2) if take(x) => (),
| ^ value used here after move
|
note: consider changing this parameter type in function `take` to borrow instead if owning the value isn't necessary
--> $DIR/move-guard-same-consts.rs:25:15
|
LL | fn take<T>(_: T) -> bool { false }
| ---- ^ this parameter takes ownership of the value
| |
| in this function
help: consider cloning the value if the performance cost is acceptable
|
LL | (1, 2) if take(x.clone()) => (),
| ++++++++
error: aborting due to previous error

View File

@ -8,6 +8,18 @@ LL | (1, _) if take(x) => (),
| - value moved here
LL | (_, 2) if take(x) => (),
| ^ value used here after move
|
note: consider changing this parameter type in function `take` to borrow instead if owning the value isn't necessary
--> $DIR/move-in-guard-1.rs:15:15
|
LL | fn take<T>(_: T) -> bool { false }
| ---- ^ this parameter takes ownership of the value
| |
| in this function
help: consider cloning the value if the performance cost is acceptable
|
LL | (1, _) if take(x.clone()) => (),
| ++++++++
error: aborting due to previous error

View File

@ -6,6 +6,18 @@ LL | let x: Box<_> = Box::new(1);
...
LL | (_, 2) if take(x) => (),
| ^ value used here after move
|
note: consider changing this parameter type in function `take` to borrow instead if owning the value isn't necessary
--> $DIR/move-in-guard-2.rs:13:15
|
LL | fn take<T>(_: T) -> bool { false }
| ---- ^ this parameter takes ownership of the value
| |
| in this function
help: consider cloning the value if the performance cost is acceptable
|
LL | (_, 2) if take(x.clone()) => (),
| ++++++++
error: aborting due to previous error

View File

@ -13,6 +13,10 @@ note: this function takes ownership of the receiver `self`, which moves `x`
|
LL | fn into_iter(self) -> Self::IntoIter;
| ^^^^
help: consider cloning the value if the performance cost is acceptable
|
LL | consume(x.clone().into_iter().next().unwrap());
| ++++++++
error: aborting due to previous error

View File

@ -8,7 +8,7 @@ LL | consume(node) + r
| ^^^^ value used here after partial move
|
= note: partial move occurs because value has type `Box<List>`, which does not implement the `Copy` trait
help: borrow this field in the pattern to avoid moving `node.next.0`
help: borrow this binding in the pattern to avoid moving the value
|
LL | Some(ref right) => consume(right),
| +++

View File

@ -9,6 +9,11 @@ LL | let _y = Foo { f:x };
LL |
LL | touch(&x);
| ^^ value borrowed here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | let _y = Foo { f:x.clone() };
| ++++++++
error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-distribute-copy-over-paren.rs:21:11
@ -21,6 +26,11 @@ LL | let _y = Foo { f:(((x))) };
LL |
LL | touch(&x);
| ^^ value borrowed here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | let _y = Foo { f:(((x))).clone() };
| ++++++++
error: aborting due to 2 previous errors

View File

@ -7,6 +7,11 @@ LL | let _y = Foo { f:x };
| - value moved here
LL | touch(&x);
| ^^ value borrowed here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | let _y = Foo { f:x.clone() };
| ++++++++
error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:18:11
@ -17,6 +22,11 @@ LL | let _y = (x, 3);
| - value moved here
LL | touch(&x);
| ^^ value borrowed here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | let _y = (x.clone(), 3);
| ++++++++
error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:35:11
@ -29,6 +39,11 @@ LL | x
...
LL | touch(&x);
| ^^ value borrowed here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | x.clone()
| ++++++++
error[E0382]: borrow of moved value: `y`
--> $DIR/moves-based-on-type-exprs.rs:36:11
@ -41,6 +56,11 @@ LL | y
...
LL | touch(&y);
| ^^ value borrowed here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | y.clone()
| ++++++++
error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:46:11
@ -53,6 +73,11 @@ LL | true => x,
...
LL | touch(&x);
| ^^ value borrowed here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | true => x.clone(),
| ++++++++
error[E0382]: borrow of moved value: `y`
--> $DIR/moves-based-on-type-exprs.rs:47:11
@ -65,6 +90,11 @@ LL | false => y
...
LL | touch(&y);
| ^^ value borrowed here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | false => y.clone()
| ++++++++
error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:58:11
@ -77,6 +107,18 @@ LL | _ if guard(x) => 10,
...
LL | touch(&x);
| ^^ value borrowed here after move
|
note: consider changing this parameter type in function `guard` to borrow instead if owning the value isn't necessary
--> $DIR/moves-based-on-type-exprs.rs:6:14
|
LL | fn guard(_s: String) -> bool {panic!()}
| ----- ^^^^^^ this parameter takes ownership of the value
| |
| in this function
help: consider cloning the value if the performance cost is acceptable
|
LL | _ if guard(x.clone()) => 10,
| ++++++++
error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:65:11
@ -87,6 +129,11 @@ LL | let _y = [x];
| - value moved here
LL | touch(&x);
| ^^ value borrowed here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | let _y = [x.clone()];
| ++++++++
error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:71:11
@ -97,6 +144,11 @@ LL | let _y = vec![x];
| - value moved here
LL | touch(&x);
| ^^ value borrowed here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | let _y = vec![x.clone()];
| ++++++++
error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:77:11
@ -113,6 +165,10 @@ note: this function takes ownership of the receiver `self`, which moves `x`
|
LL | fn into_iter(self) -> Self::IntoIter;
| ^^^^
help: consider cloning the value if the performance cost is acceptable
|
LL | let _y = x.clone().into_iter().next().unwrap();
| ++++++++
error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:83:11
@ -129,6 +185,10 @@ note: this function takes ownership of the receiver `self`, which moves `x`
|
LL | fn into_iter(self) -> Self::IntoIter;
| ^^^^
help: consider cloning the value if the performance cost is acceptable
|
LL | let _y = [x.clone().into_iter().next().unwrap(); 1];
| ++++++++
error: aborting due to 11 previous errors

View File

@ -8,6 +8,10 @@ LL | touch(&x);
| ^^ value borrowed here after partial move
|
= note: partial move occurs because `x.f` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | Foo {ref f} => {}
| +++
error: aborting due to previous error

View File

@ -8,6 +8,11 @@ LL | Box::new((x, x))
| - ^ value used here after move
| |
| value moved here
|
help: consider cloning the value if the performance cost is acceptable
|
LL | Box::new((x.clone(), x))
| ++++++++
error: aborting due to previous error

View File

@ -7,6 +7,11 @@ LL | (t, t)
| - ^ value used here after move
| |
| value moved here
|
help: consider cloning the value if the performance cost is acceptable
|
LL | (t.clone(), t)
| ++++++++
error: aborting due to previous error

View File

@ -67,6 +67,11 @@ LL | || x.len();
| ^^ - borrow occurs due to use in closure
| |
| value borrowed here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | let r = x.clone();
| ++++++++
error[E0382]: borrow of moved value: `x`
--> $DIR/closure-access-spans.rs:40:5
@ -79,6 +84,11 @@ LL | || x = String::new();
| ^^ - borrow occurs due to use in closure
| |
| value borrowed here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | let r = x.clone();
| ++++++++
error[E0382]: borrow of moved value: `x`
--> $DIR/closure-access-spans.rs:45:5

View File

@ -37,6 +37,11 @@ LL | let mut t: T = (0, Box::new(0)); drop(t);
| move occurs because `t` has type `(u32, Box<u32>)`, which does not implement the `Copy` trait
LL | t.0 = 10; t.1 = Box::new(20);
| ^^^^^^^^ value partially assigned here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | let mut t: T = (0, Box::new(0)); drop(t.clone());
| ++++++++
error[E0381]: partially assigned binding `s` isn't fully initialized
--> $DIR/issue-21232-partial-init-and-use.rs:123:5
@ -77,6 +82,11 @@ LL | let mut t: T = (0, Box::new(0)); drop(t);
| move occurs because `t` has type `(u32, Box<u32>)`, which does not implement the `Copy` trait
LL | t.0 = 10;
| ^^^^^^^^ value partially assigned here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | let mut t: T = (0, Box::new(0)); drop(t.clone());
| ++++++++
error[E0381]: partially assigned binding `s` isn't fully initialized
--> $DIR/issue-21232-partial-init-and-use.rs:149:5
@ -208,6 +218,11 @@ LL | c2 => {
| -- value moved here
LL | c.0 = 2;
| ^^^^^^^ value partially assigned here after move
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | ref c2 => {
| +++
error[E0382]: assign to part of moved value: `c`
--> $DIR/issue-21232-partial-init-and-use.rs:255:13
@ -219,6 +234,11 @@ LL | c2 => {
| -- value moved here
LL | (c.1).0 = 2;
| ^^^^^^^^^^^ value partially assigned here after move
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | ref c2 => {
| +++
error[E0382]: assign to part of moved value: `c.1`
--> $DIR/issue-21232-partial-init-and-use.rs:263:13
@ -229,6 +249,10 @@ LL | ((c.1).1).0 = 3;
| ^^^^^^^^^^^^^^^ value partially assigned here after move
|
= note: move occurs because `c.1` has type `(i32, (i32, String))`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | ref c2 => {
| +++
error: aborting due to 23 previous errors

View File

@ -7,6 +7,11 @@ LL | let r = range;
| ----- value moved here
LL | let x = range.start;
| ^^^^^^^^^^^ value used here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | let r = range.clone();
| ++++++++
error: aborting due to previous error

View File

@ -5,7 +5,7 @@ LL | if let Some(thing) = maybe {
| ^^^^^ value moved here, in previous iteration of loop
|
= note: move occurs because value has type `Vec<bool>`, which does not implement the `Copy` trait
help: borrow this field in the pattern to avoid moving `maybe.0`
help: borrow this binding in the pattern to avoid moving the value
|
LL | if let Some(ref thing) = maybe {
| +++

View File

@ -26,6 +26,11 @@ LL | false if { drop(x); true } => 1,
LL | true => {
LL | x;
| ^ value used here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | false if { drop(x.clone()); true } => 1,
| ++++++++
error: aborting due to 2 previous errors

View File

@ -7,6 +7,11 @@ LL | let y = x;
| - value moved here
LL | x;
| ^ value used here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | let y = x.clone();
| ++++++++
error[E0382]: use of moved value: `x`
--> $DIR/ref-suggestion.rs:8:5
@ -17,6 +22,11 @@ LL | let mut y = x;
| - value moved here
LL | x;
| ^ value used here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | let mut y = x.clone();
| ++++++++
error[E0382]: use of partially moved value: `x`
--> $DIR/ref-suggestion.rs:16:5
@ -28,7 +38,7 @@ LL | x;
| ^ value used here after partial move
|
= note: partial move occurs because value has type `Vec<i32>`, which does not implement the `Copy` trait
help: borrow this field in the pattern to avoid moving `x.0.0`
help: borrow this binding in the pattern to avoid moving the value
|
LL | (Some(ref y), ()) => {},
| +++

View File

@ -16,6 +16,11 @@ LL | Some(_z @ ref _y) => {}
| | value borrowed here after move
| value moved into `_z` here
| move occurs because `_z` has type `X` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | Some(ref _z @ ref _y) => {}
| +++
error: cannot move out of value because it is borrowed
--> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:26:14
@ -35,6 +40,11 @@ LL | Some(_z @ ref mut _y) => {}
| | value borrowed here after move
| value moved into `_z` here
| move occurs because `_z` has type `X` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | Some(ref _z @ ref mut _y) => {}
| +++
error[E0382]: borrow of moved value
--> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:12:14
@ -45,7 +55,7 @@ LL | Some(ref _y @ _z) => {}
| value borrowed here after move
|
= note: move occurs because value has type `X`, which does not implement the `Copy` trait
help: borrow this field in the pattern to avoid moving `x.0`
help: borrow this binding in the pattern to avoid moving the value
|
LL | Some(ref _y @ ref _z) => {}
| +++
@ -59,7 +69,7 @@ LL | Some(ref mut _y @ _z) => {}
| value borrowed here after move
|
= note: move occurs because value has type `X`, which does not implement the `Copy` trait
help: borrow this field in the pattern to avoid moving `x.0`
help: borrow this binding in the pattern to avoid moving the value
|
LL | Some(ref mut _y @ ref _z) => {}
| +++

View File

@ -6,6 +6,11 @@ LL | let a @ b = U;
| | |
| | value moved here
| value used here after move
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref a @ ref b = U;
| +++ +++
error[E0382]: use of partially moved value
--> $DIR/borrowck-move-and-move.rs:13:9
@ -16,6 +21,10 @@ LL | let a @ (b, c) = (U, U);
| 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 | let ref a @ (b, ref c) = (U, U);
| +++ +++
error[E0382]: use of partially moved value
--> $DIR/borrowck-move-and-move.rs:15:9
@ -26,6 +35,10 @@ LL | let a @ (b, c) = (u(), u());
| 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 | let ref a @ (b, ref c) = (u(), u());
| +++ +++
error[E0382]: use of moved value
--> $DIR/borrowck-move-and-move.rs:18:16
@ -36,6 +49,11 @@ LL | a @ Ok(b) | a @ Err(b) => {}
| - ^ value used here after move
| |
| value moved here
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | ref a @ Ok(b) | a @ Err(b) => {}
| +++
error[E0382]: use of moved value
--> $DIR/borrowck-move-and-move.rs:18:29
@ -46,6 +64,11 @@ LL | a @ Ok(b) | a @ Err(b) => {}
| - ^ value used here after move
| |
| value moved here
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | a @ Ok(b) | ref a @ Err(b) => {}
| +++
error[E0382]: use of partially moved value
--> $DIR/borrowck-move-and-move.rs:25:9
@ -56,6 +79,10 @@ LL | xs @ [a, .., b] => {}
| 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 xs @ [a, .., ref b] => {}
| +++ +++
error[E0382]: use of partially moved value
--> $DIR/borrowck-move-and-move.rs:29:9
@ -66,6 +93,10 @@ LL | xs @ [_, ys @ .., _] => {}
| 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 xs @ [_, ref ys @ .., _] => {}
| +++ +++
error[E0382]: use of moved value
--> $DIR/borrowck-move-and-move.rs:22:12

View File

@ -79,6 +79,10 @@ LL | let ref a @ box b = Box::new(NC);
| value borrowed here after move
|
= note: move occurs because value has type `NC`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref a @ box ref b = Box::new(NC);
| +++
error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable
--> $DIR/borrowck-pat-at-and-box.rs:38:9

View File

@ -7,6 +7,11 @@ LL | let a @ ref b = U;
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `U` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref a @ ref b = U;
| +++
error: aborting due to previous error

View File

@ -7,6 +7,11 @@ LL | let a @ ref b = U;
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `U` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref a @ ref b = U;
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:24:9
@ -18,6 +23,11 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U);
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `(U, U)` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref a @ (mut b @ ref mut c, d @ ref e) = (U, U);
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:24:14
@ -28,6 +38,11 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U);
| | value borrowed here after move
| value moved into `b` here
| move occurs because `b` has type `U` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let a @ (ref mut b @ ref mut c, d @ ref e) = (U, U);
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:24:33
@ -38,6 +53,11 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U);
| | value borrowed here after move
| value moved into `d` here
| move occurs because `d` has type `U` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let a @ (mut b @ ref mut c, ref d @ ref e) = (U, U);
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:29:9
@ -49,6 +69,11 @@ LL | let a @ [ref mut b, ref c] = [U, U];
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `[U; 2]` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref a @ [ref mut b, ref c] = [U, U];
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:31:9
@ -59,6 +84,11 @@ LL | let a @ ref b = u();
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `U` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref a @ ref b = u();
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:33:9
@ -70,6 +100,11 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u());
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `(U, U)` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref a @ (mut b @ ref mut c, d @ ref e) = (u(), u());
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:33:14
@ -80,6 +115,11 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u());
| | value borrowed here after move
| value moved into `b` here
| move occurs because `b` has type `U` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let a @ (ref mut b @ ref mut c, d @ ref e) = (u(), u());
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:33:33
@ -90,6 +130,11 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u());
| | value borrowed here after move
| value moved into `d` here
| move occurs because `d` has type `U` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let a @ (mut b @ ref mut c, ref d @ ref e) = (u(), u());
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:38:9
@ -101,6 +146,11 @@ LL | let a @ [ref mut b, ref c] = [u(), u()];
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `[U; 2]` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref a @ [ref mut b, ref c] = [u(), u()];
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:42:9
@ -111,6 +161,11 @@ LL | a @ Some(ref b) => {}
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `Option<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: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:47:9
@ -122,6 +177,11 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {}
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `Option<(U, 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: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:47:19
@ -132,6 +192,11 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {}
| | value borrowed here after move
| value moved into `b` here
| move occurs because `b` has type `U` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
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:47:38
@ -142,6 +207,11 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {}
| | value borrowed here after move
| value moved into `d` here
| move occurs because `d` has type `U` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
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:55:9
@ -153,6 +223,11 @@ LL | mut a @ Some([ref b, ref mut c]) => {}
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `Option<[U; 2]>` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
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
@ -163,6 +238,11 @@ LL | a @ Some(ref b) => {}
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `Option<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: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:67:9
@ -174,6 +254,11 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {}
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `Option<(U, 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: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:67:19
@ -184,6 +269,11 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {}
| | value borrowed here after move
| value moved into `b` here
| move occurs because `b` has type `U` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
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
@ -194,6 +284,11 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {}
| | value borrowed here after move
| value moved into `d` here
| move occurs because `d` has type `U` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
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
@ -205,6 +300,11 @@ LL | mut a @ Some([ref b, ref mut c]) => {}
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `Option<[U; 2]>` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | ref mut a @ Some([ref b, ref mut c]) => {}
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:11:11
@ -215,6 +315,11 @@ LL | fn f1(a @ ref b: U) {}
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `U` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | fn f1(ref a @ ref b: U) {}
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:14:11
@ -226,6 +331,11 @@ LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {}
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `(U, U)` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | fn f2(ref mut a @ (b @ ref c, mut d @ ref e): (U, U)) {}
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:14:20
@ -236,6 +346,11 @@ LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {}
| | value borrowed here after move
| value moved into `b` here
| move occurs because `b` has type `U` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | fn f2(mut a @ (ref b @ ref c, mut d @ ref e): (U, U)) {}
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:14:31
@ -246,6 +361,11 @@ LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {}
| | value borrowed here after move
| value moved into `d` here
| move occurs because `d` has type `U` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | fn f2(mut a @ (b @ ref c, ref mut d @ ref e): (U, U)) {}
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:19:11
@ -257,6 +377,11 @@ LL | fn f3(a @ [ref mut b, ref c]: [U; 2]) {}
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `[U; 2]` which does not implement the `Copy` trait
|
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[E0382]: use of partially moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:24:9
@ -267,6 +392,10 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U);
| 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 | let ref a @ (mut b @ ref mut c, ref d @ ref e) = (U, U);
| +++ +++
error[E0382]: use of partially moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:33:9
@ -277,6 +406,10 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u());
| 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 | 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
@ -285,6 +418,11 @@ 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
|
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:55:30
@ -305,6 +443,11 @@ 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
@ -313,6 +456,11 @@ 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
|
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

View File

@ -242,6 +242,10 @@ LL | let ref mut a @ [b, mut c] = [U, U];
| 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 | let ref mut a @ [b, ref mut c] = [U, U];
| +++
error[E0382]: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref.rs:33:9
@ -251,6 +255,11 @@ LL | let ref a @ b = u();
| | |
| | value moved here
| value borrowed here after move
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref a @ ref b = u();
| +++
error[E0382]: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref.rs:36:18
@ -261,6 +270,10 @@ LL | let ref a @ (ref b @ mut c, ref d @ e) = (u(), u());
| value borrowed here after move
|
= note: 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 | let ref a @ (ref b @ ref mut c, ref d @ e) = (u(), u());
| +++
error[E0382]: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref.rs:36:33
@ -271,6 +284,10 @@ LL | let ref a @ (ref b @ mut c, ref d @ e) = (u(), u());
| value borrowed here after move
|
= note: 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 | let ref a @ (ref b @ mut c, ref d @ ref e) = (u(), u());
| +++
error[E0382]: borrow of partially moved value
--> $DIR/borrowck-pat-by-move-and-ref.rs:42:9
@ -281,6 +298,10 @@ LL | let ref mut a @ [b, mut c] = [u(), u()];
| 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 | let ref mut a @ [b, ref mut c] = [u(), u()];
| +++
error[E0382]: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref.rs:69:23
@ -291,7 +312,7 @@ LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {}
| value borrowed here after move
|
= note: move occurs because value has type `U`, which does not implement the `Copy` trait
help: borrow this field in the pattern to avoid moving the value
help: borrow this binding in the pattern to avoid moving the value
|
LL | ref a @ Some((ref b @ ref mut c, ref d @ e)) => {}
| +++
@ -305,7 +326,7 @@ LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {}
| value borrowed here after move
|
= note: move occurs because value has type `U`, which does not implement the `Copy` trait
help: borrow this field in the pattern to avoid moving the value
help: borrow this binding in the pattern to avoid moving the value
|
LL | ref a @ Some((ref b @ mut c, ref d @ ref e)) => {}
| +++

View File

@ -97,6 +97,11 @@ LL | let a @ (ref mut b, ref mut c) = (U, U);
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `(U, U)` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref a @ (ref mut b, ref mut c) = (U, U);
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-ref-mut-twice.rs:67:9
@ -109,6 +114,11 @@ LL | let a @ (b, [c, d]) = &mut val; // Same as ^--
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `&mut (U, [U; 2])` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref a @ (b, [c, d]) = &mut val; // Same as ^--
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-ref-mut-twice.rs:70:9
@ -119,6 +129,11 @@ LL | let a @ &mut ref mut b = &mut U;
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `&mut U` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref a @ &mut ref mut b = &mut U;
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-ref-mut-twice.rs:72:9
@ -130,6 +145,11 @@ LL | let a @ &mut (ref mut b, ref mut c) = &mut (U, U);
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `&mut (U, U)` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref a @ &mut (ref mut b, ref mut c) = &mut (U, U);
| +++
error: cannot borrow value as mutable more than once at a time
--> $DIR/borrowck-pat-ref-mut-twice.rs:76:9

View File

@ -7,6 +7,10 @@ LL | let a @ NC(b, c @ NC(d, e)) = NC(C, NC(C, C));
| value used here after partial move
|
= note: partial move occurs because value has type `NC<C, C>`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref a @ NC(b, ref c @ NC(d, e)) = NC(C, NC(C, C));
| +++ +++
error: aborting due to previous error

View File

@ -34,6 +34,11 @@ LL | Ok(ref a @ b) | Err(b @ ref a) => {
| | value borrowed here after move
| value moved into `b` here
| move occurs because `b` has type `NotCopy` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | Ok(ref a @ b) | Err(ref b @ ref a) => {
| +++
error: cannot move out of value because it is borrowed
--> $DIR/default-binding-modes-both-sides-independent.rs:42:9
@ -52,6 +57,11 @@ LL | let ref mut a @ b = NotCopy;
| | |
| | value moved here
| value borrowed here after move
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref mut a @ ref b = NotCopy;
| +++
error: aborting due to 6 previous errors

View File

@ -129,6 +129,10 @@ LL | drop(tup.1);
| ^^^^^ value used here after move
|
= note: move occurs because `tup.1` has type `U`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let (ref _x0, ref _x1, ref _x2, ..) = tup;
| +++
error[E0382]: borrow of moved value: `tup.1`
--> $DIR/borrowck-move-ref-pattern.rs:29:20

View File

@ -7,6 +7,12 @@ LL | let _ = dbg!(a);
| ------- value moved here
LL | let _ = dbg!(a);
| ^ value used here after move
|
help: borrow this binding in the pattern to avoid moving the value
--> $SRC_DIR/std/src/macros.rs:LL:COL
|
LL | ref tmp => {
| +++
error: aborting due to previous error

View File

@ -12,6 +12,7 @@ error[E0382]: use of moved value: `a`
LL | let a = vec![1, 2, 3];
| - move occurs because `a` has type `Vec<i32>`, which does not implement the `Copy` trait
LL | for i in &a {
| ----------- inside of this loop
LL | for j in a {
| ^ `a` moved due to this implicit call to `.into_iter()`, in previous iteration of loop
|

View File

@ -0,0 +1,19 @@
// run-rustfix
#![allow(unused)]
struct S {
f: String,
}
fn main() {
let ref _moved @ ref _from = String::from("foo"); //~ ERROR
let ref _moved @ ref _from = String::from("foo"); //~ ERROR
let ref _moved @ ref _from = String::from("foo"); //~ ERROR
//~^ ERROR
let ref _moved @ ref _from = String::from("foo"); // ok
let ref _moved @ S { ref f } = S { f: String::from("foo") }; //~ ERROR
let ref _moved @ S { ref f } = S { f: String::from("foo") }; //~ ERROR
//~^ ERROR
let ref _moved @ S { ref f } = S { f: String::from("foo") }; // ok
let ref _moved @ S { ref f } = S { f: String::from("foo") }; //~ ERROR
}

View File

@ -0,0 +1,19 @@
// run-rustfix
#![allow(unused)]
struct S {
f: String,
}
fn main() {
let _moved @ _from = String::from("foo"); //~ ERROR
let _moved @ ref _from = String::from("foo"); //~ ERROR
let ref _moved @ _from = String::from("foo"); //~ ERROR
//~^ ERROR
let ref _moved @ ref _from = String::from("foo"); // ok
let _moved @ S { f } = S { f: String::from("foo") }; //~ ERROR
let ref _moved @ S { f } = S { f: String::from("foo") }; //~ ERROR
//~^ ERROR
let ref _moved @ S { ref f } = S { f: String::from("foo") }; // ok
let _moved @ S { ref f } = S { f: String::from("foo") }; //~ ERROR
}

View File

@ -0,0 +1,107 @@
error: borrow of moved value
--> $DIR/ref-pattern-binding.rs:10:9
|
LL | let _moved @ ref _from = String::from("foo");
| ------^^^---------
| | |
| | value borrowed here after move
| value moved into `_moved` here
| move occurs because `_moved` has type `String` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref _moved @ ref _from = String::from("foo");
| +++
error: cannot move out of value because it is borrowed
--> $DIR/ref-pattern-binding.rs:11:9
|
LL | let ref _moved @ _from = String::from("foo");
| ----------^^^-----
| | |
| | value moved into `_from` here
| value borrowed, by `_moved`, here
error: cannot move out of value because it is borrowed
--> $DIR/ref-pattern-binding.rs:15:9
|
LL | let ref _moved @ S { f } = S { f: String::from("foo") };
| ----------^^^^^^^-^^
| | |
| | value moved into `f` here
| value borrowed, by `_moved`, here
error: borrow of moved value
--> $DIR/ref-pattern-binding.rs:18:9
|
LL | let _moved @ S { ref f } = S { f: String::from("foo") };
| ------^^^^^^^-----^^
| | |
| | value borrowed here after move
| value moved into `_moved` here
| move occurs because `_moved` has type `S` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref _moved @ S { ref f } = S { f: String::from("foo") };
| +++
error[E0382]: use of moved value
--> $DIR/ref-pattern-binding.rs:9:9
|
LL | let _moved @ _from = String::from("foo");
| ^^^^^^ ----- ------------------- move occurs because value has type `String`, which does not implement the `Copy` trait
| | |
| | value moved here
| value used here after move
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref _moved @ ref _from = String::from("foo");
| +++ +++
error[E0382]: borrow of moved value
--> $DIR/ref-pattern-binding.rs:11:9
|
LL | let ref _moved @ _from = String::from("foo");
| ^^^^^^^^^^ ----- ------------------- move occurs because value has type `String`, which does not implement the `Copy` trait
| | |
| | value moved here
| value borrowed here after move
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref _moved @ ref _from = String::from("foo");
| +++
error[E0382]: use of partially moved value
--> $DIR/ref-pattern-binding.rs:14:9
|
LL | let _moved @ S { f } = S { f: String::from("foo") };
| ^^^^^^ - value partially moved here
| |
| value used here after partial move
|
= note: partial move occurs because value has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref _moved @ S { ref f } = S { f: String::from("foo") };
| +++ +++
error[E0382]: borrow of partially moved value
--> $DIR/ref-pattern-binding.rs:15:9
|
LL | let ref _moved @ S { f } = S { f: String::from("foo") };
| ^^^^^^^^^^ - value partially moved here
| |
| value borrowed here after partial move
|
= note: partial move occurs because value has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref _moved @ S { ref f } = S { f: String::from("foo") };
| +++
error: aborting due to 8 previous errors
For more information about this error, try `rustc --explain E0382`.

View File

@ -7,6 +7,11 @@ LL | let _moved @ _from = String::from("foo");
| | value moved here
| value used here after move
-Ztrack-diagnostics: created at compiler/rustc_borrowck/src/borrowck_errors.rs:LL:CC
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref _moved @ ref _from = String::from("foo");
| +++ +++
error: aborting due to previous error

View File

@ -23,6 +23,10 @@ LL | println!("{}", x);
| ^ value borrowed here after move
|
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider cloning the value if the performance cost is acceptable
|
LL | ::std::mem::drop(x.clone());
| ++++++++
error[E0506]: cannot assign to `i` because it is borrowed
--> $DIR/try-block-maybe-bad-lifetime.rs:40:9

View File

@ -8,6 +8,14 @@ LL | move_out(x.f1_nocopy);
| ----------- value moved here
LL | move_out(x.f2_nocopy);
| ^^^^^^^^^^^ value used here after move
|
note: consider changing this parameter type in function `move_out` to borrow instead if owning the value isn't necessary
--> $DIR/union-move.rs:10:19
|
LL | fn move_out<T>(x: T) {}
| -------- ^ this parameter takes ownership of the value
| |
| in this function
error[E0382]: use of moved value: `x`
--> $DIR/union-move.rs:45:18
@ -19,6 +27,14 @@ LL | move_out(x.f2_nocopy);
| ----------- value moved here
LL | move_out(x.f3_copy);
| ^^^^^^^^^ value used here after move
|
note: consider changing this parameter type in function `move_out` to borrow instead if owning the value isn't necessary
--> $DIR/union-move.rs:10:19
|
LL | fn move_out<T>(x: T) {}
| -------- ^ this parameter takes ownership of the value
| |
| in this function
error[E0509]: cannot move out of type `U2`, which implements the `Drop` trait
--> $DIR/union-move.rs:52:18

View File

@ -8,6 +8,14 @@ LL | move_out(x.f1_nocopy);
| ----------- value moved here
LL | move_out(x.f2_nocopy);
| ^^^^^^^^^^^ value used here after move
|
note: consider changing this parameter type in function `move_out` to borrow instead if owning the value isn't necessary
--> $DIR/union-move.rs:10:19
|
LL | fn move_out<T>(x: T) {}
| -------- ^ this parameter takes ownership of the value
| |
| in this function
error[E0382]: use of moved value: `x`
--> $DIR/union-move.rs:45:18
@ -19,6 +27,14 @@ LL | move_out(x.f2_nocopy);
| ----------- value moved here
LL | move_out(x.f3_copy);
| ^^^^^^^^^ value used here after move
|
note: consider changing this parameter type in function `move_out` to borrow instead if owning the value isn't necessary
--> $DIR/union-move.rs:10:19
|
LL | fn move_out<T>(x: T) {}
| -------- ^ this parameter takes ownership of the value
| |
| in this function
error[E0509]: cannot move out of type `U2`, which implements the `Drop` trait
--> $DIR/union-move.rs:52:18

View File

@ -14,6 +14,10 @@ note: calling this operator moves the left-hand side
|
LL | fn not(self) -> Self::Output;
| ^^^^
help: consider cloning the value if the performance cost is acceptable
|
LL | !x.clone();
| ++++++++
help: consider further restricting this bound
|
LL | fn move_then_borrow<T: Not<Output=T> + Clone + Copy>(x: T) {

View File

@ -28,6 +28,14 @@ LL | drop_unsized(y);
...
LL | println!("{}", &y);
| ^^ value borrowed here after move
|
note: consider changing this parameter type in function `drop_unsized` to borrow instead if owning the value isn't necessary
--> $DIR/borrow-after-move.rs:14:31
|
LL | fn drop_unsized<T: ?Sized>(_: T) {}
| ------------ ^ this parameter takes ownership of the value
| |
| in this function
error[E0382]: borrow of moved value: `x`
--> $DIR/borrow-after-move.rs:31:24
@ -66,6 +74,11 @@ LL | x.foo();
| - value moved here
LL | println!("{}", &x);
| ^^ value borrowed here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | x.clone().foo();
| ++++++++
error: aborting due to 5 previous errors; 1 warning emitted

View File

@ -16,6 +16,14 @@ LL | drop_unsized(y);
| - value moved here
LL | drop_unsized(y);
| ^ value used here after move
|
note: consider changing this parameter type in function `drop_unsized` to borrow instead if owning the value isn't necessary
--> $DIR/double-move.rs:14:31
|
LL | fn drop_unsized<T: ?Sized>(_: T) {}
| ------------ ^ this parameter takes ownership of the value
| |
| in this function
error[E0382]: use of moved value: `x`
--> $DIR/double-move.rs:27:22

View File

@ -9,6 +9,10 @@ LL | println!("{}", x);
| ^ value borrowed here after move
|
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider cloning the value if the performance cost is acceptable
|
LL | let _y = x.clone();
| ++++++++
error: aborting due to previous error

View File

@ -9,6 +9,14 @@ LL | l.push(n);
LL |
LL | let x = n.to_string();
| ^^^^^^^^^^^^^ value borrowed here after move
|
note: consider changing this parameter type in method `push` to borrow instead if owning the value isn't necessary
--> $DIR/use-after-move-implicity-coerced-object.rs:17:27
|
LL | fn push(&mut self, n: Box<dyn ToString + 'static>) {
| ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ this parameter takes ownership of the value
| |
| in this method
error: aborting due to previous error

View File

@ -582,7 +582,7 @@ fn ident_difference_expr_with_base_location(
| (Block(_, _), Block(_, _))
| (Closure(_), Closure(_))
| (Match(_, _), Match(_, _))
| (Loop(_, _), Loop(_, _))
| (Loop(_, _, _), Loop(_, _, _))
| (ForLoop(_, _, _, _), ForLoop(_, _, _, _))
| (While(_, _, _), While(_, _, _))
| (If(_, _, _), If(_, _, _))

View File

@ -171,7 +171,7 @@ pub fn eq_expr(l: &Expr, r: &Expr) -> bool {
(ForLoop(lp, li, lt, ll), ForLoop(rp, ri, rt, rl)) => {
eq_label(ll, rl) && eq_pat(lp, rp) && eq_expr(li, ri) && eq_block(lt, rt)
},
(Loop(lt, ll), Loop(rt, rl)) => eq_label(ll, rl) && eq_block(lt, rt),
(Loop(lt, ll, _), Loop(rt, rl, _)) => eq_label(ll, rl) && eq_block(lt, rt),
(Block(lb, ll), Block(rb, rl)) => eq_label(ll, rl) && eq_block(lb, rb),
(TryBlock(l), TryBlock(r)) => eq_block(l, r),
(Yield(l), Yield(r)) | (Ret(l), Ret(r)) => eq_expr_opt(l, r),

View File

@ -660,7 +660,7 @@ fn to_control_flow(expr: &ast::Expr, expr_type: ExprType) -> Option<ControlFlow<
ast::ExprKind::ForLoop(ref pat, ref cond, ref block, label) => {
Some(ControlFlow::new_for(pat, cond, block, label, expr.span))
}
ast::ExprKind::Loop(ref block, label) => {
ast::ExprKind::Loop(ref block, label, _) => {
Some(ControlFlow::new_loop(block, label, expr.span))
}
ast::ExprKind::While(ref cond, ref block, label) => {