non-Drop types with drop glue leak may_dangle implementation details on stable #103318
Labels
C-bug
Category: This is a bug.
needs-triage-legacy
Old issue that were never triaged. Remove this label once the issue has been sufficiently triaged.
I tried this code:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=ef62faa188b41fd69f1561da05605db6
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=2c6e1a61081f093bab2b882e9ea676ae
I expected to see this happen: These should behave identically.
Instead, this happened: Implementation details of parametric dropck, also known as may_dangle, which is an internal unstable feature, leak to stable, so one of these complies while the other doesn't.
We honestly, after a lot of discussion and reading a lot of RFCs related to dropck, think both of these should compile. A quick fix would be to treat PhantomData like ManuallyDrop when outside an explicitly Drop type, and fall back to the existing behaviour for may_dangle. A proper fix would be to change may_dangle to be non-parametric, but that's gonna require an (e)RFC :). (N.B.: ManuallyDrop is unsound with may_dangle, but that's already acknowledged by may_dangle being unsafe.)
Meta
rustc --version --verbose
:Backtrace
The text was updated successfully, but these errors were encountered: