Open
Description
The current error doesn't help users resolve the problem. Even just including a message that one should try borrowing the field by prepending a &
would be of help. I don't think it matters that this isn't possible for e.g. self.foo.consuming_method()
struct Foo {
v: Vec<u32>,
}
impl Foo {
fn bar(&self) {
for _ in self.v {
}
}
}
Errors:
Compiling playground v0.0.1 (/playground)
error[E0507]: cannot move out of `self.v` which is behind a shared reference
--> src/lib.rs:7:18
|
7 | for _ in self.v {
| ^^^^^^ move occurs because `self.v` has type `std::vec::Vec<u32>`, which does not implement the `Copy` trait
error: aborting due to previous error
For more information about this error, try `rustc --explain E0507`.
error: Could not compile `playground`.
To learn more, run the command again with --verbose.