Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate spooky-dropck-at-a-distance #3414

Closed
wants to merge 5 commits into from

Conversation

SoniEx2
Copy link

@SoniEx2 SoniEx2 commented Apr 14, 2023

(Split off from #3390 after discussions with t-types.)

Rendered

@programmerjake
Copy link
Member

because this affects soundness of nearly all code using #[may_dangle], I think the compiler should require #[may_dangle] to be textually changed somehow in order to compile, maybe #[may_dangle2] or #[may_dangle(dropped)]/#[may_dangle(!dropped)]? this would make old unadjusted code fail to compile instead of being silently unsound.

@programmerjake
Copy link
Member

since #[may_dangle] T is most commonly used when dropping T, maybe #[may_dangle] could be changed to check validity for dropping T and #[may_dangle(!drop)] T could be used when T doesn't need that? this would also avoid the silent unsoundness afaict.

@SoniEx2
Copy link
Author

SoniEx2 commented Apr 14, 2023

yes, #[may_dangle(borrowed)] or something is fine. we just don't want to put too much work into it, since this isn't meant for stabilization.

alternatively we could just make the compiler check if drop glue for T was generated. (in other words, the compiler can effectively check if drop_in_place was called inappropriately.) but having that happen at monomorphization time is less than ideal. unfortunately the alternative to that is to go full #3390.

also note that for lifetimes, only #[may_dangle] is relevant. (there's no such thing as #[needs_drop] 'a.)

also: hashbrown.

@ehuss ehuss added the T-lang Relevant to the language team, which will review and decide on the RFC. label Apr 14, 2023
@lcnr lcnr added T-types Relevant to the types team, which will review and decide on the RFC. and removed T-lang Relevant to the language team, which will review and decide on the RFC. labels Apr 17, 2023
Particularly reference-level explanation.
@SoniEx2 SoniEx2 changed the title Split may_dangle Split may_dangle and make PhantomData less weird Apr 17, 2023
@SoniEx2
Copy link
Author

SoniEx2 commented Apr 17, 2023

we also note that neither this nor #3390 are an issue for future proposals. in particular, these would NOT block typestate/partially initialized types. they're orthogonal.

@SoniEx2 SoniEx2 changed the title Split may_dangle and make PhantomData less weird Deprecate spooky-dropck-at-a-distance Apr 21, 2023
@SoniEx2
Copy link
Author

SoniEx2 commented Apr 21, 2023

c.f. rust-lang/rust#110288

text/3414-deprecate-spooky-dropck-at-a-distance.md Outdated Show resolved Hide resolved
text/3414-deprecate-spooky-dropck-at-a-distance.md Outdated Show resolved Hide resolved
text/3414-deprecate-spooky-dropck-at-a-distance.md Outdated Show resolved Hide resolved
text/3414-deprecate-spooky-dropck-at-a-distance.md Outdated Show resolved Hide resolved
text/3414-deprecate-spooky-dropck-at-a-distance.md Outdated Show resolved Hide resolved
text/3414-deprecate-spooky-dropck-at-a-distance.md Outdated Show resolved Hide resolved
text/3414-deprecate-spooky-dropck-at-a-distance.md Outdated Show resolved Hide resolved
@SoniEx2 SoniEx2 closed this May 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-types Relevant to the types team, which will review and decide on the RFC.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants