Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
PatchMixolydic opened this issue Nov 4, 2021 · 1 comment · Fixed by #90901
Labels
A-diagnostics Area: Messages for errors, warnings, and lints D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@PatchMixolydic
Copy link
Contributor

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>>,
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@PatchMixolydic PatchMixolydic added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 4, 2021
@PatchMixolydic
Copy link
Contributor Author

@rustbot modify labels: +D-invalid-suggestion

@rustbot rustbot added the D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. label Nov 4, 2021
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 17, 2021
…estebank

Improve ManuallyDrop suggestion

closes rust-lang#90585
* Fixes the recommended change to use ManuallyDrop as per the issue
* Changes the note to a help
* improves the span so it only points at the type.
@bors bors closed this as completed in 469faa2 Nov 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants