move_from,
..
} => {
- let try_remove_deref = match move_from {
- Place::Projection(box Projection {
- elem: ProjectionElem::Deref,
- ..
- }) => true,
- _ => false,
- };
- if try_remove_deref && snippet.starts_with('*') {
- // The snippet doesn't start with `*` in (e.g.) index
- // expressions `a[b]`, which roughly desugar to
- // `*Index::index(&a, b)` or
- // `*IndexMut::index_mut(&mut a, b)`.
- err.span_suggestion(
- span,
- "consider removing the `*`",
- snippet[1..].to_owned(),
- Applicability::Unspecified,
- );
- } else {
- err.span_suggestion(
- span,
- "consider borrowing here",
- format!("&{}", snippet),
- Applicability::Unspecified,
- );
- }
+ err.span_suggestion(
+ span,
+ "consider borrowing here",
+ format!("&{}", snippet),
+ Applicability::Unspecified,
+ );
if binds_to.is_empty() {
let place_ty = move_from.ty(self.mir, self.infcx.tcx).ty;
| | |
| | data moved here
| | move occurs because `v` has type `std::vec::Vec<isize>`, which does not implement the `Copy` trait
- | help: consider removing the `*`: `s`
+ | help: consider borrowing here: `&*s`
error: aborting due to previous error
| ^^
| |
| move occurs because `*y` has type `std::boxed::Box<i32>`, which does not implement the `Copy` trait
- | help: consider removing the `*`: `y`
+ | help: consider borrowing here: `&*y`
error: aborting due to previous error
--> $DIR/borrowck-move-error-with-note.rs:11:11
|
LL | match *f {
- | ^^ help: consider removing the `*`: `f`
+ | ^^ help: consider borrowing here: `&*f`
LL | Foo::Foo1(num1,
| ---- data moved here
LL | num2) => (),
| ^^
| |
| move occurs because `*x` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait
- | help: consider removing the `*`: `x`
+ | help: consider borrowing here: `&*x`
error: aborting due to previous error
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| move occurs because value has type `std::string::String`, which does not implement the `Copy` trait
- | help: consider removing the `*`: `Rc::new("hi".to_string())`
+ | help: consider borrowing here: `&*Rc::new("hi".to_string())`
error: aborting due to previous error
| ^^^^^^
| |
| move occurs because `*array` has type `std::vec::Vec<Value>`, which does not implement the `Copy` trait
- | help: consider removing the `*`: `array`
+ | help: consider borrowing here: `&*array`
error: aborting due to previous error
| ^^^^^^^^^^
| |
| move occurs because value has type `T`, which does not implement the `Copy` trait
- | help: consider removing the `*`: `mut_ref()`
+ | help: consider borrowing here: `&*mut_ref()`
error[E0507]: cannot move out of a shared reference
--> $DIR/issue-20801.rs:29:22
| ^^^^^^^^^^
| |
| move occurs because value has type `T`, which does not implement the `Copy` trait
- | help: consider removing the `*`: `imm_ref()`
+ | help: consider borrowing here: `&*imm_ref()`
error[E0507]: cannot move out of a raw pointer
--> $DIR/issue-20801.rs:32:22
| ^^^^^^^^^^
| |
| move occurs because value has type `T`, which does not implement the `Copy` trait
- | help: consider removing the `*`: `mut_ptr()`
+ | help: consider borrowing here: `&*mut_ptr()`
error[E0507]: cannot move out of a raw pointer
--> $DIR/issue-20801.rs:35:22
| ^^^^^^^^^^^^
| |
| move occurs because value has type `T`, which does not implement the `Copy` trait
- | help: consider removing the `*`: `const_ptr()`
+ | help: consider borrowing here: `&*const_ptr()`
error: aborting due to 4 previous errors
| ^^
| |
| move occurs because `*r` has type `std::string::String`, which does not implement the `Copy` trait
- | help: consider removing the `*`: `r`
+ | help: consider borrowing here: `&*r`
error[E0507]: cannot move out of `*r` which is behind a shared reference
--> $DIR/cannot-move-block-spans.rs:6:22
| ^^
| |
| move occurs because `*r` has type `std::string::String`, which does not implement the `Copy` trait
- | help: consider removing the `*`: `r`
+ | help: consider borrowing here: `&*r`
error[E0507]: cannot move out of `*r` which is behind a shared reference
--> $DIR/cannot-move-block-spans.rs:7:26
| ^^
| |
| move occurs because `*r` has type `std::string::String`, which does not implement the `Copy` trait
- | help: consider removing the `*`: `r`
+ | help: consider borrowing here: `&*r`
error[E0508]: cannot move out of type `[std::string::String; 2]`, a non-copy array
--> $DIR/cannot-move-block-spans.rs:11:15
| ^^
| |
| move occurs because `*r` has type `std::string::String`, which does not implement the `Copy` trait
- | help: consider removing the `*`: `r`
+ | help: consider borrowing here: `&*r`
error[E0507]: cannot move out of `*r` which is behind a shared reference
--> $DIR/cannot-move-block-spans.rs:18:45
| ^^
| |
| move occurs because `*r` has type `std::string::String`, which does not implement the `Copy` trait
- | help: consider removing the `*`: `r`
+ | help: consider borrowing here: `&*r`
error[E0507]: cannot move out of `*r` which is behind a shared reference
--> $DIR/cannot-move-block-spans.rs:19:49
| ^^
| |
| move occurs because `*r` has type `std::string::String`, which does not implement the `Copy` trait
- | help: consider removing the `*`: `r`
+ | help: consider borrowing here: `&*r`
error: aborting due to 9 previous errors
| ^^
| |
| move occurs because `*a` has type `A`, which does not implement the `Copy` trait
- | help: consider removing the `*`: `a`
+ | help: consider borrowing here: `&*a`
error[E0508]: cannot move out of type `[A; 1]`, a non-copy array
--> $DIR/move-errors.rs:12:13
| ^^^
| |
| move occurs because `**r` has type `A`, which does not implement the `Copy` trait
- | help: consider removing the `*`: `*r`
+ | help: consider borrowing here: `&**r`
error[E0507]: cannot move out of an `Rc`
--> $DIR/move-errors.rs:27:13
| ^^
| |
| move occurs because value has type `A`, which does not implement the `Copy` trait
- | help: consider removing the `*`: `r`
+ | help: consider borrowing here: `&*r`
error[E0508]: cannot move out of type `[A; 1]`, a non-copy array
--> $DIR/move-errors.rs:32:13
--> $DIR/move-errors.rs:38:16
|
LL | let A(s) = *a;
- | - ^^ help: consider removing the `*`: `a`
+ | - ^^ help: consider borrowing here: `&*a`
| |
| data moved here
| move occurs because `s` has type `std::string::String`, which does not implement the `Copy` trait
--> $DIR/move-errors.rs:110:11
|
LL | match *x {
- | ^^ help: consider removing the `*`: `x`
+ | ^^ help: consider borrowing here: `&*x`
LL |
LL | Ok(s) | Err(s) => (),
| -
| ^^^
| |
| move occurs because value has type `std::sync::atomic::AtomicBool`, which does not implement the `Copy` trait
- | help: consider removing the `*`: `&x`
+ | help: consider borrowing here: `&*&x`
error[E0507]: cannot move out of a shared reference
--> $DIR/std-uncopyable-atomics.rs:11:13
| ^^^
| |
| move occurs because value has type `std::sync::atomic::AtomicIsize`, which does not implement the `Copy` trait
- | help: consider removing the `*`: `&x`
+ | help: consider borrowing here: `&*&x`
error[E0507]: cannot move out of a shared reference
--> $DIR/std-uncopyable-atomics.rs:13:13
| ^^^
| |
| move occurs because value has type `std::sync::atomic::AtomicUsize`, which does not implement the `Copy` trait
- | help: consider removing the `*`: `&x`
+ | help: consider borrowing here: `&*&x`
error[E0507]: cannot move out of a shared reference
--> $DIR/std-uncopyable-atomics.rs:15:13
| ^^^
| |
| move occurs because value has type `std::sync::atomic::AtomicPtr<usize>`, which does not implement the `Copy` trait
- | help: consider removing the `*`: `&x`
+ | help: consider borrowing here: `&*&x`
error: aborting due to 4 previous errors
let X(_t) = *s;
//~^ ERROR cannot move
- //~| HELP consider removing the `*`
+ //~| HELP consider borrowing here
//~| SUGGESTION s
if let Either::One(_t) = *r { }
//~^ ERROR cannot move
- //~| HELP consider removing the `*`
+ //~| HELP consider borrowing here
//~| SUGGESTION r
while let Either::One(_t) = *r { }
//~^ ERROR cannot move
- //~| HELP consider removing the `*`
+ //~| HELP consider borrowing here
//~| SUGGESTION r
match *r {
//~^ ERROR cannot move
- //~| HELP consider removing the `*`
+ //~| HELP consider borrowing here
//~| SUGGESTION r
Either::One(_t)
| Either::Two(_t) => (),
}
match *r {
//~^ ERROR cannot move
- //~| HELP consider removing the `*`
+ //~| HELP consider borrowing here
//~| SUGGESTION r
Either::One(_t) => (),
Either::Two(ref _t) => (),
let X(_t) = *sm;
//~^ ERROR cannot move
- //~| HELP consider removing the `*`
+ //~| HELP consider borrowing here
//~| SUGGESTION sm
if let Either::One(_t) = *rm { }
//~^ ERROR cannot move
- //~| HELP consider removing the `*`
+ //~| HELP consider borrowing here
//~| SUGGESTION rm
while let Either::One(_t) = *rm { }
//~^ ERROR cannot move
- //~| HELP consider removing the `*`
+ //~| HELP consider borrowing here
//~| SUGGESTION rm
match *rm {
//~^ ERROR cannot move
- //~| HELP consider removing the `*`
+ //~| HELP consider borrowing here
//~| SUGGESTION rm
Either::One(_t)
| Either::Two(_t) => (),
}
match *rm {
//~^ ERROR cannot move
- //~| HELP consider removing the `*`
+ //~| HELP consider borrowing here
//~| SUGGESTION rm
Either::One(_t) => (),
Either::Two(ref _t) => (),
}
match *rm {
//~^ ERROR cannot move
- //~| HELP consider removing the `*`
+ //~| HELP consider borrowing here
//~| SUGGESTION rm
Either::One(_t) => (),
Either::Two(ref mut _t) => (),
--> $DIR/simple.rs:38:17
|
LL | let X(_t) = *s;
- | -- ^^ help: consider removing the `*`: `s`
+ | -- ^^ help: consider borrowing here: `&*s`
| |
| data moved here
| move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
--> $DIR/simple.rs:42:30
|
LL | if let Either::One(_t) = *r { }
- | -- ^^ help: consider removing the `*`: `r`
+ | -- ^^ help: consider borrowing here: `&*r`
| |
| data moved here
| move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:46:33
|
LL | while let Either::One(_t) = *r { }
- | -- ^^ help: consider removing the `*`: `r`
+ | -- ^^ help: consider borrowing here: `&*r`
| |
| data moved here
| move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:50:11
|
LL | match *r {
- | ^^ help: consider removing the `*`: `r`
+ | ^^ help: consider borrowing here: `&*r`
...
LL | Either::One(_t)
| --
--> $DIR/simple.rs:57:11
|
LL | match *r {
- | ^^ help: consider removing the `*`: `r`
+ | ^^ help: consider borrowing here: `&*r`
...
LL | Either::One(_t) => (),
| --
--> $DIR/simple.rs:66:17
|
LL | let X(_t) = *sm;
- | -- ^^^ help: consider removing the `*`: `sm`
+ | -- ^^^ help: consider borrowing here: `&*sm`
| |
| data moved here
| move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
--> $DIR/simple.rs:70:30
|
LL | if let Either::One(_t) = *rm { }
- | -- ^^^ help: consider removing the `*`: `rm`
+ | -- ^^^ help: consider borrowing here: `&*rm`
| |
| data moved here
| move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:74:33
|
LL | while let Either::One(_t) = *rm { }
- | -- ^^^ help: consider removing the `*`: `rm`
+ | -- ^^^ help: consider borrowing here: `&*rm`
| |
| data moved here
| move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:78:11
|
LL | match *rm {
- | ^^^ help: consider removing the `*`: `rm`
+ | ^^^ help: consider borrowing here: `&*rm`
...
LL | Either::One(_t)
| --
--> $DIR/simple.rs:85:11
|
LL | match *rm {
- | ^^^ help: consider removing the `*`: `rm`
+ | ^^^ help: consider borrowing here: `&*rm`
...
LL | Either::One(_t) => (),
| --
--> $DIR/simple.rs:93:11
|
LL | match *rm {
- | ^^^ help: consider removing the `*`: `rm`
+ | ^^^ help: consider borrowing here: `&*rm`
...
LL | Either::One(_t) => (),
| --