External Publication
Visit Post

Reducing Raw Pointer Footguns: Preventing Reference Aliasing Violations at Compile Time

Rust Internals [Unofficial] May 17, 2026
Source

Having more of the matrix of invariants would certainly be nice. unsafe<'_> binders, for lifetime erasure. MaybeDangling. UnsafePinned or whatever it ends up being called.

Don’t forget pointer tagging, though. Is there currently any other way to soundly read and manipulate the numeric value of bytes which may have providence (without exposing the pointer) other than raw pointers? Designing a non-raw-pointer-type for ergonomic pointer tagging might be interesting, I suppose. (Ah, maybe it could just be an enum, possibly with some repr(ptr) or something if needed for clarity, 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.)

Edit: hrmm I think you might be able to make “we have raw pointers at home” with references to ZSTs.

I fear raw pointers won’t be able to be deprecated at this point, but I hope Rust serves as good research material for a successor language that might avoid needing them.

Discussion in the ATmosphere

Loading comments...