Tracking Issue for Field Projections
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
This is a tracking issue for work on Field Projections.
The feature gate for the issue is #![feature(field_projections)].
This is a lang experiment at the moment and the feature is subject to change substantially over time.
We have an active project goal for this effort: https://github.com/rust-lang/rust-project-goals/issues/390
About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Discussion comments will get marked as off-topic or deleted.
Repeated discussions on the tracking issue may lead to the tracking issue getting locked.
Steps
-
Approve as lang experiment
- We accepted this experiment in the 2025-08-13 lang design meeting.
-
Hold a second design, notes from 2026-04-01
-
a-mir-formality: create a formal model of the borrow checker changes- familiarization & experimentation
- do small experiments using the traits from the borrow checker
- add our traits to the model
- add lang-item crate https://github.com/rust-lang/a-mir-formality/pull/258
- wait for Niko's new expression based syntax
- Copy traits to new syntax https://github.com/rust-lang/a-mir-formality/pull/306
- Integrate
HasPlacewith place expressions and projections - Integrate
PlaceReadinto the borrow checker (forCopytargets only) - Integrate
PlaceWrite,PlaceDrop,DropHuskandPlaceRead(also for!Copy) into the borrow checker - Integrate
PlaceBorrowinto the borrow checker - Refine & Explore Model
- Comprehensive test-suite
- Ensure functionality of common patterns
- Author document for explaining the model
- familiarization & experimentation
-
Implementation: implement a compiler experiment
- add field reflection via field representing types (FRTs)
- add FRTs &
Fieldtrait: https://github.com/rust-lang/rust/pull/152730 - improve FRT documentation https://github.com/rust-lang/rust/pull/154927
- fix FRTs not being invariant https://github.com/rust-lang/rust/pull/154778
- fix privacy violation https://github.com/rust-lang/rust/pull/152730#issuecomment-3940696062
- fix compiler hang https://github.com/rust-lang/rust/issues/153256
- support unsized base types (but only sized fields)
- support for unions & enums via extra trait
- figure out packed structs: direct support vs
Unaligned<T> - add
field_of!in expression position to improve ergonomics (reducing need for turbofish) - figure out if we actually want & need FRTs for projections
- add FRTs &
- Add operation and projection traits to
corehttps://github.com/rust-lang/rust/pull/154940 - add manual projection desugaring macros
- syntax (require
unsafeto access) - borrow checker integration
- depends on
a-mir-formalitymodel
- depends on
- relax
unsaferequirement on syntax
- add field reflection via field representing types (FRTs)
-
Experimentation: stress-test the experiment in real code
- Questions to resolve by this experiment:
- How much new syntax do we even need?
- How bad is the ambiguity when making
@placebe inferred? - What effects does this have on SemVer in std & in general?
- Linux Kernel
- replace Gary's pointer projection infrastructure
-
Untrusted<T> -
SeqLockRef<'_, T> -
MutexGuard<'_ ,T> -
Mutex<T>->Rcu<U> -
Arc<T> -
Box<T> -
ArcBorrow<'_, T>
- Standard Library
-
MappedMutexGuard<'_, T> -
UnsafeCell<T> -
Cell<T> -
ManuallyDrop<T> -
MaybeUninit<T> -
*const T&*mut T -
NonNull<T> -
Box<T> -
Arc<T> -
Rc<T> -
&[mut] T - coordinate with t-libs-api on the creation of:
-
ArcRef<T>&UniqueArcRef<T> -
ArcBorrow<'_, T> -
ArcBox<T>(?) -
WrappingPtr<T> -
MutexGuardRef<'_, T> -
MutexRef<'_, T> -
Own<'_, T>(aka&own T)
-
-
ArcRef<T>&UniqueArcRef<T> -
ArcBorrow<'_, T> -
ArcBox<T>(?) -
WrappingPtr<T> -
cell::Ref[Mut]<'_, T> -
MutexGuardRef<'_, T> -
MutexRef<'_, T> -
{btree_map,hash_map}::Entry@joshtriplett
-
-
pyo3@davidhewitt-
PyRef[Mut]<'_, T>
-
-
crubit@tmandry
- Questions to resolve by this experiment:
-
User Research
- What is the best name for
HasPlace? Some good candidates arePlaceandDerefable. - How should the borrowing syntax look like? What's the best for the 95% use-case and what do users understand best?
- What is the best name for
Unresolved Questions
- Should FRTs be provably (un)inhabited?
Making them inhabited would allow APIs to take their value to reduce the amount of turbo-fish syntax in codemy_fun(field_of!(Struct, field))instead ofmy_fun::<field_of!(Struct, field)>(). There currently is no known advantage for provably uninhabited FRTs.- Resolved: they should be inhabited ZSTs to allow reducing the amount of turbofish syntax required to use them.
Implementation history
- https://github.com/rust-lang/rust/pull/155588
- https://github.com/rust-lang/rust/pull/154940
- https://github.com/rust-lang/rust/pull/154927
- https://github.com/rust-lang/rust/pull/154778
- https://github.com/rust-lang/a-mir-formality/pull/306
- https://github.com/rust-lang/a-mir-formality/pull/258
- https://github.com/rust-lang/rust/pull/153229
- https://github.com/rust-lang/rust/pull/152730
- https://github.com/rust-lang/rust/pull/146307
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source file or test is named. Start with the field_projections feature gate, the unchecked implementation checklist, and linked work in rust and a-mir-formality; a contribution is done when one specific checklist item is completed with its relevant implementation or design work and the tracking issue is updated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100