You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
121
121
122
122
```rust
123
123
pubstructBTreeMap<K, V> {
@@ -155,13 +155,12 @@ When implicitly dropping a variable of type `T`, liveness requirements are compu
155
155
- or they are marked with `#[only_dropped]`, in which case recurse into the generic argument.
156
156
- Regardless of whether `T` implements `Drop`, recurse into all types *owned* by `T`:
157
157
- 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.
159
159
- tuples and arrays consider their element types to be owned.
160
160
- 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.
165
164
166
165
Checking drop impls may error for generic parameters which are known to be incorrectly marked:
167
166
-`#[fully_unused]` parameters which are recursively owned
@@ -178,8 +177,8 @@ into types owned by `T` to figure out the correct constraints.
178
177
179
178
`PhantomData<U>` currently considers `U` to be owned while not having drop glue itself. This means
180
179
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.
183
182
One can easily forget this, which caused the [unsound](https://github.com/rust-lang/rust/issues/76367)
0 commit comments