{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreicmgu2xn76dletmmuqibqdxlx7qv45gvblrg7xovogatvzaazx2yy",
"uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mlzpcx3mmah2"
},
"path": "/t/reducing-raw-pointer-footguns-preventing-reference-aliasing-violations-at-compile-time/24301?page=2#post_32",
"publishedAt": "2026-05-17T05:05:29.000Z",
"site": "https://internals.rust-lang.org",
"textContent": "robofinch:\n\n> (Ah, maybe it could just be an enum in some specific scenario guaranteed to be optimized into a single pointer, a bit like how the null optimization of `Option`-like enums is guaranteed.)\n\nThis is exactly what I was planning – an `AtomicEnum` that gets packed down to a sufficiently small size that it can be stored in an atomic. This gives an enormous amount of power (e.g. it is enough to write `Mutex` in entirely safe code, as long as you have access to a safe futex or other comparable blocking primitive). For `Mutex` you just need the existing optimisation on `Option`, but for more complicated situations you would probably want a `#[repr(…)]` that's guaranteed to be able to pack multiple types of pointer into a single atomic-sized word, as long as they have sufficient alignment to allow enough of a niche.",
"title": "Reducing Raw Pointer Footguns: Preventing Reference Aliasing Violations at Compile Time"
}