You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This adds admonition syntax for edition differences blocks so that they
have a uniform formatting.
This also slightly changes the naming rules so that the block is labeled
with the edition where the behavior *changed*, so that it syncs up with
how we document editions in the edition guide.
Copy file name to clipboardExpand all lines: docs/authoring.md
+8-2
Original file line number
Diff line number
Diff line change
@@ -95,7 +95,7 @@ When assigning rules to new paragraphs, or when modifying rule names, use the fo
95
95
* If the rule is naming a specific Rust language construct (e.g. an attribute, standard library type/function, or keyword-introduced concept), use the construct as named in the language, appropriately case-adjusted (but do not replace `_`s with `-`s).
96
96
* Other than Rust language concepts with `_`s in the name, use `-` characters to separate words within a "subrule".
97
97
* Whenever possible, do not repeat previous components of the rule.
98
-
* Edition differences admonitions should typically be named by the edition referenced directly by the rule. If multiple editions are named, use the one for which the behavior is defined by the admonition, and not by a previous paragraph.
98
+
* Edition differences admonitions should typically be named by the edition where the behavior changed. You should be able to correspond the dates to the chapters in <https://doc.rust-lang.org/edition-guide/>.
99
99
* Target specific admonitions should typically be named by the least specific target property to which they apply (e.g. if a rule affects all x86 CPUs, the rule name should include `x86` rather than separately listing `i586`, `i686` and `x86_64`, and if a rule applies to all ELF platforms, it should be named `elf` rather than listing every ELF OS).
100
100
* Use an appropriately descriptive, but short, name if the language does not provide one.
101
101
@@ -197,4 +197,10 @@ The reference does not document which targets exist, or the properties of specif
197
197
198
198
### Editions
199
199
200
-
The main text and flow should document only the current edition. Whenever there is a difference between editions, the differences should be called out with an "Edition differences" block.
200
+
The main text and flow should document only the current edition. Whenever there is a difference between editions, the differences should be called out with an edition block, such as:
Copy file name to clipboardExpand all lines: src/destructors.md
+2-1
Original file line number
Diff line number
Diff line change
@@ -215,7 +215,8 @@ smallest scope that contains the expression and is one of the following:
215
215
> The [scrutinee] of a `match` expression is not a temporary scope, so temporaries in the scrutinee can be dropped after the `match` expression. For example, the temporary for `1` in `match 1 { ref mut z => z };` lives until the end of the statement.
216
216
217
217
r[destructors.scope.temporary.edition2024]
218
-
> **Edition differences**: The 2024 edition added two new temporary scope narrowing rules: `if let` temporaries are dropped before the `else` block, and temporaries of tail expressions of blocks are dropped immediately after the tail expression is evaluated.
218
+
> [!EDITION-2024]
219
+
> The 2024 edition added two new temporary scope narrowing rules: `if let` temporaries are dropped before the `else` block, and temporaries of tail expressions of blocks are dropped immediately after the tail expression is evaluated.
Copy file name to clipboardExpand all lines: src/expressions/await-expr.md
+3-1
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,9 @@ More specifically, an await expression has the following effect.
27
27
5. If the call to `poll` returns [`Poll::Pending`], then the future returns `Poll::Pending`, suspending its state so that, when the surrounding async context is re-polled,execution returns to step 3;
28
28
6. Otherwise the call to `poll` must have returned [`Poll::Ready`], in which case the value contained in the [`Poll::Ready`] variant is used as the result of the `await` expression itself.
29
29
30
-
> **Edition differences**: Await expressions are only available beginning with Rust 2018.
30
+
r[expr.await.edition2018]
31
+
> [!EDITION-2018]
32
+
> Await expressions are only available beginning with Rust 2018.
Copy file name to clipboardExpand all lines: src/expressions/block-expr.md
+3-1
Original file line number
Diff line number
Diff line change
@@ -114,7 +114,9 @@ The actual data format for this type is unspecified.
114
114
> [!NOTE]
115
115
> The future type that rustc generates is roughly equivalent to an enum with one variant per `await` point, where each variant stores the data needed to resume from its corresponding point.
116
116
117
-
> **Edition differences**: Async blocks are only available beginning with Rust 2018.
117
+
r[expr.block.async.edition2018]
118
+
> [!EDITION-2018]
119
+
> Async blocks are only available beginning with Rust 2018.
Copy file name to clipboardExpand all lines: src/introduction.md
+3-2
Original file line number
Diff line number
Diff line change
@@ -78,9 +78,10 @@ These conventions are documented here.
78
78
79
79
An *example term* is an example of a term being defined.
80
80
81
-
*Differences in the language by which edition the crate is compiled under are in a blockquote that start with the words "Edition differences:" in **bold**.
81
+
*The main text describes the latest stable edition. Differences to previous editions are separated in edition blocks:
82
82
83
-
> **Edition differences**: In the 2015 edition, this syntax is valid that is disallowed as of the 2018 edition.
83
+
> [!EDITION-2018]
84
+
> In the 2015 edition, this syntax is valid that is disallowed as of the 2018 edition.
84
85
85
86
* Notes that contain useful information about the state of the book or point out useful, but mostly out of scope, information are in note blocks.
Copy file name to clipboardExpand all lines: src/items/external-blocks.md
+2-1
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,8 @@ r[items.extern.unsafe-required]
36
36
The `unsafe` keyword is semantically required to appear before the `extern` keyword on external blocks.
37
37
38
38
r[items.extern.edition2024]
39
-
> **Edition differences**: Prior to the 2024 edition, the `unsafe` keyword is optional. The `safe` and `unsafe` item qualifiers are only allowed if the external block itself is marked as `unsafe`.
39
+
> [!EDITION-2024]
40
+
> Prior to the 2024 edition, the `unsafe` keyword is optional. The `safe` and `unsafe` item qualifiers are only allowed if the external block itself is marked as `unsafe`.
An empty brace does not import anything, though the leading path is validated that it is accessible.
197
198
<!-- This is slightly wrong, see: https://github.com/rust-lang/rust/issues/61826 -->
198
199
199
-
r[items.use.multiple-syntax.edition2015]
200
-
> **Edition differences**: In the 2015 edition, paths are relative to the crate root, so an import such as `use {foo, bar};` will import the names `foo` and `bar` from the crate root, whereas starting in 2018, those names are relative to the current scope.
200
+
r[items.use.multiple-syntax.edition2018]
201
+
> [!EDITION-2018]
202
+
> In the 2015 edition, paths are relative to the crate root, so an import such as `use {foo, bar};` will import the names `foo` and `bar` from the crate root, whereas starting in 2018, those names are relative to the current scope.
`*` cannot be used to import a module's contents into itself (such as `use self::*;`).
309
311
310
-
r[items.use.glob.edition2015]
311
-
> **Edition differences**: In the 2015 edition, paths are relative to the crate root, so an import such as `use *;` is valid, and it means to import everything from the crate root.
312
+
r[items.use.glob.edition2018]
313
+
> [!EDITION-2018]
314
+
> In the 2015 edition, paths are relative to the crate root, so an import such as `use *;` is valid, and it means to import everything from the crate root.
Copy file name to clipboardExpand all lines: src/macros-by-example.md
+7-4
Original file line number
Diff line number
Diff line change
@@ -160,14 +160,16 @@ The keyword metavariable `$crate` can be used to refer to the current crate; see
160
160
transcribed more than once or not at all.
161
161
162
162
r[macro.decl.meta.edition2021]
163
-
> **Edition differences**: Starting with the 2021 edition, `pat` fragment-specifiers match top-level or-patterns (that is, they accept [_Pattern_]).
163
+
> [!EDITION-2021]
164
+
> Starting with the 2021 edition, `pat` fragment-specifiers match top-level or-patterns (that is, they accept [_Pattern_]).
164
165
>
165
166
> Before the 2021 edition, they match exactly the same fragments as `pat_param` (that is, they accept [_PatternNoTopAlt_]).
166
167
>
167
168
> The relevant edition is the one in effect for the `macro_rules!` definition.
168
169
169
170
r[macro.decl.meta.edition2024]
170
-
> **Edition differences**: Before the 2024 edition, `expr` fragment specifiers do not match [_UnderscoreExpression_] or [_ConstBlockExpression_] at the top level. They are allowed within subexpressions.
171
+
> [!EDITION-2024]
172
+
> Before the 2024 edition, `expr` fragment specifiers do not match [_UnderscoreExpression_] or [_ConstBlockExpression_] at the top level. They are allowed within subexpressions.
171
173
>
172
174
> The `expr_2021` fragment specifier exists to maintain backwards compatibility with editions before 2024.
173
175
@@ -496,7 +498,7 @@ macro_rules! call_foo {
496
498
fnfoo() {}
497
499
```
498
500
499
-
> **Version & Edition differences**: Prior to Rust 1.30, `$crate` and
501
+
> **Version differences**: Prior to Rust 1.30, `$crate` and
500
502
> `local_inner_macros` (below) were unsupported. They were added alongside
501
503
> path-based imports of macros (described above), to ensure that helper macros
502
504
> did not need to be manually imported by users of a macro-exporting crate.
> **Edition differences**: Before the 2024 edition, bindings could explicitly specify a `ref` or `ref mut` binding mode even when the default binding mode was not "move", and they could specify mutability on such bindings with `mut`. In these editions, specifying `mut` on a binding set the binding mode to "move" regardless of the current default binding mode.
337
+
> [!EDITION-2024]
338
+
> Before the 2024 edition, bindings could explicitly specify a `ref` or `ref mut` binding mode even when the default binding mode was not "move", and they could specify mutability on such bindings with `mut`. In these editions, specifying `mut` on a binding set the binding mode to "move" regardless of the current default binding mode.
> **Edition differences**: Before the 2024 edition, reference patterns could appear even when the default binding mode was not "move", and had both the effect of matching against the scrutinee and of causing the default binding mode to be reset to "move".
348
+
> [!EDITION-2024]
349
+
> Before the 2024 edition, reference patterns could appear even when the default binding mode was not "move", and had both the effect of matching against the scrutinee and of causing the default binding mode to be reset to "move".
348
350
349
351
r[patterns.ident.binding.mixed]
350
352
Move bindings and reference bindings can be mixed together in the same pattern.
@@ -669,7 +671,8 @@ _RangeFromPattern_ cannot be used as a top-level pattern for subpatterns in [sli
669
671
For example, the pattern `[1.., _]` is not a valid pattern.
670
672
671
673
r[patterns.range.edition2021]
672
-
> **Edition differences**: Before the 2021 edition, range patterns with both a lower and upper bound may also be written using `...` in place of `..=`, with the same meaning.
674
+
> [!EDITION-2021]
675
+
> Before the 2021 edition, range patterns with both a lower and upper bound may also be written using `...` in place of `..=`, with the same meaning.
0 commit comments