{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreieezhclgjqz2mptx5e4pbcrvr7wdo2azg5nnbmuoc22crtttsmre4",
"uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mlynir6p3jd2"
},
"path": "/t/reducing-raw-pointer-footguns-preventing-reference-aliasing-violations-at-compile-time/24301?page=2#post_23",
"publishedAt": "2026-05-16T09:54:19.000Z",
"site": "https://internals.rust-lang.org",
"textContent": "fuji-184:\n\n> That code avoids the point because it avoids mixing raw pointers and references\n\nI simply replaced your `AliasableGuardMut` with a mutable reference and made no changes to avoid mixing raw pointers and references. This means that your code didn't really need the capabilities of raw pointers in the first place and is thus not a valid example of where `AliasableGuardMut` would help.\n\nfuji-184:\n\n> So the body of the example is not important by itself. The important part is: “assume this operation requires a raw pointer”.\n\nAssumptions are ok only as long as they don't matter for the point you're making. They matter in your examples though.\n\nfuji-184:\n\n> The example gives compile time error. Did you run with the code in the opening post?\n\nThe examples themselves were incomplete so I didn't run them.\n\nfuji-184:\n\n> Where 1 one the example is indeed invalidate the head. That is because I didn't wrap the head pointer with the guard. After I wrap all will guard, it now prevents the head pointer invalidation\n\nNo, the head is still invalidated because you use the `node` mutable reference after creating the head. It's another example where your `AliasableGuardMut` does not prevent this kind of issues.",
"title": "Reducing Raw Pointer Footguns: Preventing Reference Aliasing Violations at Compile Time"
}