Skip to content

Commit 2ed1937

Browse files
Merge pull request #1044 from AloeareV/make_scrutinee_explicit
Make explicit reference to scrutinee expression in grammar snippet
2 parents 1388c1f + 86b8eb1 commit 2ed1937

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

src/expressions/if-expr.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ assert_eq!(y, "Bigger");
4141

4242
> **<sup>Syntax</sup>**\
4343
> _IfLetExpression_ :\
44-
> &nbsp;&nbsp; `if` `let` [_Pattern_] `=` [_Expression_]<sub>_except struct or lazy boolean operator expression_</sub>
44+
> &nbsp;&nbsp; `if` `let` [_Pattern_] `=` [_Scrutinee_]<sub>_except lazy boolean operator expression_</sub>
4545
> [_BlockExpression_]\
4646
> &nbsp;&nbsp; (`else` (
4747
> [_BlockExpression_]
@@ -148,6 +148,7 @@ if let PAT = ( EXPR || EXPR ) { .. }
148148
[_Expression_]: ../expressions.md
149149
[_LazyBooleanOperatorExpression_]: operator-expr.md#lazy-boolean-operators
150150
[_Pattern_]: ../patterns.md
151+
[_Scrutinee_]: match-expr.md
151152
[_eRFCIfLetChain_]: https://github.com/rust-lang/rfcs/blob/master/text/2497-if-let-chains.md#rollout-plan-and-transitioning-to-rust-2018
152153
[`match` expression]: match-expr.md
153154
[boolean type]: ../types/boolean.md

src/expressions/loop-expr.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@ while i < 10 {
6262

6363
> **<sup>Syntax</sup>**\
6464
> [_PredicatePatternLoopExpression_] :\
65-
> &nbsp;&nbsp; `while` `let` [_Pattern_] `=` [_Expression_]<sub>_except struct or lazy boolean operator expression_</sub>
65+
> &nbsp;&nbsp; `while` `let` [_Pattern_] `=` [_Scrutinee_]<sub>_except lazy boolean operator expression_</sub>
6666
> [_BlockExpression_]
6767
68+
6869
A `while let` loop is semantically similar to a `while` loop but in place of a condition expression it expects the keyword `let` followed by a pattern, an `=`, a [scrutinee] expression and a block expression.
6970
If the value of the scrutinee matches the pattern, the loop body block executes then control returns to the pattern matching statement.
7071
Otherwise, the while expression completes.
@@ -264,6 +265,7 @@ In the case a `loop` has an associated `break`, it is not considered diverging,
264265
[_BlockExpression_]: block-expr.md
265266
[_Expression_]: ../expressions.md
266267
[_Pattern_]: ../patterns.md
268+
[_Scrutinee_]: match-expr.md
267269
[`match` expression]: match-expr.md
268270
[boolean]: ../types/boolean.md
269271
[scrutinee]: ../glossary.md#scrutinee

src/expressions/match-expr.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22

33
> **<sup>Syntax</sup>**\
44
> _MatchExpression_ :\
5-
> &nbsp;&nbsp; `match` [_Expression_]<sub>_except struct expression_</sub> `{`\
5+
> &nbsp;&nbsp; `match` _Scrutinee_ `{`\
66
> &nbsp;&nbsp; &nbsp;&nbsp; [_InnerAttribute_]<sup>\*</sup>\
77
> &nbsp;&nbsp; &nbsp;&nbsp; _MatchArms_<sup>?</sup>\
88
> &nbsp;&nbsp; `}`
99
>
10+
>_Scrutinee_ :\
11+
> &nbsp;&nbsp; [_Expression_]<sub>_except struct expression_</sub>
12+
>
1013
> _MatchArms_ :\
1114
> &nbsp;&nbsp; ( _MatchArm_ `=>`
1215
> ( [_ExpressionWithoutBlock_][_Expression_] `,`

0 commit comments

Comments
 (0)