1
Fork 0

Suggest .clone() or ref binding on E0382

This commit is contained in:
Esteban Küber 2022-11-02 21:22:24 -07:00
parent d121aa3b55
commit 9e72e35ceb
86 changed files with 1092 additions and 49 deletions

View file

@ -1376,7 +1376,7 @@ pub enum ExprKind {
/// Conditionless loop (can be exited with `break`, `continue`, or `return`). /// Conditionless loop (can be exited with `break`, `continue`, or `return`).
/// ///
/// `'label: loop { block }` /// `'label: loop { block }`
Loop(P<Block>, Option<Label>), Loop(P<Block>, Option<Label>, Span),
/// A `match` block. /// A `match` block.
Match(P<Expr>, Vec<Arm>), Match(P<Expr>, Vec<Arm>),
/// A closure (e.g., `move |a, b, c| a + b + c`). /// 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); vis.visit_block(body);
visit_opt(label, |label| vis.visit_label(label)); visit_opt(label, |label| vis.visit_label(label));
} }
ExprKind::Loop(body, label) => { ExprKind::Loop(body, label, span) => {
vis.visit_block(body); vis.visit_block(body);
visit_opt(label, |label| vis.visit_label(label)); visit_opt(label, |label| vis.visit_label(label));
vis.visit_span(span);
} }
ExprKind::Match(expr, arms) => { ExprKind::Match(expr, arms) => {
vis.visit_expr(expr); 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_expr(subexpression);
visitor.visit_block(block); visitor.visit_block(block);
} }
ExprKind::Loop(block, opt_label) => { ExprKind::Loop(block, opt_label, _) => {
walk_list!(visitor, visit_label, opt_label); walk_list!(visitor, visit_label, opt_label);
visitor.visit_block(block); 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); let span = this.mark_span_with_reason(DesugaringKind::WhileLoop, e.span, None);
this.lower_expr_while_in_loop_scope(span, cond, body, *opt_label) 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( hir::ExprKind::Loop(
this.lower_block(body, false), this.lower_block(body, false),
this.lower_label(*opt_label), this.lower_label(*opt_label),
hir::LoopSource::Loop, hir::LoopSource::Loop,
DUMMY_SP, this.lower_span(span),
) )
}), }),
ExprKind::TryBlock(body) => self.lower_expr_try_block(body), ExprKind::TryBlock(body) => self.lower_expr_try_block(body),

View file

