Skip to content

Commit 143ec85

Browse files
authored
Merge pull request #1346 from lcnr/types-team-update
Types Team Update and Roadmap
2 parents bdccce3 + 3b038f0 commit 143ec85

File tree

1 file changed

+226
-0
lines changed

1 file changed

+226
-0
lines changed

posts/2024-06-26-types-team-update.md

+226
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
---
2+
layout: post
3+
title: "Types Team Update and Roadmap"
4+
author: lcnr
5+
team: The Types Team <https://github.com/rust-lang/types-team>
6+
---
7+
8+
It has been more than a year since [the initial blog post][TypesAnnouncement] announcing the Types team, and our initial set of goals. For details on what the team is, why it was formed, or our previously-stated overarching goals, go check out that blog post. In short the Types team's purview extends to the parts of the Rust language and compiler that involve the type system, e.g. type checking, trait solving, and borrow checking. Our short and long term goals effectively work to make the type system sound, consistent, extensible, and fast.
9+
10+
Before getting into details, it's worth sharing a quick point: the team over the last year has been very successful. Oftentimes, it's hard to measure impact, particularly when long-term roadmap goals are hard to quantify progress on and various short-term goals either are hit or aren't. But, there is one clear statistic that is somewhat indicative of the team's progress: over the last year or so, [more than 50 user-facing changes][FCPs] have landed, each separately approved by Types Team consensus through FCP.
11+
12+
The changes lie at the boundary between language design and implementation, and the Types Team (which is a subteam of both the Language and Compiler Teams) existing means that not only does the Rust Project have the bandwidth to make these decisions but we also have enough people with the knowledge and experience of the type system to make informed decisions that overall make the language better.
13+
14+
## The priorities of the types team
15+
16+
To evaluate our progress over the last year and our roadmap going forward,
17+
lets start with our main priorities in order of importance. We will refer
18+
to them during the remainder of this post. To reach our goals, we need a
19+
a healthy group of maintainers which have the expertise and capacity to
20+
react to issues and to implement complex changes.
21+
22+
### The type system should be Sound
23+
24+
One of the main promises of Rust is that there cannot be undefined behavior when using
25+
only safe code. It might surprise you that there are currently [known type system
26+
bugs][unsoundCAT] which break these guarantees. Most of these issues were found by people familiar with
27+
the inner workings of the compiler by explicitly looking for them and we generally do not expect
28+
users to encounter these bugs by accident. Regardless, we deeply care about fixing them
29+
and are working towards a fully sound and ideally verified type system.
30+
31+
### The type system should be Consistent
32+
33+
The type system should be easy to reason about. We should avoid rough edges and
34+
special-cases if possible. We want to keep both the implementation and user-facing behavior
35+
as simple as possible. Where possible we want to consider the overall design instead of
36+
providing local targeted fixes. This is necessary to build trust in the soundness of the
37+
type system and allows for a simpler mental model of Rust.
38+
39+
### The type system should be Extensible
40+
41+
Rust is still evolving and we will be required to extend the type system to enable new
42+
language features going forward. This requires the type system to be extensible and
43+
approachable. The design of the language should not be adapted to work around
44+
short-comings of its current type system implementation. We should collaborate with
45+
other teams and users to make sure we're aware of their problems and consider possible
46+
future extensions in our implementation and design.
47+
48+
### The type system should be Fast
49+
50+
We care about the compile times of Rust and want to consider the impact on compile times
51+
of our designs. We should look for effective approaches to speed up the existing implementation,
52+
by improving caching or adding fast paths where applicable. We should also be aware of the
53+
compile time impact of future additions to the type system and suggest more performant
54+
solutions where possible.
55+
56+
## Updates
57+
58+
We have been very active over the last year and made some significant progress. There
59+
are also a few non-technical updates we would like to share.
60+
61+
## Organizational updates
62+
63+
First, a huge welcome to the two new members to team since the announcement post: [@BoxyUwU] and [@aliemjay]. [@BoxyUwU] has been doing a lot of work on const generics and made significant contributions to the design of the next generation trait solver. [@aliemjay] has been working on some very subtle improvements to opaque types - `impl Trait` - and to borrow checking. They are both invaluable additions to the team.
64+
65+
We also organized another in-person Types Team meetup last October, immediately prior to EuroRust. We discussed the state of the team, looked at current implementation challenges and in-progress work, and reviewed and updated [the roadmap from the previous meetup][PrevRoadmap]. Most of this will be covered in this blog post.
66+
67+
Finally, as discussed in the [RFC](https://rust-lang.github.io/rfcs/3254-types-team.html), we would like to have leads rotate out regularly, largely to help share the burden and experience of leads' work. So with that being said, [@nikomatsakis](https://github.com/nikomatsakis) is rotating out and [@lcnr](https://github.com/lcnr) is joining to co-lead alongside [@jackh726](https://github.com/jackh726/).
68+
69+
## Roadmap progress and major milestones
70+
71+
### The next-generation trait solver
72+
73+
There has been [a lot of work][NewSolver] on the [next-generation trait solver][InitiativeRepo].
74+
The initiative posted [a separate update][InitiativeUpdate] at the end of last year. While
75+
we would have liked to [stabilize its use in coherence][StabilizeNS] a few months ago,
76+
this surfaced additional small behavior regressions and hangs, causing delays. We are working on fixing these issues and intend to merge the stabilization PR soon. We are getting close to compiling the standard library
77+
and the compiler with the new solver enabled everywhere, after which will be able to run
78+
crater to figure out the remaining issues. We expect there to be a long tail of minor issues
79+
and behavioral differences from the existing implementation, so there's still a lot to do
80+
here. There are also open design questions which we will have to resolve before stabilizing
81+
the new implementation.
82+
83+
### Async and `impl Trait`
84+
85+
We stabilized `async`-fn in traits (AFIT) and return-position `impl Trait` in
86+
traits (RPTIIT) in version 1.75 thanks to a significant effort by [@compiler-errors] and
87+
[@spastorino]. [@cjgillot] greatly improved the way generators, and therefore async functions,
88+
are represented in the type system[^107421]. This allowed us to support recursive
89+
`async`-functions without too much additional work[^117703].
90+
91+
Designing the next-generation trait solver surfaced issues and future-compatibility challenges
92+
of our type-alias `impl Trait` (TAIT) implementation using the old trait solver. We are
93+
currently reworking the design and implementation. [@oli-obk] is spear-heading this effort.
94+
This also impacts RPIT edge-cases, forcing us to be careful to avoid accidental breakage.
95+
There are some open language design questions for TAIT, so we plan to
96+
stabilize associated type position `impl Trait` (ATPIT) as it avoids these language design
97+
questions while still closing the expressiveness gap.
98+
99+
### `a-mir-formality`
100+
101+
We made limited progress on [`a-mir-formality`] over the last year, mostly
102+
because we were able to allocate less time than expected towards this work.
103+
We have used it as the foundation towards an intuitive approach to
104+
coinductive traits which are necessary for many of the remaining unsound
105+
issues.
106+
107+
### Fixing soundness issues
108+
109+
We fixed multiple long-standing unsound issues, see [the full list of closed issues](https://github.com/rust-lang/rust/issues?q=is%3Aissue+label%3AI-unsound+label%3AT-types+-label%3Arequires-nightly+is%3Aclosed+closed%3A%3C2024-06-20+). The most most notable of which was [#80176](https://github.com/rust-lang/rust/issues/80176). This subtle issue caused us to accept methods in trait implementations whose function signature had outlives requirements not present in the trait definition. These requirements were then never proven when calling the trait method. As there were some crates which relied on this pattern by accident, even if it their usages didn't exploit this unsoundness, we first merged a [future-compatibility lint](https://github.com/rust-lang/rust/issues/105572) which we then moved to a hard error after a few versions.
110+
111+
We've also spent time on [categorizing the remaining open issues][unsoundCat] and integrating
112+
them into our longterm planning. Most of the remaining ones are blocked on the
113+
next-generation trait solver as fixing them relies on coinductive trait semantics
114+
and improvements to implied bounds. There are some remaining issues which can be at
115+
least partially fixed right now, and we intend to work through them as we go.
116+
Finally, there are some issues for which we still haven't figured out the best
117+
approach and which require some further considerations.
118+
119+
## Going forward
120+
121+
We made significant progress during the last year but we are not done! This section covers our goals for the rest of 2024. For each item we also link to the project goals that we have proposed as part of the Rust Project's [experimental new roadmap process](https://blog.rust-lang.org/inside-rust/2024/05/07/announcing-project-goals.html).
122+
123+
### `-Znext-solver`
124+
125+
* [Next-generation trait solver project goal](https://rust-lang.github.io/rust-project-goals/2024h2/next-solver.html)
126+
127+
Our biggest goal is to use the [next-generation trait solver][InitiativeRepo]
128+
everywhere by default and to fully replace the existing implementation. We are currently
129+
finalizing the stabilization of [its use in coherence checking][StabilizeNS]. This should
130+
already fix multiple unsound issues and fix a lot of smaller issues and inconsistencies of
131+
the current implementation. See the stabilization report for more details.
132+
133+
We are also working on extracting its implementation into a separate library
134+
outside of the compiler itself. We would like to share the trait solver with
135+
rust-analyzer by the end of this year. They currently use [chalk] which is no longer
136+
actively maintained. Using the next-generation trait solver in rust-analyzer
137+
should result in a lot of additional testing for the solver and while also improving
138+
the IDE experience by positively impacting performance and correctness.
139+
140+
We intend to slowly roll out the solver in other areas of the compiler until we're able
141+
to fully remove the existing implementation by the end of 2025. This switch will fix
142+
multiple unsound issues by itself and will unblock a significant amount of future work.
143+
It will generally cleanup many rough edges of the type system, such as associated types
144+
in higher-ranked types. There are many unsound issues which can only be fixed once we exclusively
145+
use the new implementation.
146+
147+
### `a-mir-formality`
148+
149+
* [`a-mir-formality` project goal](https://rust-lang.github.io/rust-project-goals/2024h2/a-mir-formality.html)
150+
151+
We intend to more actively develop `a-mir-formality` this year to use it in our design process.
152+
Using it to model parts of the type system has already been incredibly impactful and we want
153+
to build on that. We are working on more effective testing of `a-mir-formality` by enabling its
154+
use for actual Rust code snippets and by adding fuzzing support. This will allow us to gain
155+
additional confidence in our model of the type system and will guide its future development.
156+
157+
We plan to fully formalize some components of the type system this year. Coherence is fairly
158+
self-contained, very subtle, and soundness-critical. This has prevented us from making significant
159+
improvements to it in the past. We also intend to formalize coinductive trait semantics, which are
160+
difficult to reason about and necessary to fix many longstanding soundness issues.
161+
162+
### Language changes and polonius
163+
164+
* [Associated Type Position Impl Trait (ATPIT) project goal](https://rust-lang.github.io/rust-project-goals/2024h2/ATPIT.html)
165+
* [Polonius on Nightly project goal](https://rust-lang.github.io/rust-project-goals/2024h2/Polonius.html)
166+
167+
We intend to get the internal implementation of opaque types ready for the stabilization
168+
of TAIT and ATPIT this year. We are also hoping to land significant improvements to our
169+
handling of associated types in coherence checking this year.
170+
171+
Our other goal is to get [Polonius], the next generation borrow checker, available on nightly, which would put us in a position to stabilize in 2025 once we have time to do more optimization and testing.
172+
173+
[polonius]: https://blog.rust-lang.org/inside-rust/2023/10/06/polonius-update.html
174+
175+
We also intend to support the development of other language features, such as `async`-closures, which are part of the [async project goal](https://rust-lang.github.io/rust-project-goals/2024h2/async.html),
176+
and `dyn`-trait upcasting, which will hopefully get stabilized in the near future.
177+
178+
## Roadmap
179+
180+
### EOY 2024
181+
182+
- next-generation trait solver
183+
- stable in coherence
184+
- used by rust-analyzer
185+
- ATPIT stabilized
186+
- a-mir-formality
187+
- support for fuzzing and testing Rust snippets
188+
- complete model of coherence and coinductive trait semantics
189+
- full polonius implementation available on nightly
190+
191+
### EOY 2025
192+
193+
- next-generation trait solver used everywhere by default
194+
- TAIT stabilized
195+
- polonius stabilized
196+
197+
## EOY 2027
198+
199+
- next-generation trait solver
200+
- support for coinduction and (implicit) where-bounds on `for<'a>`
201+
- enable perfect derive
202+
- a-mir-formality fully model soundness critical parts of Rust
203+
- all known type system unsoundnesses fixed
204+
205+
206+
[TypesAnnouncement]: https://blog.rust-lang.org/2023/01/20/types-announcement.html
207+
[PrevRoadmap]: https://blog.rust-lang.org/2023/01/20/types-announcement.html#roadmap
208+
[InitiativeUpdate]: https://blog.rust-lang.org/inside-rust/2023/12/22/trait-system-refactor-initiative.html
209+
[InitiativeRepo]: https://github.com/rust-lang/trait-system-refactor-initiative/
210+
[devGuide]: https://rustc-dev-guide.rust-lang.org/solve/trait-solving.html
211+
[`a-mir-formality`]: https://github.com/rust-lang/a-mir-formality
212+
[FCPs]: https://github.com/rust-lang/rust/pulls?q=is%3Apr+label%3AT-types+label%3Adisposition-merge+is%3Amerged+closed%3A%3E2023-01-20+sort%3Acreated-asc+
213+
[NewSolver]: https://github.com/rust-lang/rust/pulls?q=is%3Apr+label%3AWG-trait-system-refactor+-label%3Arollup+is%3Amerged+closed%3A%3E2023-01-20+sort%3Acreated-asc+
214+
[StabilizeNS]: https://github.com/rust-lang/rust/pull/121848
215+
[unsoundCat]: https://github.com/orgs/rust-lang/projects/44/views/1
216+
[chalk]: https://github.com/rust-lang/chalk/
217+
218+
[@aliemjay]: https://github.com/aliemjay
219+
[@BoxyUwU]: https://github.com/boxyuwu
220+
[@compiler-errors]: https://github.com/compiler-errors
221+
[@oli-obk]: https://github.com/oli-obk
222+
[@spastorino]: https://github.com/spastorino
223+
[@cjgillot]: https://github.com/cjgillot
224+
225+
[^107421]: stabilized in https://github.com/rust-lang/rust/issues/107421
226+
[^117703]: stabilized in https://github.com/rust-lang/rust/issues/117703

0 commit comments

Comments
 (0)