External Publication
Visit Post

Idea / Pre-RFC: Null-free pointer and Zeroable reference

Rust Internals [Unofficial] March 7, 2026
Source

H4n_uL:

That said, I'm not sure it alone would be sufficient for cases like the DevTreeBlob example in the OP, where the hardware places a structure at 0x0 on a 16-bit target with no spare RAM. There, what's needed is &mut DevTreeBlob

A & or &mut at null will never happen, precisely for the reasons laid out earlier in this thread; references are never null, niche optimization, and both the compiler and the ecosystem count on both of those. The thing you wrote as "instant UB" is going to continue to be instant UB.

But given the appropriate low-level primitives, you'd be able to design a different wrapper type, e.g. AnywherePtr<T>, which can contain a raw pointer value that's only used with those specific low-level primitives. And with upcoming work on field projection, you could go from an AnywherePtr<MyStruct> to an AnywherePtr<FieldOfMyStruct>. That could look roughly like let value = my_anywhere_ptr~field.read(); or my_anywhere_ptr~field.write(value); (where the exact operator in place of ~ is still TBD).

Discussion in the ATmosphere

Loading comments...