|
| 1 | +- Feature Name: `rust_spec` |
| 2 | +- Start Date: 2022-12-06 |
| 3 | +- RFC PR: [rust-lang/rfcs#3355](https://github.com/rust-lang/rfcs/pull/3355) |
| 4 | +- Rust Issue: [rust-lang/rust#113527](https://github.com/rust-lang/rust/issues/113527) |
| 5 | + |
| 6 | +# Summary |
| 7 | +[summary]: #summary |
| 8 | + |
| 9 | +We should start working on a Rust specification. |
| 10 | + |
| 11 | +# Goal of this RFC |
| 12 | + |
| 13 | +The goal of this RFC is to reach consensus on: |
| 14 | + |
| 15 | +- Whether we want a specification, and (if so), |
| 16 | +- Some initial goals and non-goals, and |
| 17 | +- How we want the work to be organised and coordinated. |
| 18 | + |
| 19 | +This RFC _does not_ define the full scope of the specification |
| 20 | +or discuss any details of how it would look like. |
| 21 | +It only provides the minimal details necessary to be able to kick off the Rust specification work. |
| 22 | + |
| 23 | +# Motivation |
| 24 | + |
| 25 | +Why do we want a Rust specification at all? |
| 26 | + |
| 27 | +There are many different kind of Rust users that would benefit from a Rust specification in their own way. |
| 28 | +Things like the Rust Reference, the Unsafe Code Guidelines Project, the Rustonomicon, and so on, |
| 29 | +all exist to fulfill certain needs of Rust users. |
| 30 | +Unfortunately, their use is currently limited, because none of these are complete, entirely accurate, or normative. |
| 31 | + |
| 32 | +Authors of unsafe code could benefit a lot from clear definitions of what is and isn't undefined behaviour. |
| 33 | +Safety critical Rust software won't pass certification without a specification that clearly specifies how Rust code behaves. |
| 34 | +Proposals and discussions about new Rust language features could be more efficient and precise |
| 35 | +using accurately defined terms that everyone agrees on. |
| 36 | +Questions about subtle interactions between features of the language could be answered |
| 37 | +using precise information from a specification, instead a combination of guesses and several non-authoritative sources. |
| 38 | + |
| 39 | +# Current state |
| 40 | + |
| 41 | +Languages like C and C++ are standardized. |
| 42 | +Rust is not. Standardization comes down to, basically: |
| 43 | + |
| 44 | +1. Having an accurate specification (a document) |
| 45 | +2. An (open) process for evolution of the language |
| 46 | +3. Stability |
| 47 | + |
| 48 | +Rust currently already has 2 and 3, but not 1. |
| 49 | + |
| 50 | +For 1, we currently have: |
| 51 | +the (incomplete) [Rust Reference](https://doc.rust-lang.org/stable/reference/), |
| 52 | +the [Standard Library Reference Documentation](https://doc.rust-lang.org/stable/std/), |
| 53 | +the [Rust Nomicon](https://doc.rust-lang.org/nightly/nomicon/), |
| 54 | +the [Unsafe Code Guidelines Project](https://github.com/rust-lang/unsafe-code-guidelines/), |
| 55 | +[Miri](https://github.com/rust-lang/miri/), |
| 56 | +the collection of [accepted RFCs](https://rust-lang.github.io/rfcs/), |
| 57 | +the [Ferrocene Language Specification](https://spec.ferrocene.dev/), |
| 58 | +lots context and decisions spread over [tons of GitHub issues](https://github.com/rust-lang/rust/issues/), |
| 59 | +[MiniRust](https://github.com/RalfJung/minirust), |
| 60 | +the [source code](https://github.com/rust-lang/rust/), |
| 61 | +and more. |
| 62 | + |
| 63 | +These are currently all incomplete, and/or not a good source to rely on. |
| 64 | + |
| 65 | +More background information is available in [this blog post](https://blog.m-ou.se/rust-standard/). |
| 66 | + |
| 67 | +# Goals and non-goals |
| 68 | + |
| 69 | +- The goal of the Rust specification work is the creation of a document, the Rust specification. |
| 70 | + |
| 71 | +- The goal is _not_ to change how the language evolves; |
| 72 | + the relevant teams (Language, Libs-API, …) remain in charge of the evolution of their respective parts of Rust, |
| 73 | + and will continue to use processes as they see fit (e.g. RFCs). |
| 74 | + |
| 75 | +- The specification will only be considered "official" once the relevant teams have approved of its contents. |
| 76 | + Changes to the official specification must be approved by the relevant team(s). |
| 77 | + |
| 78 | +- The goal is to serve the needs of Rust users, such as |
| 79 | + authors of unsafe Rust code, those working on safety critical Rust software, |
| 80 | + language designers, maintainers of Rust tooling, and so on. |
| 81 | + |
| 82 | +- It is _not_ a primary goal of the specification to aid in the development of alternative Rust implementations, |
| 83 | + although authors of alternative compilers might still find the specification to be useful. |
| 84 | + |
| 85 | + What this means is that, unlike the C or C++ standard, |
| 86 | + the Rust specification does not provide a set of requirements for a compiler to be able to call itself "a Rust™ compiler". |
| 87 | + Instead, it specifies the behaviour of the Rust compiler. |
| 88 | + (So, not "A Rust implementation should …", but instead "Rust will …".) |
| 89 | + |
| 90 | +- The scope remains to be determined, but at least includes all topics currently included in |
| 91 | + the (incomplete) [Rust Reference](https://doc.rust-lang.org/stable/reference/). |
| 92 | + |
| 93 | +- The Rust specification is expected to replace the current Rust Reference. |
| 94 | + |
| 95 | +- The scope of the specification can grow over time, depending on the needs of Rust users and |
| 96 | + time and motivation of those working on it. |
| 97 | + |
| 98 | + For example, it might grow over time to also specify details of Cargo, |
| 99 | + compiler flags, procedural macros, or other parts that we might initially consider out of scope. |
| 100 | + |
| 101 | +- The specification is specific to the latest version of Rust. |
| 102 | + A copy of the specification is included with each Rust release, |
| 103 | + as we currently already do with much of our documentation. |
| 104 | + |
| 105 | + While the specification might include notes about the Rust version that a feature was introduced in |
| 106 | + for informative purposes (similar to standard library documentation), |
| 107 | + it does not attempt to accurately specify older, unsupported versions of Rust. |
| 108 | + |
| 109 | +- The specification specifies all Rust _editions_, as supported by the latest version of the Rust compiler. |
| 110 | + |
| 111 | +- Once the specification reaches an initial usable version, |
| 112 | + the relevant teams are expected to incorporate it in their process for language evolution. |
| 113 | + For example, the language team could require a new language feature to be included |
| 114 | + in the specification as a requirement for stabilization. |
| 115 | + |
| 116 | +- The specification will be written in English and will be freely available under a permissive license |
| 117 | + that allows for translations and other derived works, just like all our existing documentation and code. |
| 118 | + |
| 119 | +# Coordination and editing |
| 120 | + |
| 121 | +Writing, editing, and in general coordinating all that's necessary for the creation of a Rust specification is a large amount for work. |
| 122 | +While there are many volunteers willing to work on specific parts of it, |
| 123 | +it's unlikely we'd end up with a complete, consistent, properly maintained specification if we rely entirely on volunteers. |
| 124 | + |
| 125 | +So this RFC proposes that we ask the Rust Foundation to coordinate and take responsibility |
| 126 | +for the parts of the work that would otherwise not get done. |
| 127 | +The foundation should hire a technical editor |
| 128 | +who will work with the Rust teams and contributors to create the Rust specification. |
| 129 | +The editor will be responsible for maintaining the document and will coordinate with the relevant teams |
| 130 | +(e.g. the language team, the operational semantics team, the compiler, the types team, the library API team, and so on) |
| 131 | +to collect all relevant information and make sure that consensus is reached on everything that will end up in the official specification. |
| 132 | + |
| 133 | +The relevant Rust teams keep authority on their respective parts of Rust. |
| 134 | +The Rust Foundation supports and coordinates the work, but the Rust teams will remain in charge of what Rust is. |
| 135 | + |
| 136 | +## Role of the Editor |
| 137 | + |
| 138 | +The role of the editor is more than just a technical writer; the editor will be a leader in the specification development process. |
| 139 | + |
| 140 | +The tasks of the editor (as [suggested by Joel](https://github.com/rust-lang/rfcs/pull/3355#issuecomment-1481813621)): |
| 141 | + |
| 142 | +1. *Active coordination and management of the specification process*. |
| 143 | + Working with project members, an editor dedicated to the specification will |
| 144 | + work to ensure that there is continuous progress on the specification itself, |
| 145 | + through activities like coordinating meetings, suggesting relevant topics of |
| 146 | + discussion, managing the infrastructure around the creation of the |
| 147 | + specification. |
| 148 | + |
| 149 | +2. *Collecting and aggregating information from spec-relevant Project teams*. |
| 150 | + Related to the coordination and management of the process, the editor will have |
| 151 | + an ear in all the relevant Project teams that have members working on the |
| 152 | + specification in order to understand their thoughts, ideas and requirements. |
| 153 | + The editor will aggregate this information to use during the specification |
| 154 | + process. The editor will work closely with Project teams such as the Language |
| 155 | + team, the Operational Semantics team, etc. to ensure, for example, |
| 156 | + specification proposals can be officially approved for inclusion into the |
| 157 | + specification. To be clear the editor is not necessarily a member of any |
| 158 | + particular team, but will work with those teams to ensure they are represented |
| 159 | + well and fairly in the specification. |
| 160 | + |
| 161 | +3. *Technical writing*. |
| 162 | + The editor actually has to incorporate the concepts and write the words that |
| 163 | + will ultimately make up the specification. The reason that this is not |
| 164 | + necessarily the top priority is that without the coordination and information |
| 165 | + gathering, this cannot be done in any meaningful way. But, obviously, this is |
| 166 | + where the rubber meets the road and where the final output will be made. The |
| 167 | + editor, in conjunction with any potential required ancillary design or |
| 168 | + copyediting resources, will produce a developer and community friendly Rust |
| 169 | + language specification. |
| 170 | + |
| 171 | +4. *Reporting progress*. |
| 172 | + Since not everyone in the Project will be involved in the specification process |
| 173 | + on a daily basis and with the expected interest within the Rust community, the |
| 174 | + editor will provide regular status updates on the progress of the |
| 175 | + specification. The vehicle by which this will be done is to be determined, but |
| 176 | + you can imagine public blog posts, a dedicated Zulip stream, etc. |
| 177 | + |
| 178 | +5. *Propose technical clarifications and corrections to the specification*. |
| 179 | + As we work on the specification, there is a reasonable probability that we may |
| 180 | + find areas that are unclear, confusing and maybe even contradictory. While not |
| 181 | + a hard requirement and more of a nice-to-have, optimally the editor will be |
| 182 | + well-versed in programming languages and can offer potential clarifications and |
| 183 | + corrections for technical correctness and consistency purposes. |
| 184 | + |
| 185 | +# Questions deliberately left open |
| 186 | + |
| 187 | +This RFC deliberately leaves many questions open, to be answered later in the process. |
| 188 | +For example: |
| 189 | + |
| 190 | +- The starting point of the Rust specification. |
| 191 | + |
| 192 | + The Rust specification could take the [Ferrocene Specification](https://spec.ferrocene.dev/) or |
| 193 | + the [Rust Reference](https://doc.rust-lang.org/stable/reference/) as starting point, |
| 194 | + or start from scratch, as the editor sees fit. |
| 195 | + (The contents will still require approval from the Rust teams, regardless.) |
| 196 | + |
| 197 | +- The shape, form, and structure of the document. |
| 198 | + |
| 199 | +- The scope of the Rust specification. |
| 200 | + |
| 201 | + It should include at least all topics covered in |
| 202 | + [the Rust Reference](https://doc.rust-lang.org/stable/reference/), |
| 203 | + but the scope can grow depending on ongoing efforts in the Rust team and the needs of the Rust community. |
| 204 | + |
| 205 | +- How certain topics will be specified. |
| 206 | + |
| 207 | + Certain parts of the specification might use a formal language |
| 208 | + for specifying behavior or syntax. |
| 209 | + For example, the grammar might be specified as EBNF, |
| 210 | + and parts of the borrow checker or memory model might be specified by |
| 211 | + a more formal definition that the document refers to. |
| 212 | + |
| 213 | +- The depth of the specification for various topics. |
| 214 | + |
| 215 | + For example, it might specify only the existence of `#[allow(…)]` (etc.) without naming any lints, |
| 216 | + or at the other extreme it might fully specify the behaviour of every single lint. |
| 217 | + As another example, it could only specify the overall guarantees of the borrow checker |
| 218 | + (e.g. "it won't allow UB in safe code"), or it could precisely specify what currently is and isn't accepted by the borrow checker. |
| 219 | + The right level of detail for each topic should be discussed and agreed upon by the involved parties, |
| 220 | + and can change over time. |
| 221 | + |
| 222 | +- Naming. |
| 223 | + |
| 224 | + The exact title of the document might carry significance depending on how it will be used. |
| 225 | + Before we officially publish a non-draft version of the specification, we |
| 226 | + should come to an agreement on whether to call it "The Rust Specification" or something else. |
0 commit comments