Skip to content

make field representing types invariant over the base type#154778

Merged
rust-bors[bot] merged 2 commits intorust-lang:mainfrom
BennoLossin:frt-invariant
Apr 8, 2026
Merged

make field representing types invariant over the base type#154778
rust-bors[bot] merged 2 commits intorust-lang:mainfrom
BennoLossin:frt-invariant

Conversation

@BennoLossin
Copy link
Copy Markdown
Contributor

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Apr 3, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 3, 2026

oli-obk is not on the review rotation at the moment.
They may take a while to respond.

@BennoLossin
Copy link
Copy Markdown
Contributor Author

@rustbot label +F-field_projections

@rustbot rustbot added the F-field_projections `#![feature(field_projections)]` label Apr 7, 2026
@oli-obk
Copy link
Copy Markdown
Contributor

oli-obk commented Apr 8, 2026

@bors r+ rollup

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 8, 2026

📌 Commit 8e36508 has been approved by oli-obk

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 8, 2026
@oli-obk oli-obk added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-types Relevant to the types team, which will review and decide on the PR/issue. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Apr 8, 2026
rust-bors Bot pushed a commit that referenced this pull request Apr 8, 2026
…uwer

Rollup of 15 pull requests

Successful merges:

 - #153995 (Use convergent attribute to funcs for GPU targets)
 - #154184 (stabilize s390x vector registers)
 - #151898 (constify DoubleEndedIterator)
 - #154235 (remove unnecessary variables and delimiter check)
 - #154473 (move borrow checker tests)
 - #154745 (Replace span_look_ahead with span_followed_by)
 - #154778 (make field representing types invariant over the base type)
 - #154867 (Fix private fields diagnostics and improve error messages)
 - #154879 (Don't store `pattern_ty` in `TestableCase`)
 - #154910 (Suppress `unreachable_code` lint in `derive(PartialEq, Clone)`)
 - #154923 (Fix ICE in next-solver dyn-compatibility check)
 - #154934 (Add getters for `rustc_pattern_analysis::constructor::Slice` fields)
 - #154938 (match exhaustiveness: Show the guard exhaustivity note only when it's the guards alone that cause non-exhaustiveness)
 - #154961 (Use derived impl for `GappedRange` subdiagnostic)
 - #154980 (rustc-dev-guide subtree update)
@rust-bors rust-bors Bot merged commit 532c2b6 into rust-lang:main Apr 8, 2026
11 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 8, 2026
@rustbot rustbot added this to the 1.96.0 milestone Apr 8, 2026
rust-timer added a commit that referenced this pull request Apr 8, 2026
Rollup merge of #154778 - BennoLossin:frt-invariant, r=oli-obk

make field representing types invariant over the base type

We probably don't want to have any subtype relationship between any FRTs.

Reported-by: @dvdhrm "David Rheinsberg" <[email protected]>
Link: https://rust-for-linux.zulipchat.com/#narrow/channel/288089-General/topic/Multiple.20LockedBy.20with.20Single.20Lock/near/579275908

r? @oli-obk
@BennoLossin BennoLossin deleted the frt-invariant branch April 8, 2026 17:49
@dvdhrm
Copy link
Copy Markdown
Contributor

dvdhrm commented Apr 9, 2026

Thanks a lot for changing this!

I think this also needs to be a guarantee of the API, rather than just an implementation detail. If I create a generic type with an FRT, I want to be ensured that the FRT cannot be changed due to subtyping, as other parts of the object might rely on the metadata of the FRT to be immutable.

IOW, I don't want an intrusive list List<Frt> to be coerced to List<Frt2>, ever, as it would completely break it.

@BennoLossin
Copy link
Copy Markdown
Contributor Author

Thanks a lot for noticing this mistake :)

It makes a lot of sense to want this to be documented. Note that this feature is still unstable and incomplete. When we initially created FRTs, we thought we needed them for field projections. It turns out that we do not necessarily need them.

I plan to keep them until we've fully verified this in the field projection experiment. Additionally, @fbq has expressed a need for FRTs for his intrusive data structure abstractions in RfL. If you also have a use for FRTs, we can think about splitting them off into a separate feature and write an RFC to get them stabilized orthogonally to field projections.

When we do that, we can also document this guarantee (FRTs are invariant over the base type, and that different fields will result in different FRTs). If you want, you can file a PR to add a comment to field_of! noting that we probably want to give this guarantee. I'm at capacity with my other efforts at the moment.

github-actions Bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Apr 13, 2026
…uwer

Rollup of 15 pull requests

Successful merges:

 - rust-lang/rust#153995 (Use convergent attribute to funcs for GPU targets)
 - rust-lang/rust#154184 (stabilize s390x vector registers)
 - rust-lang/rust#151898 (constify DoubleEndedIterator)
 - rust-lang/rust#154235 (remove unnecessary variables and delimiter check)
 - rust-lang/rust#154473 (move borrow checker tests)
 - rust-lang/rust#154745 (Replace span_look_ahead with span_followed_by)
 - rust-lang/rust#154778 (make field representing types invariant over the base type)
 - rust-lang/rust#154867 (Fix private fields diagnostics and improve error messages)
 - rust-lang/rust#154879 (Don't store `pattern_ty` in `TestableCase`)
 - rust-lang/rust#154910 (Suppress `unreachable_code` lint in `derive(PartialEq, Clone)`)
 - rust-lang/rust#154923 (Fix ICE in next-solver dyn-compatibility check)
 - rust-lang/rust#154934 (Add getters for `rustc_pattern_analysis::constructor::Slice` fields)
 - rust-lang/rust#154938 (match exhaustiveness: Show the guard exhaustivity note only when it's the guards alone that cause non-exhaustiveness)
 - rust-lang/rust#154961 (Use derived impl for `GappedRange` subdiagnostic)
 - rust-lang/rust#154980 (rustc-dev-guide subtree update)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

F-field_projections `#![feature(field_projections)]` T-types Relevant to the types team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants