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
Copy file name to clipboardExpand all lines: dev-guide/src/rules/index.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,6 +33,7 @@ When assigning rules to new paragraphs or modifying rule names, use the followin
33
33
-`intro`: The beginning paragraph of each section. It should explain the construct being defined overall.
34
34
-`syntax`: Syntax definitions or explanations when BNF syntax definitions are not used.
35
35
-`namespace`: For items only, specifies the namespace(s) the item introduces a name in. It may also be used elsewhere when defining a namespace (e.g., `r[attribute.diagnostic.namespace]`).
36
+
-`diverging`: The divergence behavior of an expression. Be sure to update the Divergence chapter, too.
36
37
6. When a rule doesn't fall under the above keywords, or for section rule IDs, name the subrule as follows:
37
38
- If the rule names 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).
38
39
- Other than Rust language concepts with `_`s in the name, use `-` characters to separate words within a "subrule".
An array expression [diverges] if any of its operands diverges.
77
+
75
78
r[expr.array.index]
76
79
## Array and slice indexing expressions
77
80
@@ -113,6 +116,35 @@ arr[10]; // warning: index out of bounds
113
116
r[expr.array.index.trait-impl]
114
117
The array index expression can be implemented for types other than arrays and slices by implementing the [Index] and [IndexMut] traits.
115
118
119
+
r[expr.array.index.diverging]
120
+
An index expression [diverges] if either of its operands diverges, or if the type of the indexed element is the [never type] and the value is guaranteed to be read.
Copy file name to clipboardExpand all lines: src/expressions/block-expr.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -191,6 +191,9 @@ The actual data format for this type is unspecified.
191
191
> [!NOTE]
192
192
> 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.
193
193
194
+
r[expr.block.async.diverging]
195
+
An async block expression does not itself [diverge], but evaluating the future (such as through `await`) diverges if the output type is the [never type].
196
+
194
197
r[expr.block.async.edition2018]
195
198
> [!EDITION-2018]
196
199
> Async blocks are only available beginning with Rust 2018.
Copy file name to clipboardExpand all lines: src/expressions/field-expr.md
+39Lines changed: 39 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,6 +42,43 @@ foo().x;
42
42
(mystruct.function_field)() // Call expression containing a field expression
43
43
```
44
44
45
+
r[expr.field.diverging]
46
+
A field expression [diverges] if its expression operand diverges or if the type of the field is the [never type] and the value is guaranteed to be read.
Copy file name to clipboardExpand all lines: src/expressions/if-expr.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -73,6 +73,8 @@ assert_eq!(y, "Bigger");
73
73
r[expr.if.diverging]
74
74
An `if` expression [diverges] if either the condition expression diverges or if all arms diverge.
75
75
76
+
The condition expression diverges if the leftmost condition in the `&&` chain diverges, where `let` patterns are considered to diverge if the scrutinee diverges.
77
+
76
78
```rust,no_run
77
79
fn diverging_condition() -> ! {
78
80
// Diverges because the condition expression diverges
0 commit comments