Open theemathas opened 2 weeks ago
There is no way to get a &mut
to thread-locals in safe code. And the address is indeed stable.
However once the destructor of the thread-local gets run, the reference gets invalidated, so the 'static
lifetime is a lie. You seem to be aware of that.
The notion of "soundness" of an unsafe function is non-trivial to define so it's not entirely clear what you are asking about.
And the address is indeed stable.
Is this documented anywhere?
Not that I am aware of.
thread-locals are a library feature, so this would be a t-libs-api issue to be raised in https://github.com/rust-lang/rust/issues/
Is the following code sound?
In other words, is it guaranteed that: