Closed
Description
... and trying to use foo
afterwards, which triggers
error[E0382]: use of moved value:
foo
Example:
struct Bar;
impl AsRef<Bar> for Bar {
fn as_ref(&self) -> &Bar {
self
}
}
fn foo<T: AsRef<Bar>>(_: T) {}
pub fn main() {
let bar = Bar;
foo(bar);
let baa = bar;
}
currently yields
rustc 1.17.0 (56124baa9 2017-04-24)
error[E0382]: use of moved value: `bar`
--> <anon>:15:9
|
14 | foo(bar);
| --- value moved here
15 | let baa = bar;
| ^^^ value used here after move
|
= note: move occurs because `bar` has type `Bar`, which does not implement the `Copy` trait
error: aborting due to previous error
I suggest that it should also contain
help: if you meant to borrow `bar` use `foo(&bar)`?
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Suggestions generated by the compiler applied by `cargo fix`Category: An issue proposing an enhancement or a PR with one.Diagnostics: An error or lint that needs small tweaks.Relevant to the compiler team, which will review and decide on the PR/issue.