Skip to content

Commit 36bb4e9

Browse files
committed
self review
1 parent 39131d4 commit 36bb4e9

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

0000-template.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Summary
77
[summary]: #summary
88

9-
Cleanup the rules for implicit drops by splitting `#[may_dangle]` into two separate attributes
9+
Cleanup the rules for implicit drops by splitting `#[may_dangle]` into two separate attributes:
1010
`#[only_dropped]` and `#[fully_ignored]`. Change `PhantomData` to get completely ignored
1111
by dropck as its current behavior is confusing and inconsistent.
1212

@@ -79,7 +79,7 @@ fn can_drop_dead_reference() {
7979
}
8080
```
8181
The above example will however fail if we add a manual `Drop` impl as the compiler conservatively
82-
assumes that all generic parameters of the `Drop` impl are considered used:
82+
assumes that all generic parameters of the `Drop` impl are used:
8383
[playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=e604bcaecb7b2b4cf7fd0440faf165ac).
8484

8585
In case a manual `Drop` impl does not access a generic parameter, you can add
@@ -116,8 +116,8 @@ fn can_drop_dead_reference() {
116116
}
117117
```
118118

119-
The ability to differentiate between `#[fully_unused]` and `#[only_dropped]` is especially useful
120-
for type parameters, consider the following simplified types from the standard library:
119+
The ability to differentiate between `#[fully_unused]` and `#[only_dropped]` is significant
120+
for type parameters:
121121

122122
```rust
123123
pub struct BTreeMap<K, V> {
@@ -155,13 +155,12 @@ When implicitly dropping a variable of type `T`, liveness requirements are compu
155155
- or they are marked with `#[only_dropped]`, in which case recurse into the generic argument.
156156
- Regardless of whether `T` implements `Drop`, recurse into all types *owned* by `T`:
157157
- references, raw pointers, function pointers, function items and scalars do not own
158-
anything. They are trivially drop.
158+
anything. They can be trivially dropped.
159159
- tuples and arrays consider their element types to be owned.
160160
- all fields (of all variants) of ADTs are considered owned. We consider all variants
161-
for enums. The only exception here is `ManuallyDrop<U>` which does not consider `U` to
162-
be owned. `PhantomData<U>` does not have any fields and therefore also does not consider
163-
`U` to be owned.
164-
- closures and generators consider their upvars to be owned.
161+
for enums. The only exception here is `ManuallyDrop<U>` which is not considered to own `U`. `PhantomData<U>` does not have any fields and therefore also does not consider
162+
`U` to be owned.
163+
- closures and generators own their captured upvars.
165164

166165
Checking drop impls may error for generic parameters which are known to be incorrectly marked:
167166
- `#[fully_unused]` parameters which are recursively owned
@@ -178,8 +177,8 @@ into types owned by `T` to figure out the correct constraints.
178177

179178
`PhantomData<U>` currently considers `U` to be owned while not having drop glue itself. This means
180179
that `(PhantomData<PrintOnDrop<'s>>, String)` requires `'s` to be live while
181-
`(PhantomData<PrintOnDrop<'s>>, u32)` does not. The current behavior is required for get the
182-
behavior of `#[only_dropped]` for unowned parameters by adding `PhantomData` as a field.
180+
`(PhantomData<PrintOnDrop<'s>>, u32)` does not. This is required for get the
181+
behavior of `#[only_dropped]` for parameters otherwise not owned by adding `PhantomData` as a field.
183182
One can easily forget this, which caused the [unsound](https://github.com/rust-lang/rust/issues/76367)
184183
[issues](https://github.com/rust-lang/rust/issues/99408) mentioned above.
185184

@@ -204,9 +203,9 @@ It is therefore quite important to improve the status quo.
204203

205204
A more general extension to deal with partially invalid types is far from trivial. We currently
206205
assume types to always be well-formed and any approach which generalizes `#[may_dangle]` will
207-
have huge consequences for how well-formedness is handled. This impacts many - often implicit -
206+
have major consequences for how well-formedness is handled. This impacts many - often implicit -
208207
interactions and assumptions. It is highly unlikely that we will have the capacity for any such change
209-
in the near future. The benefits from such are change are also likely to be fairly limited while
208+
in the near future. The benefits from such are change are likely to be fairly limited while
210209
adding significant complexity.
211210

212211
# Prior art

0 commit comments

Comments
 (0)