Skip to content

Commit

Permalink
Add non-#[may_dangle] mention to dropck mechanic
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhenrymantilla committed Aug 7, 2023
1 parent b372cea commit 8f6451a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/phantom-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ When a type already has a `Drop impl`, **adding an extra `_owns_T: PhantomData<T
is thus _superfluous_ and accomplishes nothing**, dropck-wise (it still affects variance
and auto-traits).

- (advanced edge case: if the type containing the `PhantomData` has no `Drop` impl at all,
but still has drop glue (by having _another_ field with drop glue), then the
dropck/`#[may_dangle]` considerations mentioned herein do apply as well: a `PhantomData<T>`
field will then require `T` to be droppable whenever the containing type goes out of scope).

___

But this situation can sometimes lead to overly restrictive code. That's why the
Expand Down

0 comments on commit 8f6451a

Please sign in to comment.