Skip to content

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

Closed

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>>,
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Activity

  1. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Nov 4, 2021
  2. PatchMixolydic commented on Nov 4, 2021

    @PatchMixolydic
    ContributorAuthor

    @rustbot modify labels: +D-invalid-suggestion

  3. added
    D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.
    on Nov 4, 2021
  4. added 2 commits that reference this issue on Nov 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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