Sometimes it happens that two unsafe-using libraries are sound in isolation, but unsound when combined. Each time that happens, Rust has to decide which side to consider sound. Ultimately this boils down to precisely specifying the safety invariants of all our types -- but doing that requires something like RustBelt, so it is hard to have that discussion in full generality. (Also that would involve T-types at least as much as WG-UCG / T-opsem.)
But meanwhile, it would be good to collect the cases of these conflicts here that we find out there in the wild.
The most famous case of this is of course leakpocalypse: Rc vs pre-Rust-1.0-scoped-threads, which famously got decided in favor of Rc (and mem::forget). Another case is that without union and ManuallyDrop, josephine would be sound. Again the resolution for the ecosystem is clearly in favor of unions and ManuallyDrop.
The point of this thread is not to discuss any of these conflicts and figure out which side we want to bless. It is solely to collect the known cases in a central location.
- take_mut / replace_with vs partial-borrow: see here for details and discussion.
- mk_static vs Stack Tokens: see reddit for details.
Pin is seriously under-specified and probably has quite a few of these conflicts, here is one.
- "Partial move out of
Drop type" vs a pattern that assumes that exactly that does not happen (coming up in this RFC).
- TLS vs stackful coroutines.
- Allowing vs not allowing some lifetime subtyping on
dyn Trait.
- Safe life-before-main vs
main assuming there are no other threads and libraries assuming their life-before-main is called before their API is used
- Commuting
&MaybeUninit<Cell<T>> to &Cell<MaybeUninit<T>> vs the uninit crate
Things get extremely murky when you consider macros -- personally I am skeptical of anything that relies on macro tricks for soundness; "obviously" many of those can be broken if the language gains new features (and obviously we want to have the freedom to add new features to Rust). But for completeness' sake, we can also collect cases involving macros:
Sometimes it happens that two unsafe-using libraries are sound in isolation, but unsound when combined. Each time that happens, Rust has to decide which side to consider sound. Ultimately this boils down to precisely specifying the safety invariants of all our types -- but doing that requires something like RustBelt, so it is hard to have that discussion in full generality. (Also that would involve T-types at least as much as WG-UCG / T-opsem.)
But meanwhile, it would be good to collect the cases of these conflicts here that we find out there in the wild.
The most famous case of this is of course leakpocalypse:
Rcvs pre-Rust-1.0-scoped-threads, which famously got decided in favor ofRc(andmem::forget). Another case is that withoutunionandManuallyDrop,josephinewould be sound. Again the resolution for the ecosystem is clearly in favor ofunions andManuallyDrop.The point of this thread is not to discuss any of these conflicts and figure out which side we want to bless. It is solely to collect the known cases in a central location.
Pinis seriously under-specified and probably has quite a few of these conflicts, here is one.Droptype" vs a pattern that assumes that exactly that does not happen (coming up in this RFC).dyn Trait.mainassuming there are no other threads and libraries assuming their life-before-main is called before their API is used&MaybeUninit<Cell<T>>to&Cell<MaybeUninit<T>>vs theuninitcrateThings get extremely murky when you consider macros -- personally I am skeptical of anything that relies on macro tricks for soundness; "obviously" many of those can be broken if the language gains new features (and obviously we want to have the freedom to add new features to Rust). But for completeness' sake, we can also collect cases involving macros:
pin!macro vs movable coroutines / generators:pin!()(and any other unsafe code relying on local variables having a fixed location) in a coroutine orgenblock is unsound rust#153688lien::scope!macro vs async functions (Loophole in some structured loan-backed products (a.k.a., unsoundness in the API) twilligon/lien#1)