@ -377,7 +377,7 @@ impl<'a> State<'a> {
self.space(); self.space();
self.print_block_with_attrs(blk, attrs); 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 { if let Some(label) = opt_label {
self.print_ident(label.ident); self.print_ident(label.ident);
self.word_space(":"); self.word_space(":");

View file

@ -191,6 +191,146 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
is_loop_move = true; is_loop_move = true;
} }
struct ExpressionFinder<'hir> {
expr_span: Span,
expr: Option<&'hir hir::Expr<'hir>>,
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, _) = p.kind
&& i.span == self.expr_span
{
self.pat = Some(p);
}
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,
};
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) {
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)
&& let Some(def_id) = def_id.as_local()
&& 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 + 1)
{
let mut span: MultiSpan = arg.span.into();
span.push_span_label(
arg.span,
"this type parameter takes ownership of the value".to_string(),
);
span.push_span_label(
ident.span,
"in this method".to_string(),
);
err.span_note(
span,
format!(
"consider changing this parameter type in `{}` to borrow \
instead if ownering the value isn't necessary",
ident,
),
);
}
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()
&& let Some(def_id) = def_id.as_local()
&& 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)
{
let mut span: MultiSpan = arg.span.into();
span.push_span_label(
arg.span,
"this type parameter takes ownership of the value".to_string(),
);
span.push_span_label(
ident.span,
"in this function".to_string(),
);
err.span_note(
span,
format!(
"consider changing this parameter type in `{}` to borrow \
instead if ownering the value isn't necessary",
ident,
),
);
}
let place = &self.move_data.move_paths[mpi].place;
let ty = place.ty(self.body, self.infcx.tcx).ty;
self.suggest_cloning(&mut err, ty, move_span);
}
}
if let Some(pat) = finder.pat {
in_pattern = true;
err.span_suggestion_verbose(
pat.span.shrink_to_lo(),
"borrow this binding in the pattern to avoid moving the value",
"ref ".to_string(),
Applicability::MachineApplicable,
);
}
}
self.explain_captures( self.explain_captures(
&mut err, &mut err,
span, span,
@ -203,25 +343,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
is_loop_move, is_loop_move,
maybe_reinitialized_locations.is_empty(), 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;
}
}
} }
use_spans.var_path_only_subdiag(&mut err, desired_action); use_spans.var_path_only_subdiag(&mut err, desired_action);
@ -590,6 +711,39 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
true 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();
let mut fulfill_cx = <dyn rustc_infer::traits::TraitEngine<'_>>::new(infcx.tcx);
let clone_did = infcx.tcx.lang_items().clone_trait().unwrap();
let cause = ObligationCause::new(
span,
self.mir_hir_id(),
rustc_infer::traits::ObligationCauseCode::MiscObligation,
);
fulfill_cx.register_bound(
&infcx,
self.param_env,
// Erase any region vids from the type, which may not be resolved
infcx.tcx.erase_regions(ty),
clone_did,
cause,
);
// Select all, including ambiguous predicates
let errors = fulfill_cx.select_all_or_error(&infcx);
if errors.is_empty() {
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) { fn suggest_adding_copy_bounds(&self, err: &mut Diagnostic, ty: Ty<'tcx>, span: Span) {
let tcx = self.infcx.tcx; let tcx = self.infcx.tcx;
let generics = tcx.generics_of(self.mir_def_id()); let generics = tcx.generics_of(self.mir_def_id());

View file

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

View file

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

View file

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

View file

@ -32,6 +32,10 @@ LL | +
LL | x.clone(); LL | x.clone();
| ^^^^^^^^^ value borrowed here after move | ^^^^^^^^^ 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 help: consider further restricting this bound
| |
LL | fn move_then_borrow<T: Add<Output=()> + Clone + Copy>(x: T) { LL | fn move_then_borrow<T: Add<Output=()> + Clone + Copy>(x: T) {

View file

@ -27,6 +27,11 @@ LL | a @ [.., _] => (),
... ...
LL | &x; LL | &x;
| ^^ value borrowed here after move | ^^ 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 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 --> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:28:5
@ -78,6 +83,15 @@ LL | foo @ Some(Test::Foo | Test::Bar) => (),
... ...
LL | &x; LL | &x;
| ^^ value borrowed here after move | ^^ 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) => (),
| +++
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 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 --> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:86:5
@ -129,6 +143,15 @@ LL | a @ [.., Some(Test::Foo | Test::Bar)] => (),
... ...
LL | &x; LL | &x;
| ^^ value borrowed here after move | ^^ 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)] => (),
| +++
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 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 --> $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 | - value moved here
LL | consume(b); LL | consume(b);
| ^ value used here after move | ^ value used here after move
|
note: consider changing this parameter type in `consume` to borrow instead if ownering the value isn't necessary
--> $DIR/borrowck-consume-unsize-vec.rs:3:15
|
LL | fn consume(_: Box<[i32]>) {
| ------- ^^^^^^^^^^ this type 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 error: aborting due to previous error

View file

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

View file

@ -9,6 +9,11 @@ LL | Some(_) if { drop(my_str); false } => {}
LL | Some(_) => {} LL | Some(_) => {}
LL | None => { foo(my_str); } LL | None => { foo(my_str); }
| ^^^^^^ value used here after move | ^^^^^^ 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 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 borrowed here after move
| | | |
| value moved here | 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 error: aborting due to previous error

View file

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

View file

@ -8,6 +8,10 @@ LL | match a {
| ^ value used here after partial move | ^ value used here after partial move
| |
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait = 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` error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:28:11 --> $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 | ^ value used here after partial move
| |
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait = 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` error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:41:11 --> $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 | ^ value used here after partial move
| |
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait = 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` error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:52:11 --> $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 | ^ value used here after partial move
| |
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait = 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` error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:63:11 --> $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 | ^ value used here after partial move
| |
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait = 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` error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:74:11 --> $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 | ^ value used here after partial move
| |
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait = 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` error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:85:11 --> $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 | ^ value used here after partial move
| |
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait = 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` error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:96:11 --> $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 | ^ value used here after partial move
| |
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait = 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` error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:109:11 --> $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 | ^ value used here after partial move
| |
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait = 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 error: aborting due to 9 previous errors

View file

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

View file

@ -8,6 +8,10 @@ LL | match a {
| ^ value used here after partial move | ^ value used here after partial move
| |
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait = 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` error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:28:11 --> $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 | ^ value used here after partial move
| |
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait = 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` error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:41:11 --> $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 | ^ value used here after partial move
| |
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait = 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` error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:52:11 --> $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 | ^ value used here after partial move
| |
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait = 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` error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:63:11 --> $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 | ^ value used here after partial move
| |
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait = 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` error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:74:11 --> $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 | ^ value used here after partial move
| |
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait = 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` error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:85:11 --> $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 | ^ value used here after partial move
| |
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait = 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` error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:96:11 --> $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 | ^ value used here after partial move
| |
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait = 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` error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:109:11 --> $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 | ^ value used here after partial move
| |
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait = 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 error: aborting due to 9 previous errors

View file

@ -7,6 +7,10 @@ LL | let [.., ref _y] = a;
| ^^^^^^ value borrowed here after move | ^^^^^^ value borrowed here after move
| |
= note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait = 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[..]` error[E0382]: borrow of partially moved value: `a[..]`
--> $DIR/borrowck-move-out-from-array-use.rs:16:14 --> $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 | ^^^^^^ value borrowed here after partial move
| |
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait = 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` error[E0382]: borrow of moved value: `a[..].0`
--> $DIR/borrowck-move-out-from-array-use.rs:22:15 --> $DIR/borrowck-move-out-from-array-use.rs:22:15
@ -27,6 +35,10 @@ LL | let [.., (ref _y, _)] = a;
| ^^^^^^ value borrowed here after move | ^^^^^^ value borrowed here after move
| |
= note: move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait = 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` error[E0382]: borrow of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use.rs:30:10 --> $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 | ^^^^^^ value borrowed here after partial move
| |
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait = 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` error[E0382]: borrow of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use.rs:36:16 --> $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 | ^^^^^^ value borrowed here after partial move
| |
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait = 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` error[E0382]: borrow of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use.rs:42:10 --> $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 | ^^^^^^ value borrowed here after partial move
| |
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait = 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` error[E0382]: borrow of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use.rs:48:16 --> $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 | ^^^^^^ value borrowed here after partial move
| |
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait = 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[..]` error[E0382]: borrow of moved value: `a[..]`
--> $DIR/borrowck-move-out-from-array-use.rs:54:11 --> $DIR/borrowck-move-out-from-array-use.rs:54:11
@ -77,6 +105,10 @@ LL | let [(ref _x, _), _, _] = a;
| ^^^^^^ value borrowed here after move | ^^^^^^ value borrowed here after move
| |
= note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait = 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[..]` error[E0382]: borrow of moved value: `a[..]`
--> $DIR/borrowck-move-out-from-array-use.rs:60:15 --> $DIR/borrowck-move-out-from-array-use.rs:60:15
@ -87,6 +119,10 @@ LL | let [.., (ref _x, _)] = a;
| ^^^^^^ value borrowed here after move | ^^^^^^ value borrowed here after move
| |
= note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait = 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` error[E0382]: borrow of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use.rs:68:13 --> $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 | ^^^^^^ value borrowed here after partial move
| |
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait = 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` error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use.rs:76:5 --> $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 | ^^^^ value used here after partial move
| |
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait = 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` error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use.rs:82:5 --> $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 | ^^^^ value used here after partial move
| |
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait = 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` error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use.rs:88:5 --> $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 | ^^^^ value used here after partial move
| |
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait = 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` error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use.rs:94:5 --> $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 | ^^^^ value used here after partial move
| |
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait = 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 error: aborting due to 14 previous errors

View file

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

View file

@ -40,6 +40,11 @@ LL | thread::spawn(move|| {
... ...
LL | drop(x1); LL | drop(x1);
| -- use occurs due to use in closure | -- 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` error[E0382]: use of moved value: `x2`
--> $DIR/borrowck-multiple-captures.rs:27:19 --> $DIR/borrowck-multiple-captures.rs:27:19
@ -53,6 +58,11 @@ LL | thread::spawn(move|| {
... ...
LL | drop(x2); LL | drop(x2);
| -- use occurs due to use in closure | -- 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` error[E0382]: use of moved value: `x`
--> $DIR/borrowck-multiple-captures.rs:41:14 --> $DIR/borrowck-multiple-captures.rs:41:14
@ -100,6 +110,11 @@ LL | thread::spawn(move|| {
LL | LL |
LL | drop(x); LL | drop(x);
| - use occurs due to use in closure | - 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 error: aborting due to 8 previous errors

View file

@ -33,6 +33,11 @@ LL | println!("{}", f[s]);
... ...
LL | f[s] = 10; LL | f[s] = 10;
| ^ value used here after move | ^ 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 error: aborting due to 3 previous errors

View file

@ -8,6 +8,11 @@ LL | drop(x);
| - value moved here | - value moved here
LL | let _ = (1,x); LL | let _ = (1,x);
| ^ value used here after move | ^ 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 error: aborting due to previous error

View file

@ -8,6 +8,11 @@ LL | Some(_) if { drop(a); false } => None,
| - value moved here | - value moved here
LL | x => x, LL | x => x,
| ^ value used here after move | ^ 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 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 | ^^^^^ value moved here, in previous iteration of loop
| |
= note: move occurs because value has type `Vec<bool>`, which does not implement the `Copy` trait = 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 { LL | if let Some(ref thing) = maybe {
| +++ | +++

View file

@ -8,6 +8,10 @@ LL | val = None;
| ---------- this reinitialization might get skipped | ---------- this reinitialization might get skipped
| |
= note: move occurs because value has type `Struct`, which does not implement the `Copy` trait = 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` error[E0382]: use of moved value: `foo`
--> $DIR/issue-83760.rs:21:14 --> $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 | ^^^^^^ value moved here, in previous iteration of loop
| |
= note: move occurs because value has type `&mut i32`, which does not implement the `Copy` trait = 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 {} LL | if let Some(ref mut _x) = opt {}
| +++ | +++

View file

@ -8,7 +8,7 @@ LL | foo(s);
| ^ value used here after partial move | ^ value used here after partial move
| |
= note: partial move occurs because value has type `S`, which does not implement the `Copy` trait = 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 { LL | if let Some(ref mut x) = s {
| +++ | +++
@ -23,7 +23,7 @@ LL | bar(e);
| ^ value used here after partial move | ^ value used here after partial move
| |
= note: partial move occurs because value has type `S`, which does not implement the `Copy` trait = 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; LL | let E::V { s: ref mut x } = e;
| +++ | +++

View file

@ -8,7 +8,7 @@ LL | foo(s);
| ^ value used here after partial move | ^ value used here after partial move
| |
= note: partial move occurs because value has type `S`, which does not implement the `Copy` trait = 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 { LL | if let Some(ref x) = s {
| +++ | +++
@ -23,7 +23,7 @@ LL | bar(e);
| ^ value used here after partial move | ^ value used here after partial move
| |
= note: partial move occurs because value has type `S`, which does not implement the `Copy` trait = 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; 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>) { 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 | ----- move occurs because `value` has type `&mut Events<R>`, which does not implement the `Copy` trait
LL | for _ in 0..3 { LL | for _ in 0..3 {
| ------------- inside of this loop
LL | Other::handle(value); LL | Other::handle(value);
| ^^^^^ value moved here, in previous iteration of loop | ^^^^^ value moved here, in previous iteration of loop
| |
note: consider changing this parameter type in `handle` to borrow instead if ownering the value isn't necessary
--> $DIR/mut-borrow-in-loop-2.rs:9:22
|
LL | fn handle(value: T) -> Self;
| ------ ^ this type parameter takes ownership of the value
| |
| in this function
help: consider creating a fresh reborrow of `value` here help: consider creating a fresh reborrow of `value` here
| |
LL | Other::handle(&mut *value); LL | Other::handle(&mut *value);

View file

@ -8,6 +8,10 @@ LL | &x.0 .0;
| ^^^^^^^ value borrowed here after move | ^^^^^^^ value borrowed here after move
| |
= note: move occurs because `x.0.0` has type `String`, which does not implement the `Copy` trait = 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` error[E0382]: borrow of moved value: `x.0.1`
--> $DIR/or-patterns.rs:10:5 --> $DIR/or-patterns.rs:10:5
@ -19,6 +23,10 @@ LL | &x.0 .1;
| ^^^^^^^ value borrowed here after move | ^^^^^^^ value borrowed here after move
| |
= note: move occurs because `x.0.1` has type `String`, which does not implement the `Copy` trait = 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 error[E0502]: cannot borrow `x.0.0` as mutable because it is also borrowed as immutable
--> $DIR/or-patterns.rs:18:5 --> $DIR/or-patterns.rs:18:5
@ -77,6 +85,10 @@ LL | &x.0 .0;
| ^^^^^^^ value borrowed here after move | ^^^^^^^ value borrowed here after move
| |
= note: move occurs because `x.0.0` has type `String`, which does not implement the `Copy` trait = 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` error[E0382]: borrow of moved value: `x.0.1`
--> $DIR/or-patterns.rs:40:5 --> $DIR/or-patterns.rs:40:5
@ -88,6 +100,10 @@ LL | &x.0 .1;
| ^^^^^^^ value borrowed here after move | ^^^^^^^ value borrowed here after move
| |
= note: move occurs because `x.0.1` has type `String`, which does not implement the `Copy` trait = 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 error[E0502]: cannot borrow `x.0.0` as mutable because it is also borrowed as immutable
--> $DIR/or-patterns.rs:46:5 --> $DIR/or-patterns.rs:46:5

View file

@ -16,6 +16,10 @@ note: this value implements `FnOnce`, which causes it to be moved when called
| |
LL | debug_dump_dict(); LL | debug_dump_dict();
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^
help: consider cloning the value if the performance cost is acceptable
|
LL | debug_dump_dict.clone()();
| ++++++++
error: aborting due to previous error error: aborting due to previous error

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; 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) = 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 error: aborting due to previous error

View file

@ -7,6 +7,11 @@ LL | let _bar = foo;
| --- value moved here | --- value moved here
LL | let _baz = [foo; 0]; LL | let _baz = [foo; 0];
| ^^^ value used here after move | ^^^ 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 error[E0493]: destructor of `String` cannot be evaluated at compile-time
--> $DIR/repeat-drop-2.rs:7:25 --> $DIR/repeat-drop-2.rs:7:25

View file

@ -9,6 +9,11 @@ LL | 0 if { drop(s); false } => String::from("oops"),
... ...
LL | s LL | s
| ^ value used here after move | ^ 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 error: aborting due to previous error

View file

@ -10,6 +10,10 @@ LL | println!("{}", s);
| ^ value borrowed here after move | ^ 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) = 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 error: aborting due to previous error

View file

@ -14,6 +14,10 @@ note: this function takes ownership of the receiver `self`, which moves `bad_let
| |
LL | fn into_iter(self) -> Self::IntoIter; LL | fn into_iter(self) -> Self::IntoIter;
| ^^^^ | ^^^^
help: consider cloning the value if the performance cost is acceptable
|
LL | for l in bad_letters.clone() {
| ++++++++
help: consider iterating over a slice of the `Vec<char>`'s content to avoid moving into the `for` loop help: consider iterating over a slice of the `Vec<char>`'s content to avoid moving into the `for` loop
| |
LL | for l in &bad_letters { LL | for l in &bad_letters {

View file

@ -15,6 +15,10 @@ note: this function takes ownership of the receiver `self`, which moves `orig`
| |
LL | fn into_iter(self) -> Self::IntoIter; LL | fn into_iter(self) -> Self::IntoIter;
| ^^^^ | ^^^^
help: consider cloning the value if the performance cost is acceptable
|
LL | for _val in orig.clone() {}
| ++++++++
help: consider iterating over a slice of the `Vec<bool>`'s content to avoid moving into the `for` loop help: consider iterating over a slice of the `Vec<bool>`'s content to avoid moving into the `for` loop
| |
LL | for _val in &orig {} LL | for _val in &orig {}

View file

@ -3,9 +3,23 @@ error[E0382]: use of moved value: `x`
| |
LL | let x: Box<isize> = Box::new(25); LL | let x: Box<isize> = Box::new(25);
| - move occurs because `x` has type `Box<isize>`, which does not implement the `Copy` trait | - 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); LL | take(x);
| ^ value moved here, in previous iteration of loop | ^ value moved here, in previous iteration of loop
|
note: consider changing this parameter type in `take` to borrow instead if ownering the value isn't necessary
--> $DIR/liveness-move-call-arg.rs:1:13
|
LL | fn take(_x: Box<isize>) {}
| ---- ^^^^^^^^^^ this type 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 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(); LL | let y: Box<isize> = 42.into();
| - move occurs because `y` has type `Box<isize>`, which does not implement the `Copy` trait | - 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; LL | x = y;
| ^ value moved here, in previous iteration of loop | ^ 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 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(); LL | let y: Box<isize> = 42.into();
| - move occurs because `y` has type `Box<isize>`, which does not implement the `Copy` trait | - 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 | println!("{}", y);
| ^ value borrowed here after move | ^ value borrowed here after move
LL | while true { while true { while true { x = y; x.clone(); } } } 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) = 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 error: aborting due to previous error; 3 warnings emitted

View file

@ -10,6 +10,10 @@ LL | println!("{}", *x);
| ^^ value borrowed here after move | ^^ 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) = 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 error: aborting due to previous error

View file

@ -8,7 +8,16 @@ LL | send(ch, message);
LL | println!("{}", message); LL | println!("{}", message);
| ^^^^^^^ value borrowed here after move | ^^^^^^^ value borrowed here after move
| |
note: consider changing this parameter type in `send` to borrow instead if ownering 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 type 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) = 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 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()) { LL | fn takes_fn(f: impl Fn()) {
| - move occurs because `f` has type `impl Fn()`, which does not implement the `Copy` trait | - move occurs because `f` has type `impl Fn()`, which does not implement the `Copy` trait
LL | loop { LL | loop {
| ---- inside of this loop
LL | takes_fnonce(f); LL | takes_fnonce(f);
| ^ value moved here, in previous iteration of loop | ^ value moved here, in previous iteration of loop
| |
note: consider changing this parameter type in `takes_fnonce` to borrow instead if ownering the value isn't necessary
--> $DIR/borrow-closures-instead-of-move.rs:34:20
|
LL | fn takes_fnonce(_: impl FnOnce()) {}
| ------------ ^^^^^^^^^^^^^ this type parameter takes ownership of the value
| |
| in this function
help: consider borrowing `f` help: consider borrowing `f`
| |
LL | takes_fnonce(&f); LL | takes_fnonce(&f);
@ -24,6 +32,13 @@ LL | takes_fnonce(m);
LL | takes_fnonce(m); LL | takes_fnonce(m);
| ^ value used here after move | ^ value used here after move
| |
note: consider changing this parameter type in `takes_fnonce` to borrow instead if ownering the value isn't necessary
--> $DIR/borrow-closures-instead-of-move.rs:34:20
|
LL | fn takes_fnonce(_: impl FnOnce()) {}
| ------------ ^^^^^^^^^^^^^ this type parameter takes ownership of the value
| |
| in this function
help: consider mutably borrowing `m` help: consider mutably borrowing `m`
| |
LL | takes_fnonce(&mut m); LL | takes_fnonce(&mut m);
@ -43,6 +58,13 @@ note: closure cannot be moved more than once as it is not `Copy` due to moving t
| |
LL | x += 1; LL | x += 1;
| ^ | ^
note: consider changing this parameter type in `takes_fnonce` to borrow instead if ownering the value isn't necessary
--> $DIR/borrow-closures-instead-of-move.rs:34:20
|
LL | fn takes_fnonce(_: impl FnOnce()) {}
| ------------ ^^^^^^^^^^^^^ this type parameter takes ownership of the value
| |
| in this function
help: consider mutably borrowing `closure` help: consider mutably borrowing `closure`
| |
LL | takes_fnonce(&mut closure); LL | takes_fnonce(&mut closure);

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 | - move occurs because `b` has type `Box<bool>`, which does not implement the `Copy` trait
LL | test!({b}); LL | test!({b});
| ^ value used here after move | ^ 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 error: aborting due to previous error

View file

@ -25,7 +25,7 @@ fn moved_here_1() {
fn moved_here_2() { fn moved_here_2() {
let value = NonCopy{}; let value = NonCopy{};
//~^ NOTE move occurs because `value` has type `NonCopy`, which does not implement the `Copy` trait //~^ 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; let _used = value;
//~^ NOTE value moved here //~^ NOTE value moved here
loop { loop {
@ -38,7 +38,7 @@ fn moved_here_2() {
fn moved_loop_1() { fn moved_loop_1() {
let value = NonCopy{}; let value = NonCopy{};
//~^ NOTE move occurs because `value` has type `NonCopy`, which does not implement the `Copy` trait //~^ 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` let _used = value; //~ ERROR use of moved value: `value`
//~^ NOTE value moved here, in previous iteration of loop //~^ 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 //~^ NOTE move occurs because `value` has type `NonCopy`, which does not implement the `Copy` trait
let _used = value; let _used = value;
value = NonCopy{}; value = NonCopy{};
loop { loop { //~ NOTE inside of this loop
let _used2 = value; //~ ERROR use of moved value: `value` let _used2 = value; //~ ERROR use of moved value: `value`
//~^ NOTE value moved here, in previous iteration of loop //~^ 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{}; LL | let value = NonCopy{};
| ----- move occurs because `value` has type `NonCopy`, which does not implement the `Copy` trait | ----- 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; LL | let _used = value;
| ----- value moved here | ----- value moved here
... ...
@ -27,7 +29,9 @@ error[E0382]: use of moved value: `value`
| |
LL | let value = NonCopy{}; LL | let value = NonCopy{};
| ----- move occurs because `value` has type `NonCopy`, which does not implement the `Copy` trait | ----- 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; LL | let _used = value;
| ^^^^^ value moved here, in previous iteration of loop | ^^^^^ value moved here, in previous iteration of loop
@ -37,6 +41,8 @@ error[E0382]: use of moved value: `value`
LL | let mut value = NonCopy{}; LL | let mut value = NonCopy{};
| --------- move occurs because `value` has type `NonCopy`, which does not implement the `Copy` trait | --------- move occurs because `value` has type `NonCopy`, which does not implement the `Copy` trait
... ...
LL | loop {
| ---- inside of this loop
LL | let _used2 = value; LL | let _used2 = value;
| ^^^^^ value moved here, in previous iteration of loop | ^^^^^ 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>) {} 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` error[E0382]: use of moved value: `foo_add`
--> $DIR/move-fn-self-receiver.rs:59:5 --> $DIR/move-fn-self-receiver.rs:59:5
@ -123,6 +127,10 @@ LL | for _val in implicit_into_iter {}
LL | implicit_into_iter; LL | implicit_into_iter;
| ^^^^^^^^^^^^^^^^^^ value used here after move | ^^^^^^^^^^^^^^^^^^ value used here after move
| |
help: consider cloning the value if the performance cost is acceptable
|
LL | for _val in implicit_into_iter.clone() {}
| ++++++++
help: consider iterating over a slice of the `Vec<bool>`'s content to avoid moving into the `for` loop help: consider iterating over a slice of the `Vec<bool>`'s content to avoid moving into the `for` loop
| |
LL | for _val in &implicit_into_iter {} LL | for _val in &implicit_into_iter {}
@ -137,6 +145,11 @@ LL | for _val in explicit_into_iter.into_iter() {}
| ----------- `explicit_into_iter` moved due to this method call | ----------- `explicit_into_iter` moved due to this method call
LL | explicit_into_iter; LL | explicit_into_iter;
| ^^^^^^^^^^^^^^^^^^ value used here after move | ^^^^^^^^^^^^^^^^^^ 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` error[E0382]: use of moved value: `container`
--> $DIR/move-fn-self-receiver.rs:71:5 --> $DIR/move-fn-self-receiver.rs:71:5
@ -160,6 +173,7 @@ error[E0382]: use of moved value: `foo2`
LL | let foo2 = Foo; LL | let foo2 = Foo;
| ---- move occurs because `foo2` has type `Foo`, which does not implement the `Copy` trait | ---- move occurs because `foo2` has type `Foo`, which does not implement the `Copy` trait
LL | loop { LL | loop {
| ---- inside of this loop
LL | foo2.use_self(); LL | foo2.use_self();
| ^^^^ ---------- `foo2` moved due to this method call, in previous iteration of loop | ^^^^ ---------- `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 | - value moved here
LL | (1, 2) if take(x) => (), LL | (1, 2) if take(x) => (),
| ^ value used here after move | ^ value used here after move
|
note: consider changing this parameter type in `take` to borrow instead if ownering the value isn't necessary
--> $DIR/move-guard-same-consts.rs:25:15
|
LL | fn take<T>(_: T) -> bool { false }
| ---- ^ this type 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 error: aborting due to previous error

View file

@ -8,6 +8,18 @@ LL | (1, _) if take(x) => (),
| - value moved here | - value moved here
LL | (_, 2) if take(x) => (), LL | (_, 2) if take(x) => (),
| ^ value used here after move | ^ value used here after move
|
note: consider changing this parameter type in `take` to borrow instead if ownering the value isn't necessary
--> $DIR/move-in-guard-1.rs:15:15
|
LL | fn take<T>(_: T) -> bool { false }
| ---- ^ this type 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 error: aborting due to previous error

View file

@ -6,6 +6,18 @@ LL | let x: Box<_> = Box::new(1);
... ...
LL | (_, 2) if take(x) => (), LL | (_, 2) if take(x) => (),
| ^ value used here after move | ^ value used here after move
|
note: consider changing this parameter type in `take` to borrow instead if ownering the value isn't necessary
--> $DIR/move-in-guard-2.rs:13:15
|
LL | fn take<T>(_: T) -> bool { false }
| ---- ^ this type 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 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; 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 error: aborting due to previous error

View file

@ -8,7 +8,7 @@ LL | consume(node) + r
| ^^^^ value used here after partial move | ^^^^ value used here after partial move
| |
= note: partial move occurs because value has type `Box<List>`, which does not implement the `Copy` trait = 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), LL | Some(ref right) => consume(right),
| +++ | +++

View file

@ -9,6 +9,11 @@ LL | let _y = Foo { f:x };
LL | LL |
LL | touch(&x); LL | touch(&x);
| ^^ value borrowed here after move | ^^ 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` error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-distribute-copy-over-paren.rs:21:11 --> $DIR/moves-based-on-type-distribute-copy-over-paren.rs:21:11
@ -21,6 +26,11 @@ LL | let _y = Foo { f:(((x))) };
LL | LL |
LL | touch(&x); LL | touch(&x);
| ^^ value borrowed here after move | ^^ 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 error: aborting due to 2 previous errors

View file

@ -7,6 +7,11 @@ LL | let _y = Foo { f:x };
| - value moved here | - value moved here
LL | touch(&x); LL | touch(&x);
| ^^ value borrowed here after move | ^^ 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` error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:18:11 --> $DIR/moves-based-on-type-exprs.rs:18:11
@ -17,6 +22,11 @@ LL | let _y = (x, 3);
| - value moved here | - value moved here
LL | touch(&x); LL | touch(&x);
| ^^ value borrowed here after move | ^^ 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` error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:35:11 --> $DIR/moves-based-on-type-exprs.rs:35:11
@ -29,6 +39,11 @@ LL | x
... ...
LL | touch(&x); LL | touch(&x);
| ^^ value borrowed here after move | ^^ 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` error[E0382]: borrow of moved value: `y`
--> $DIR/moves-based-on-type-exprs.rs:36:11 --> $DIR/moves-based-on-type-exprs.rs:36:11
@ -41,6 +56,11 @@ LL | y
... ...
LL | touch(&y); LL | touch(&y);
| ^^ value borrowed here after move | ^^ 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` error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:46:11 --> $DIR/moves-based-on-type-exprs.rs:46:11
@ -53,6 +73,11 @@ LL | true => x,
... ...
LL | touch(&x); LL | touch(&x);
| ^^ value borrowed here after move | ^^ 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` error[E0382]: borrow of moved value: `y`
--> $DIR/moves-based-on-type-exprs.rs:47:11 --> $DIR/moves-based-on-type-exprs.rs:47:11
@ -65,6 +90,11 @@ LL | false => y
... ...
LL | touch(&y); LL | touch(&y);
| ^^ value borrowed here after move | ^^ 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` error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:58:11 --> $DIR/moves-based-on-type-exprs.rs:58:11
@ -77,6 +107,18 @@ LL | _ if guard(x) => 10,
... ...
LL | touch(&x); LL | touch(&x);
| ^^ value borrowed here after move | ^^ value borrowed here after move
|
note: consider changing this parameter type in `guard` to borrow instead if ownering the value isn't necessary
--> $DIR/moves-based-on-type-exprs.rs:6:14
|
LL | fn guard(_s: String) -> bool {panic!()}
| ----- ^^^^^^ this type 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` error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:65:11 --> $DIR/moves-based-on-type-exprs.rs:65:11
@ -87,6 +129,11 @@ LL | let _y = [x];
| - value moved here | - value moved here
LL | touch(&x); LL | touch(&x);
| ^^ value borrowed here after move | ^^ 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` error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:71:11 --> $DIR/moves-based-on-type-exprs.rs:71:11
@ -97,6 +144,11 @@ LL | let _y = vec![x];
| - value moved here | - value moved here
LL | touch(&x); LL | touch(&x);
| ^^ value borrowed here after move | ^^ 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` error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:77:11 --> $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; 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` error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:83:11 --> $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; 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 error: aborting due to 11 previous errors

View file

@ -8,6 +8,10 @@ LL | touch(&x);
| ^^ value borrowed here after partial move | ^^ value borrowed here after partial move
| |
= note: partial move occurs because `x.f` has type `String`, which does not implement the `Copy` trait = 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 error: aborting due to previous error

View file

@ -8,6 +8,11 @@ LL | Box::new((x, x))
| - ^ value used here after move | - ^ value used here after move
| | | |
| value moved here | 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 error: aborting due to previous error

View file

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

View file

@ -67,6 +67,11 @@ LL | || x.len();
| ^^ - borrow occurs due to use in closure | ^^ - borrow occurs due to use in closure
| | | |
| value borrowed here after move | 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` error[E0382]: borrow of moved value: `x`
--> $DIR/closure-access-spans.rs:40:5 --> $DIR/closure-access-spans.rs:40:5
@ -79,6 +84,11 @@ LL | || x = String::new();
| ^^ - borrow occurs due to use in closure | ^^ - borrow occurs due to use in closure
| | | |
| value borrowed here after move | 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` error[E0382]: borrow of moved value: `x`
--> $DIR/closure-access-spans.rs:45:5 --> $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 | 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); LL | t.0 = 10; t.1 = Box::new(20);
| ^^^^^^^^ value partially assigned here after move | ^^^^^^^^ 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 error[E0381]: partially assigned binding `s` isn't fully initialized
--> $DIR/issue-21232-partial-init-and-use.rs:123:5 --> $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 | move occurs because `t` has type `(u32, Box<u32>)`, which does not implement the `Copy` trait
LL | t.0 = 10; LL | t.0 = 10;
| ^^^^^^^^ value partially assigned here after move | ^^^^^^^^ 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 error[E0381]: partially assigned binding `s` isn't fully initialized
--> $DIR/issue-21232-partial-init-and-use.rs:149:5 --> $DIR/issue-21232-partial-init-and-use.rs:149:5
@ -208,6 +218,11 @@ LL | c2 => {
| -- value moved here | -- value moved here
LL | c.0 = 2; LL | c.0 = 2;
| ^^^^^^^ value partially assigned here after move | ^^^^^^^ 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` error[E0382]: assign to part of moved value: `c`
--> $DIR/issue-21232-partial-init-and-use.rs:255:13 --> $DIR/issue-21232-partial-init-and-use.rs:255:13
@ -219,6 +234,11 @@ LL | c2 => {
| -- value moved here | -- value moved here
LL | (c.1).0 = 2; LL | (c.1).0 = 2;
| ^^^^^^^^^^^ value partially assigned here after move | ^^^^^^^^^^^ 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` error[E0382]: assign to part of moved value: `c.1`
--> $DIR/issue-21232-partial-init-and-use.rs:263:13 --> $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 | ^^^^^^^^^^^^^^^ value partially assigned here after move
| |
= note: move occurs because `c.1` has type `(i32, (i32, String))`, which does not implement the `Copy` trait = 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 error: aborting due to 23 previous errors

View file

@ -7,6 +7,11 @@ LL | let r = range;
| ----- value moved here | ----- value moved here
LL | let x = range.start; LL | let x = range.start;
| ^^^^^^^^^^^ value used here after move | ^^^^^^^^^^^ 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 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 | ^^^^^ value moved here, in previous iteration of loop
| |
= note: move occurs because value has type `Vec<bool>`, which does not implement the `Copy` trait = 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 { LL | if let Some(ref thing) = maybe {
| +++ | +++

View file

@ -26,6 +26,11 @@ LL | false if { drop(x); true } => 1,
LL | true => { LL | true => {
LL | x; LL | x;
| ^ value used here after move | ^ 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 error: aborting due to 2 previous errors

View file

@ -7,6 +7,11 @@ LL | let y = x;
| - value moved here | - value moved here
LL | x; LL | x;
| ^ value used here after move | ^ 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` error[E0382]: use of moved value: `x`
--> $DIR/ref-suggestion.rs:8:5 --> $DIR/ref-suggestion.rs:8:5
@ -17,6 +22,11 @@ LL | let mut y = x;
| - value moved here | - value moved here
LL | x; LL | x;
| ^ value used here after move | ^ 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` error[E0382]: use of partially moved value: `x`
--> $DIR/ref-suggestion.rs:16:5 --> $DIR/ref-suggestion.rs:16:5
@ -28,7 +38,7 @@ LL | x;
| ^ value used here after partial move | ^ value used here after partial move
| |
= note: partial move occurs because value has type `Vec<i32>`, which does not implement the `Copy` trait = 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), ()) => {}, LL | (Some(ref y), ()) => {},
| +++ | +++

View file

@ -45,7 +45,7 @@ LL | Some(ref _y @ _z) => {}
| value borrowed here after move | value borrowed here after move
| |
= note: move occurs because value has type `X`, which does not implement the `Copy` trait = 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) => {} LL | Some(ref _y @ ref _z) => {}
| +++ | +++
@ -59,7 +59,7 @@ LL | Some(ref mut _y @ _z) => {}
| value borrowed here after move | value borrowed here after move
| |
= note: move occurs because value has type `X`, which does not implement the `Copy` trait = 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) => {} LL | Some(ref mut _y @ ref _z) => {}
| +++ | +++

View file

@ -6,6 +6,11 @@ LL | let a @ b = U;
| | | | | |
| | value moved here | | value moved here
| value used here after move | value used here after move
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let a @ ref b = U;
| +++
error[E0382]: use of partially moved value error[E0382]: use of partially moved value
--> $DIR/borrowck-move-and-move.rs:13:9 --> $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 | value used here after partial move
| |
= note: partial move occurs because value has type `U`, which does not implement the `Copy` trait = 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 a @ (b, ref c) = (U, U);
| +++
error[E0382]: use of partially moved value error[E0382]: use of partially moved value
--> $DIR/borrowck-move-and-move.rs:15:9 --> $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 | value used here after partial move
| |
= note: partial move occurs because value has type `U`, which does not implement the `Copy` trait = 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 a @ (b, ref c) = (u(), u());
| +++
error[E0382]: use of moved value error[E0382]: use of moved value
--> $DIR/borrowck-move-and-move.rs:18:16 --> $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 used here after move
| | | |
| value moved here | 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 error[E0382]: use of moved value
--> $DIR/borrowck-move-and-move.rs:18:29 --> $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 used here after move
| | | |
| value moved here | 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 error[E0382]: use of partially moved value
--> $DIR/borrowck-move-and-move.rs:25:9 --> $DIR/borrowck-move-and-move.rs:25:9
@ -56,6 +79,10 @@ LL | xs @ [a, .., b] => {}
| value used here after partial move | value used here after partial move
| |
= note: partial move occurs because value has type `U`, which does not implement the `Copy` trait = 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 | xs @ [a, .., ref b] => {}
| +++
error[E0382]: use of partially moved value error[E0382]: use of partially moved value
--> $DIR/borrowck-move-and-move.rs:29:9 --> $DIR/borrowck-move-and-move.rs:29:9
@ -66,6 +93,10 @@ LL | xs @ [_, ys @ .., _] => {}
| value used here after partial move | value used here after partial move
| |
= note: partial move occurs because value has type `U`, which does not implement the `Copy` trait = 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 | xs @ [_, ref ys @ .., _] => {}
| +++
error[E0382]: use of moved value error[E0382]: use of moved value
--> $DIR/borrowck-move-and-move.rs:22:12 --> $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 | value borrowed here after move
| |
= note: move occurs because value has type `NC`, which does not implement the `Copy` trait = 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 error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable
--> $DIR/borrowck-pat-at-and-box.rs:38:9 --> $DIR/borrowck-pat-at-and-box.rs:38:9

View file

@ -267,6 +267,10 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U);
| value used here after partial move | value used here after partial move
| |
= note: partial move occurs because value has type `U`, which does not implement the `Copy` trait = 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 a @ (mut b @ ref mut c, ref d @ ref e) = (U, U);
| +++
error[E0382]: use of partially moved value error[E0382]: use of partially moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:33:9 --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:33:9
@ -277,6 +281,10 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u());
| value used here after partial move | value used here after partial move
| |
= note: partial move occurs because value has type `U`, which does not implement the `Copy` trait = 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 a @ (mut b @ ref mut c, ref d @ ref e) = (u(), u());
| +++
error[E0382]: use of moved value error[E0382]: use of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:47:38 --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:47:38
@ -285,6 +293,11 @@ LL | match Some((U, U)) {
| ------------ move occurs because value has type `Option<(U, U)>`, which does not implement the `Copy` trait | ------------ 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)) => {} LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {}
| - value moved here ^ value used here after move | - 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 error[E0382]: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:55:30 --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:55:30
@ -305,6 +318,11 @@ LL | a @ Some(ref b) => {}
| - ^^^^^ value borrowed here after move | - ^^^^^ value borrowed here after move
| | | |
| value moved here | 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 error[E0382]: use of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:67:38 --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:67:38
@ -313,6 +331,11 @@ LL | match Some((u(), u())) {
| ---------------- move occurs because value has type `Option<(U, U)>`, which does not implement the `Copy` trait | ---------------- 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)) => {} LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {}
| - value moved here ^ value used here after move | - 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 error[E0382]: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:75:30 --> $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 | value borrowed here after partial move
| |
= note: partial move occurs because value has type `U`, which does not implement the `Copy` trait = 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 error[E0382]: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref.rs:33:9 --> $DIR/borrowck-pat-by-move-and-ref.rs:33:9
@ -251,6 +255,11 @@ LL | let ref a @ b = u();
| | | | | |
| | value moved here | | value moved here
| value borrowed here after move | 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 error[E0382]: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref.rs:36:18 --> $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 | value borrowed here after move
| |
= note: move occurs because value has type `U`, which does not implement the `Copy` trait = 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 error[E0382]: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref.rs:36:33 --> $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 | value borrowed here after move
| |
= note: move occurs because value has type `U`, which does not implement the `Copy` trait = 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 error[E0382]: borrow of partially moved value
--> $DIR/borrowck-pat-by-move-and-ref.rs:42:9 --> $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 | value borrowed here after partial move
| |
= note: partial move occurs because value has type `U`, which does not implement the `Copy` trait = 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 error[E0382]: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref.rs:69:23 --> $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 | value borrowed here after move
| |
= note: move occurs because value has type `U`, which does not implement the `Copy` trait = 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)) => {} 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 | value borrowed here after move
| |
= note: move occurs because value has type `U`, which does not implement the `Copy` trait = 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)) => {} LL | ref a @ Some((ref b @ mut c, ref d @ ref e)) => {}
| +++ | +++

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 | value used here after partial move
| |
= note: partial move occurs because value has type `NC<C, C>`, which does not implement the `Copy` trait = 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 a @ NC(b, ref c @ NC(d, e)) = NC(C, NC(C, C));
| +++
error: aborting due to previous error error: aborting due to previous error

View file

@ -52,6 +52,11 @@ LL | let ref mut a @ b = NotCopy;
| | | | | |
| | value moved here | | value moved here
| value borrowed here after move | 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 error: aborting due to 6 previous errors

View file

@ -129,6 +129,10 @@ LL | drop(tup.1);
| ^^^^^ value used here after move | ^^^^^ value used here after move
| |
= note: move occurs because `tup.1` has type `U`, which does not implement the `Copy` trait = 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` error[E0382]: borrow of moved value: `tup.1`
--> $DIR/borrowck-move-ref-pattern.rs:29:20 --> $DIR/borrowck-move-ref-pattern.rs:29:20

View file

@ -7,6 +7,12 @@ LL | let _ = dbg!(a);
| ------- value moved here | ------- value moved here
LL | let _ = dbg!(a); LL | let _ = dbg!(a);
| ^ value used here after move | ^ 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 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]; LL | let a = vec![1, 2, 3];
| - move occurs because `a` has type `Vec<i32>`, which does not implement the `Copy` trait | - move occurs because `a` has type `Vec<i32>`, which does not implement the `Copy` trait
LL | for i in &a { LL | for i in &a {
| ----------- inside of this loop
LL | for j in a { LL | for j in a {
| ^ `a` moved due to this implicit call to `.into_iter()`, in previous iteration of loop | ^ `a` moved due to this implicit call to `.into_iter()`, in previous iteration of loop
| |
@ -20,6 +21,10 @@ note: this function takes ownership of the receiver `self`, which moves `a`
| |
LL | fn into_iter(self) -> Self::IntoIter; LL | fn into_iter(self) -> Self::IntoIter;
| ^^^^ | ^^^^
help: consider cloning the value if the performance cost is acceptable
|
LL | for j in a.clone() {
| ++++++++
help: consider iterating over a slice of the `Vec<i32>`'s content to avoid moving into the `for` loop help: consider iterating over a slice of the `Vec<i32>`'s content to avoid moving into the `for` loop
| |
LL | for j in &a { LL | for j in &a {

View file

@ -23,6 +23,10 @@ LL | println!("{}", x);
| ^ value borrowed here after move | ^ 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) = 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 error[E0506]: cannot assign to `i` because it is borrowed
--> $DIR/try-block-maybe-bad-lifetime.rs:40:9 --> $DIR/try-block-maybe-bad-lifetime.rs:40:9

View file

@ -16,6 +16,10 @@ note: this value implements `FnOnce`, which causes it to be moved when called
| |
LL | tick(); LL | tick();
| ^^^^ | ^^^^
help: consider cloning the value if the performance cost is acceptable
|
LL | tick.clone()();
| ++++++++
error: aborting due to previous error error: aborting due to previous error

View file

@ -16,6 +16,10 @@ note: this value implements `FnOnce`, which causes it to be moved when called
| |
LL | tick(); LL | tick();
| ^^^^ | ^^^^
help: consider cloning the value if the performance cost is acceptable
|
LL | tick.clone()();
| ++++++++
error: aborting due to previous error error: aborting due to previous error

View file

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

View file

@ -8,6 +8,14 @@ LL | move_out(x.f1_nocopy);
| ----------- value moved here | ----------- value moved here
LL | move_out(x.f2_nocopy); LL | move_out(x.f2_nocopy);
| ^^^^^^^^^^^ value used here after move | ^^^^^^^^^^^ value used here after move
|
note: consider changing this parameter type in `move_out` to borrow instead if ownering the value isn't necessary
--> $DIR/union-move.rs:10:19
|
LL | fn move_out<T>(x: T) {}
| -------- ^ this type parameter takes ownership of the value
| |
| in this function
error[E0382]: use of moved value: `x` error[E0382]: use of moved value: `x`
--> $DIR/union-move.rs:45:18 --> $DIR/union-move.rs:45:18
@ -19,6 +27,14 @@ LL | move_out(x.f2_nocopy);
| ----------- value moved here | ----------- value moved here
LL | move_out(x.f3_copy); LL | move_out(x.f3_copy);
| ^^^^^^^^^ value used here after move | ^^^^^^^^^ value used here after move
|
note: consider changing this parameter type in `move_out` to borrow instead if ownering the value isn't necessary
--> $DIR/union-move.rs:10:19
|
LL | fn move_out<T>(x: T) {}
| -------- ^ this type parameter takes ownership of the value
| |
| in this function
error[E0509]: cannot move out of type `U2`, which implements the `Drop` trait error[E0509]: cannot move out of type `U2`, which implements the `Drop` trait
--> $DIR/union-move.rs:52:18 --> $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; 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 help: consider further restricting this bound
| |
LL | fn move_then_borrow<T: Not<Output=T> + Clone + Copy>(x: T) { 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); LL | println!("{}", &y);
| ^^ value borrowed here after move | ^^ value borrowed here after move
|
note: consider changing this parameter type in `drop_unsized` to borrow instead if ownering the value isn't necessary
--> $DIR/borrow-after-move.rs:14:31
|
LL | fn drop_unsized<T: ?Sized>(_: T) {}
| ------------ ^ this type parameter takes ownership of the value
| |
| in this function
error[E0382]: borrow of moved value: `x` error[E0382]: borrow of moved value: `x`
--> $DIR/borrow-after-move.rs:31:24 --> $DIR/borrow-after-move.rs:31:24
@ -66,6 +74,11 @@ LL | x.foo();
| - value moved here | - value moved here
LL | println!("{}", &x); LL | println!("{}", &x);
| ^^ value borrowed here after move | ^^ 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 error: aborting due to 5 previous errors; 1 warning emitted

View file

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

View file

@ -9,6 +9,10 @@ LL | println!("{}", x);
| ^ value borrowed here after move | ^ 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) = 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 error: aborting due to previous error

View file

@ -9,6 +9,14 @@ LL | l.push(n);
LL | LL |
LL | let x = n.to_string(); LL | let x = n.to_string();
| ^^^^^^^^^^^^^ value borrowed here after move | ^^^^^^^^^^^^^ value borrowed here after move
|
note: consider changing this parameter type in `push` to borrow instead if ownering 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 type parameter takes ownership of the value
| |
| in this method
error: aborting due to previous error error: aborting due to previous error