(We could emit a lint if a type contains a `*T` but no `PhantomData`, if we're worried about variance inference, I don't know if we already have something like that)
-
-
Show this threadThanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
With Option for getting nullability? I think there was some obscure other issue but would love this outcome!
-
Yes, and language guarantees about its representation and whatever else you need. Was it one of the things
@ManishEarth mentioned?https://twitter.com/ManishEarth/status/989286766296219648 … -
(Anyway it sounds like this would be controversial.)
End of conversation
New conversation -
-
-
We use nullable pointers a lot in abstractions in firefox, especially when doing stuff with FFI. Yes, you can use Option<*T> here. Now that's super transmutey for doing bitmasks and stuff.
-
Wait why / what's the difference? Do you mean because `as` exists for */usize but not Option? (We could try to figure something out to improve the situation as part of the solution..)
-
Partly yeah. In general adding weirdness/guarantees to types passed over FFI doesn't sit well with me. This proposal seems designed from the unsafe abstractions POV but FFI uses these things too.
-
(It's designed from the "maybe we can simplify things" POV not any particular use case.)
-
This complicates things :) We could simplify pointers by removing the const/mut distinction.
-
In abstractions you almost always want NonNull, in FFI it's the opposite.
-
Furthermore, forgetting NonNull is nbd. Forgetting Option for *T is a big deal. And raw pointers are far more pervasive in FFI. You write one or two raw pointers in a abstractions crate. You write hundreds in FFI
-
Now, an RFC guaranteeing the repr of Option<NonNull> would be sweet. We used this in Gecko, some types get passed as &T or Option<&T> over FFI and this has helped catch bugs.
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.