Rollup merge of #62330 - SimonSapin:no-drop-in-union-fields, r=RalfJung
Change untagged_unions to not allow union fields with drop This is a rebase of #56440, massaged to solve merge conflicts and make the test suite pass. Change untagged_unions to not allow union fields with drop Union fields may now never have a type with attached destructor. This for example allows unions to use arbitrary field types only by wrapping them in `ManuallyDrop` (or similar). The stable rule remains, that union fields must be `Copy`. We use the new rule for the `untagged_union` feature. Tracking issue: https://github.com/rust-lang/rust/issues/55149
This commit is contained in:
commit
aba84894d1
40 changed files with 454 additions and 265 deletions
|
|
@ -596,30 +596,6 @@ warning: function cannot return without recursing
|
|||
|
|
||||
```
|
||||
|
||||
## unions-with-drop-fields
|
||||
|
||||
This lint detects use of unions that contain fields with possibly non-trivial drop code. Some
|
||||
example code that triggers this lint:
|
||||
|
||||
```rust
|
||||
#![feature(untagged_unions)]
|
||||
|
||||
union U {
|
||||
s: String,
|
||||
}
|
||||
```
|
||||
|
||||
This will produce:
|
||||
|
||||
```text
|
||||
warning: union contains a field with possibly non-trivial drop code, drop code of union fields is ignored when dropping the union
|
||||
--> src/main.rs:4:5
|
||||
|
|
||||
4 | s: String,
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
```
|
||||
|
||||
## unknown-lints
|
||||
|
||||
This lint detects unrecognized lint attribute. Some
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue