-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Remove useless PhantomData<T> from Arc. #60594
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
Conversation
It uses NonNull<ArcInner<T>>. From https://doc.rust-lang.org/std/ptr/struct.NonNull.html: > Unlike *mut T, NonNull<T> is covariant over T. If this is incorrect for your > use case, you should include some PhantomData in your type to provide > invariance, such as PhantomData<Cell<T>> or PhantomData<&'a mut T>. Usually > this won't be necessary; covariance is correct for most safe abstractions, > such as Box, Rc, Arc, Vec, and LinkedList. This is the case because they > provide a public API that follows the normal shared XOR mutable rules of Rust. So I _think_ this is not needed.
r? @cramertj (rust_highfive has picked a reviewer for you, use r? to override) |
r? @RalfJung |
Please check in particular dropck and auto trait interactions :) |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
Huh, I guess it is needed after all for dropck but not for variance per se. The docs for Maybe a docs clarification would be on point, but this is clearly not correct. /cc @bholley |
Ah, I see, it is indeed enough, as long as you don't use |
Yeah, it's quite important to tell dropck that |
It is not -- If your type "logically" owns a |
See rust-lang/rust#60594 (comment) Differential Revision: https://phabricator.services.mozilla.com/D30169 --HG-- extra : moz-landing-system : lando
See rust-lang/rust#60594 (comment) Differential Revision: https://phabricator.services.mozilla.com/D30169 UltraBlame original commit: 63d77dbcfda80e420a7e35c2b4244a7a67a5bef2
See rust-lang/rust#60594 (comment) Differential Revision: https://phabricator.services.mozilla.com/D30169 UltraBlame original commit: 63d77dbcfda80e420a7e35c2b4244a7a67a5bef2
See rust-lang/rust#60594 (comment) Differential Revision: https://phabricator.services.mozilla.com/D30169 UltraBlame original commit: 63d77dbcfda80e420a7e35c2b4244a7a67a5bef2
It uses NonNull<ArcInner>.
From https://doc.rust-lang.org/std/ptr/struct.NonNull.html:
So I think this is not needed.