{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreihr5by7v654tdkz5lceums5pcs3pz2vxlctibcj7zwke26igzmlry",
"uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mlvwcozyltz2"
},
"path": "/t/reducing-raw-pointer-footguns-preventing-reference-aliasing-violations-at-compile-time/24301#post_9",
"publishedAt": "2026-05-15T18:03:04.000Z",
"site": "https://internals.rust-lang.org",
"textContent": "I think there are two reasonable possible semantics for your `AliasingGuardMut`. Either they are unique, or they are not.\n\nThe former case is practically identical to `&'a mut T` (though there is still a range of flexibility in exactly _when_ you assert uniqueness… which even Rust’s `&'a mut T` has not yet decided on).\n\nIn the latter case, the guards aren’t unique, so you can’t obtain a `&'a mut T` from an `AliasingGuardMut<'a, T>` (which requires asserting uniqueness). _However_ , you can still read and write a `T` from/to the pointee; so long as there’s no data races, you don’t _need_ unique access over a `T` to mutate it. It’d even be fine to go all the way and make `AliasableGuardMut<'a, T>` `Copy`.\n\nThis sounds familiar… read and write a `T` at a given instant, but don’t obtain a `&mut T` or `&T`… prohibit multithreading… the pointee lives for `'a` and the pointer is `Copy`… _**that’s just`&'a Cell<T>`**_.",
"title": "Reducing Raw Pointer Footguns: Preventing Reference Aliasing Violations at Compile Time"
}