Skip to content

Suggestion for E0740 (union contains a field that needs dropping) doesn't change anything #90585

Closed
@PatchMixolydic

Description

@PatchMixolydic

Given the following code (playground):

union U {
    value: Vec<isize>,
}

The current output is:

error[E0740]: unions may not contain fields that need dropping
 --> src/lib.rs:2:5
  |
2 |     value: Vec<isize>,
  |     ^^^^^^^^^^^^^^^^^
  |
note: `std::mem::ManuallyDrop` can be used to wrap the type
 --> src/lib.rs:2:5
  |
2 |     value: Vec<isize>,
  |     ^^^^^^^^^^^^^^^^^

Ideally the output should look like:

error[E0740]: unions may not contain fields that need dropping
 --> src/lib.rs:2:5
  |
2 |     value: Vec<isize>,
  |     ^^^^^^^^^^^^^^^^^
  |
note: `std::mem::ManuallyDrop` can be used to wrap the type
 --> src/lib.rs:2:5
  |
2 |     value: std::mem::ManuallyDrop<Vec<isize>>,
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsD-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions