Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It still mentions the rare circumstances, so I don't think this fixes the issue. I don't like that sentence either. It should either be dropped, or explicitly mention those rare circumstances ("using the unstable may_dangle feature").
As long as we mention rare circumstances, we leave the reader puzzled what those circumstances may be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. My understanding is that the "rare circumstances" ambiguity comes about because the teams are hedging so they are allowed to change it.
My draft seems more acceptable to me than the status quo because it's unambiguous as to whether and when you should use PhantomData, it just is sly about whether it has any given effect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc #103413 (comment)
"Currently, adding a field of type
PhantomData<T>
indicates that your type owns data of typeT
in very rare circumstances" is intentional. AddingPhantomData<T>
to your type only impacts whether your type 'owns'T
in rare circumstances: if your type already has another field which requires drop:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've opened an RFC to fix this behavior rust-lang/rfcs#3417, but I currently don't have the capacity to push this over the finish line. See the examples in that RFC for more details
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oic, thank you for explaining!
hmm... the definition provided here still feels abstruse, but I understand why you phrased it that way now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah 🤔 I think for this to make sense you'd have to actually go into the difference between
needs_drop
anddropck_outlives
(PhantomData
is only considered fordropck_outlives
, as there shouldn't be any types for whichneeds_drop
andCopy
both hold)Ideally the way we make this more understandable is by just merging rust-lang/rfcs#3417, though I guess we can also go more in-depth in the comment if you think that's more achievable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I currently do not have an idea of how to proceed!