Field Projections — Making Custom Pointers feel Builtin

by Benno Lossin and Nadri

Rust makes heavy use of custom pointers filling the gap (& going beyond) between references (&T and &mut T) and raw pointers (*const T and *mut T). Currently, they have two major issues: ergonomics and feature parity with builtin references and Box<T>. Raw pointers and their extensions (e.g. NonNull<T>) have especially bad ergonomics. We are working on proposing the Field Projection language feature that aims to remedy these shortcomings of custom (dumb & smart) pointers. Our current approach is an ambitious generalization of Deref that supports a plethora of custom pointers from MyBox<T> (that has all the properties of Box<T>) to VolatilePtr<T> (which is only using {read,write}_volatile to access the pointee). Our proposal integrates tightly with existing features such as place expressions, operations on places, the borrow-checker, and autoref. Field Projections was a project goal in 2025H2 and is very likely to continue in 2026. In the last few months we have made incredible progress and want to involve greater parts of the community.

Picture of Benno Lossin

Benno Lossin

he/him
Rust for Linux core team
Links: icon of github

I started with Rust during university in 2021 and quickly fell in love with the language because of its type and trait system. In early 2022, I began my contributions to Rust for Linux, providing a solution to pinned initialization, which I maintain to this day. I then continued to review core Rust code and involved myself more with the development of Rust itself. Now I’m working mostly on field projections, in-place initialization, and various other language features.

Picture of Nadri

Nadri

he/him
Rust Project and Inria Paris
Links:

I’m a programming languages enthusiast and experienced Rust contributor. I fell in love with Rust for its cool design ideas and open governance, then started contributing in 2019 to scratch an itch and ended up the de-facto expert on pattern-matching. Since then I’ve been dabbling in lang design, opsem, spec and more recently type system work. In my dayjob I’m a research engineer working on a Rust analysis toolchain.