External Publication
Visit Post

Include racy reads in Rust memory model with `MaybeInvalid<T>`

Rust Internals [Unofficial] May 31, 2026
Source

RalfJung:

The story cannot depend on a check that has not happened yet.

[citation needed]

It's the story which tell ourselves , not to the compiler. The assembly block reads some value which we know can be interpreted as T if the validity check has passed. We communicate it to the compiler by calling assume_init only after the check. Until then the value is completely opaque to the compiler, so the Schrodinger-like reliance on the post-factum check in our story is fine.

Such reasoning may not fit into the reductionist "tell me story in terms of AM" approach, but it's used in practice and by the looks of it works more or less reliably.

Discussion in the ATmosphere

Loading comments...