Skip to content

Suggest calling clone on moved values #42446

Closed
@Mark-Simulacrum

Description

@Mark-Simulacrum

We should add a help message indicating that calling clone where the value was moved is a good idea, but we should only do this when the value is cloneable.

fn main() {
    let a = String::new();
    a;
    a;
}
error[E0382]: use of moved value: `a`
 --> test.rs:4:5
  |
3 |     a;
  |     - value moved here
4 |     a;
  |     ^ value used here after move
  |
  = note: move occurs because `a` has type `std::string::String`, which does not implement the `Copy` trait

error: aborting due to previous error(s)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions