Skip to content

Commit ef95794

Browse files
joshtripletttshepangtraviscrosslqdnikomatsakis
authored
Add goal for expansion of the Rust Reference (#336)
* Add goal for expansion of the Rust Reference * Typo fixes Co-authored-by: Tshepang Mbambo <[email protected]> * Add lang-docs as a team Co-authored-by: Travis Cross <[email protected]> * Update design principles for reference goal to better reflect reference processes Based on joint iteration by @traviscross and @joshtriplett. The new text addresses all the same concerns as the old text (notably making sure that we don't let the perfect become a blocker on the good), but lays out much more detailed processes, and avoids potentially incorrect or misleading implications about the normativity of the reference. Co-authored-by: Travis Cross <[email protected]> * Add comment about sharing outlines in advance to ease review of large changes Inspired by a suggestion from @ehuss. * Add comment about breaking up larger changes for ease of review Inspired by a suggestion from @ehuss * Linkify URL Co-authored-by: Rémy Rakic <[email protected]> * Linkify URL Co-authored-by: Rémy Rakic <[email protected]> * Linkify URL Co-authored-by: Rémy Rakic <[email protected]> * Update src/2025h2/reference-expansion.md Co-authored-by: Rémy Rakic <[email protected]> --------- Co-authored-by: Tshepang Mbambo <[email protected]> Co-authored-by: Travis Cross <[email protected]> Co-authored-by: Rémy Rakic <[email protected]> Co-authored-by: Niko Matsakis <[email protected]>
1 parent dabe7ff commit ef95794

File tree

1 file changed

+149
-0
lines changed

1 file changed

+149
-0
lines changed

src/2025h2/reference-expansion.md

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# Expand the Rust Reference to specify more aspects of the Rust language
2+
3+
| Metadata | |
4+
| :-- | :-- |
5+
| Point of contact | @joshtriplett |
6+
| Teams | <!-- TEAMS WITH ASKS --> |
7+
| Task owners | <!-- TASK OWNERS --> |
8+
| Status | Proposed |
9+
| Zulip channel | [#t-spec][channel] |
10+
| Tracking issue | |
11+
12+
[channel]: https://rust-lang.zulipchat.com/#narrow/channel/399173-t-spec
13+
14+
## Summary
15+
16+
The Rust Reference (<https://doc.rust-lang.org/nightly/reference/>) describes and
17+
documents the Rust language. The Reference has coverage of many areas of Rust
18+
already, and it has been integrated into language evolution processes, so that
19+
new changes to the language get corresponding updates to the Reference.
20+
However, there are some remaining gaps in the Reference's existing coverage of
21+
Rust.
22+
23+
This project goal proposes to write new chapters for the Reference to fill
24+
these gaps, making its coverage of Rust more comprehensive. This project goal
25+
also proposes to provide additional review bandwidth for other changes, to
26+
ensure that the new material does not overwhelm existing review capacity.
27+
28+
## Motivation
29+
30+
The Rust Reference is one of the core pieces of documentation for Rust. It
31+
serves as documentation for users and implementers alike. The Reference should,
32+
ideally, describe all aspects of the Rust language comprehensively. It is
33+
easier to contribute changes to existing material than large swaths of new
34+
material; the latter is a larger commitment. Thus, this project goal will
35+
coordinate the efforts of several prospective contributors (who have already
36+
been identified and lined up) to write, contribute, and merge new material for
37+
the Reference.
38+
39+
Writing new material for the Reference does not suffice to get it merged,
40+
however. Each change to the Reference requires review and approval, which
41+
sometimes requires calling in additional expertise, and can require more and
42+
scarcer resources. This project goal serves to request such review resources,
43+
and additionally to coordinate contribution of additional review resources in
44+
other areas to share the overall review load, in an effort to alleviate this
45+
and not put as much additional load on existing contributors.
46+
47+
### The status quo
48+
49+
We consulted multiple experts on the Rust Reference, and based on that and on
50+
analysis of the current Rust Reference, some of the key areas of Rust that the
51+
Reference doesn't fully specify (and in some cases no documentation fully
52+
specifies) are:
53+
54+
- The behavior of type inference, including both when the language can infer
55+
types and the boundaries and limitations of when it cannot.
56+
- The trait solver (up to date with the new solver work by @lcnr).
57+
- More details on macros and expansion, in general. Macros-by-example
58+
(declarative `macro_rules!` macros) are mostly covered, but not things like
59+
the exact behavior of proc macros and the general process such as cfg
60+
pruning.
61+
- Name resolution: the process by which the Rust compiler resolves a name used
62+
in Rust code, including methods of traits, and items imported from various
63+
modules in various crates. Name resolution includes various extensions and
64+
special cases that have been added over the years, and the reference should
65+
document those and their behavior.
66+
- Completing documentation of const eval.
67+
68+
#### Out of scope
69+
70+
Other items, which are out of the scope of this project goal:
71+
72+
- The behavior of the borrow checker. This is extensive work that has been the
73+
subject of PhD theses. There have been multiple attempts to document and
74+
bound the behavior of the borrow checker, the latest of which is Tree Borrows
75+
( <https://www.ralfj.de/blog/2023/06/02/tree-borrows.html> ) by Ralf Jung, a
76+
successor to the previous Stacked Borrows model. Specifying this will also
77+
carefully distinguish between description of the current behavior and
78+
bounds on future behavior, as the borrow checker likely will improve further
79+
in the future.
80+
- The operational semantics of the Rust language, which includes the work
81+
formerly described as "unsafe code guidelines". This has been the focus of
82+
the opsem team (<https://github.com/rust-lang/opsem-team>).
83+
84+
Both of these have substantial efforts already working on them. In some cases,
85+
this work is as much about determining and negotiating the correct semantics as
86+
documenting them. These two areas have been the work of years and are unlikely
87+
to get completed or substantively accelerated in the goal period.
88+
89+
### The next 6 months
90+
91+
We propose to have a team of established Rust developers working on different
92+
new chapters of the Reference, writing and contributing material for those
93+
chapters. Along the way, we expect to make various other contributions based on
94+
what turns up during the project period while re-reviewing existing material.
95+
We hope to substantially close the gap between the Reference and the Rust language.
96+
97+
The developers working on this project goal have expert-level knowledge of
98+
multiple areas of Rust, and in several cases, directly worked on the portions
99+
of Rust that need documenting.
100+
101+
We're expecting to coordinate contributions of new reference material from
102+
@lcnr, @jackh726, @Amanieu, @GuillaumeGomez, and @yaahc.
103+
104+
Additional people, who may provide review, mentoring, support, and drafting,
105+
include @joshtriplett, @lcnr, @jackh726, @Amanieu, @GuillaumeGomez, @m-ou-se,
106+
@petrochenkov, @yaahc, @lucarlig, @midiareshadi, @borsakv, and @SparrowLii.
107+
108+
### The "shiny future" we are working towards
109+
110+
We hope to continue providing ongoing support for reference updates in our
111+
areas of expertise, as well as making it easier for others to make ongoing
112+
contributions by providing a starting point. While we don't expect the
113+
Reference to ever be "done" (much as the Rust language will not be), we hope to
114+
substantially close the gap between the Reference and the language.
115+
116+
In the future, we hope that the reference will include full and complete
117+
documentation for all parts of the Rust language, including the borrow checker
118+
and the operational semantics.
119+
120+
## Design axioms
121+
122+
The following [design axioms][da] apply:
123+
* Some documentation may be better suited for the rustc-dev-guide rather than the Rust Reference. If we find ourselves with material better suited for the rustc-dev-guide, we can submit it there, and submit appropriate user-focused subsets of it to the Rust Reference.
124+
* Large changes all at once can be harder to review. When possible, we should endeavor to share outlines of new material in advance, and make sure we're broadly aligned, before writing and submitting full prose. And when feasible and appropriate, we should break up changes into easier-to-review chunks (e.g. individual commits).
125+
* When writing down descriptions of Rust based on the observed current behavior of `rustc`, we sometimes encounter areas where we're not entirely sure whether we want to guarantee the observed behavior as the behavior of Rust. There are two cases:
126+
1. We're unhappy with the current behavior of some edge cases. Here, we will prefer to document the current user-visible behavior while leaving an appropriate disclaimer in the Reference (following conventions of the Reference) that there are open questions about whether we may wish to change this behavior.
127+
2. We're uncertain about whether the behavior represents a stable guarantee or simply a description of one of many behaviors that Rust could validly exhibit. Here, we will describe the current behavior in an explicitly non-normative fashion (following conventions of the Reference), noting specifically that this does not represent a Rust language guarantee and that other behaviors are possible.
128+
* Sometimes, writing things down may uncover behaviors that are clearly bugs in `rustc` (e.g., because those behaviors would be unsound, would contradict other settled language in the Reference, or are otherwise just obviously wrong) and where the correct behavior is obvious (e.g. because it's implied by other text in the Reference, by existing lang RFCs, due to being the only choice, etc.). In these cases, we'll prefer to normatively document the correct behavior, to file the relevant bug report in `rust-lang/rust`, and if appropriate (e.g. because we expect the bug to be longstanding) to add a disclaimer in the Reference (in the standard format) describing the incorrect behavior and citing the bug report.
129+
* Other times, we'll uncover behaviors where either 1) it's unclear whether or not the behavior represents a bug in `rustc` or 2) it probably does represent a bug in `rustc` but it's unclear what the correct behavior is. In these cases, we'll prefer to non-normatively document the current behavior (in the standard way for the Reference), to file an issue in `rust-lang/rust` asking the lang team (potentially along with one of its subteams, as appropriate) to make a decision about what the correct behavior is, and to cite that issue in the Reference.
130+
* Tests demonstrating the behavior being documented, whether as `rust-lang/rust` tests or as tested reference examples, can provide value in making a change easier to review and validate.
131+
* We should be explicit about any material that is primarily descriptive rather than normative.
132+
* We should keep an eye out for potential process improvements that may make it easier to maintain the Reference in the future.
133+
* Jack Huey (@jackh726) will work with T-types and T-compiler on potential process improvements to loop in the Reference when making relevant changes as part of those teams.
134+
135+
[da]: ../about/design_axioms.md
136+
137+
## Ownership and team asks
138+
139+
**Owner:** @joshtriplett, in his capacity as `t-lang` and `t-spec` team member,
140+
will lead this project goal.
141+
142+
| Task | Owner(s) or team(s) | Notes |
143+
|------------------------------------|--------------------------------|---------------------------------|
144+
| Discussion and moral support | ![Team][] [spec][] | |
145+
| New reference chapters | @lcnr, @jackh726, @Amanieu, @GuillaumeGomez, @yaahc | |
146+
| Standard reviews | @joshtriplett, @lcnr, @jackh726, @Amanieu, @GuillaumeGomez, @m-ou-se, @petrochenkov, @yaahc | |
147+
| Standard reviews | ![Team][] [spec][] [lang-docs][] | |
148+
149+
## Frequently asked questions

0 commit comments

Comments
 (0)