External Publication
Visit Post

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

Rust Internals [Unofficial] March 7, 2026
Source

H4n_uL:

it becomes difficult to express that purely as a library type without compiler support.

Lifetime tracking and borrow support is already available to custom types, with the exception of re-borrowing.

There are many other types, both in the standard library and in third-party crates that would benefit from field projection and/or reborrow support. So it's better to add those features in the compiler, and make your reference type an ordinary library type.

For field projections the tracking issue is Tracking Issue for Field Projections · Issue #145383 · rust-lang/rust · GitHub

For re-borrowing the tracking issue is Tracking Issue for Reborrow trait lang experiment · Issue #145612 · rust-lang/rust · GitHub


Both of these features can effectively be used with custom types today, just with some downsides, like ugly syntax, and lack of type inference.

For example field projection, might currently look something like field!(pointer, fieldname) instead of pointer~fieldname. playground

And reborrowing might require something like pointer.reborrow() instead of happening automatically.

Discussion in the ATmosphere

Loading comments...