Description
Some people expressed interest in a volatile Cell
-like type that owns the value, similar to the v0.3
interface of this crate. I think that such a type would be a nice addition to the pointer types proposed in #29, but the question is whether it is possible to implement such a type in a sound way.
The fundamental issue is that references are marked as dereferenceable
by the compiler, which permits LLVM to insert spurious reads. This is not valid for volatile values since they might change in between reads. This issue was e.g. discussed in this thread on the Rust internals forum in 2019, with the conclusion that such a type would require special language support.
About half a year ago, rust-lang/rust#98017 was merged, which (if I understand it correctly) removed the dereferenceable
annotation from &T
where T
contains an UnsafeCell
. Maybe this change makes it possible to safely implement a VolatileCell
with an inner UnsafeCell
now?