Skip to content

Unify labels pointing at the same span in move errors when possible #153506

@estebank

Description

@estebank

In tests/ui/moves/invalid-suggestions-destructuring-assignment-drop.stderr (and other cases) we currently output

error[E0509]: cannot move out of type `Thing`, which implements the `Drop` trait
  --> $DIR/invalid-suggestions-destructuring-assignment-drop.rs:12:34
   |
LL |     Thing(*&mut String::new()) = Thing(String::new());
   |           -------------------    ^^^^^^^^^^^^^^^^^^^^ cannot move out of here
   |           |
   |           data moved here
   |           move occurs because the place has type `String`, which does not implement the `Copy` trait

but ideally we should unify labels whenever possible. In this case, it should be

error[E0509]: cannot move out of type `Thing`, which implements the `Drop` trait
  --> $DIR/invalid-suggestions-destructuring-assignment-drop.rs:12:34
   |
LL |     Thing(*&mut String::new()) = Thing(String::new());
   |           -------------------    ^^^^^^^^^^^^^^^^^^^^ cannot move out of here
   |           |
   |           data moved here because the place has type `String`, which does not implement the `Copy` trait

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsD-verboseDiagnostics: Too much output caused by a single piece of incorrect code.P-lowLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions