mirror of
https://github.com/rust-lang/rust.git
synced 2025-09-28 13:46:03 +00:00

``` error[E0382]: borrow of moved value: `x` --> $DIR/moves-based-on-type-capture-clause-bad.rs:9:20 | LL | let x = "Hello world!".to_string(); | - move occurs because `x` has type `String`, which does not implement the `Copy` trait LL | thread::spawn(move || { | ------- value moved into closure here LL | println!("{}", x); | - variable moved due to use in closure LL | }); LL | println!("{}", x); | ^ value borrowed here after move | = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider cloning the value before moving it into the closure | LL ~ let value = x.clone(); LL ~ thread::spawn(move || { LL ~ println!("{}", value); | ```
25 lines
835 B
Plaintext
25 lines
835 B
Plaintext
error[E0382]: use of moved value: `t`
|
|
--> $DIR/borrowck-move-moved-value-into-closure.rs:11:12
|
|
|
|
|
LL | let t: Box<_> = Box::new(3);
|
|
| - move occurs because `t` has type `Box<isize>`, which does not implement the `Copy` trait
|
|
LL |
|
|
LL | call_f(move|| { *t + 1 });
|
|
| ------ -- variable moved due to use in closure
|
|
| |
|
|
| value moved into closure here
|
|
LL | call_f(move|| { *t + 1 });
|
|
| ^^^^^^ -- use occurs due to use in closure
|
|
| |
|
|
| value used here after move
|
|
|
|
|
help: consider cloning the value before moving it into the closure
|
|
|
|
|
LL ~ let value = t.clone();
|
|
LL ~ call_f(move|| { value + 1 });
|
|
|
|
|
|
|
error: aborting due to 1 previous error
|
|
|
|
For more information about this error, try `rustc --explain E0382`.
|