mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-04 12:44:40 +00:00
10c2fbec24
``` error[E0507]: cannot move out of `*x` which is behind a shared reference --> $DIR/borrowck-fn-in-const-a.rs:6:16 | LL | return *x | ^^ move occurs because `*x` has type `String`, which does not implement the `Copy` trait | help: consider cloning the value if the performance cost is acceptable | LL - return *x LL + return x.clone() | ```
16 lines
369 B
Rust
16 lines
369 B
Rust
//@ run-rustfix
|
|
// Test that a by-ref `FnMut` closure gets an error when it tries to
|
|
// consume a value.
|
|
|
|
fn call<F>(f: F) where F : Fn() {
|
|
f();
|
|
}
|
|
|
|
fn main() {
|
|
let y = vec![format!("World")];
|
|
call(|| {
|
|
<Vec<String> as Clone>::clone(&y.clone()).into_iter();
|
|
//~^ ERROR cannot move out of `y`, a captured variable in an `Fn` closure
|
|
});
|
|
}
|