Skip to content

Commit

Permalink
Merge pull request #1044 from AloeareV/make_scrutinee_explicit
Browse files Browse the repository at this point in the history
Make explicit reference to scrutinee expression in grammar snippet
  • Loading branch information
ehuss authored Jun 21, 2021
2 parents 7f79944 + ac4ff0f commit d9699fa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/expressions/if-expr.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ assert_eq!(y, "Bigger");

> **<sup>Syntax</sup>**\
> _IfLetExpression_ :\
> &nbsp;&nbsp; `if` `let` [_Pattern_] `=` [_Expression_]<sub>_except struct or lazy boolean operator expression_</sub>
> &nbsp;&nbsp; `if` `let` [_Pattern_] `=` [_Scrutinee_]<sub>_except lazy boolean operator expression_</sub>
> [_BlockExpression_]\
> &nbsp;&nbsp; (`else` (
> [_BlockExpression_]
Expand Down Expand Up @@ -148,6 +148,7 @@ if let PAT = ( EXPR || EXPR ) { .. }
[_Expression_]: ../expressions.md
[_LazyBooleanOperatorExpression_]: operator-expr.md#lazy-boolean-operators
[_Pattern_]: ../patterns.md
[_Scrutinee_]: match-expr.md
[_eRFCIfLetChain_]: https://github.com/rust-lang/rfcs/blob/master/text/2497-if-let-chains.md#rollout-plan-and-transitioning-to-rust-2018
[`match` expression]: match-expr.md
[boolean type]: ../types/boolean.md
Expand Down
4 changes: 3 additions & 1 deletion src/expressions/loop-expr.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ while i < 10 {

> **<sup>Syntax</sup>**\
> [_PredicatePatternLoopExpression_] :\
> &nbsp;&nbsp; `while` `let` [_Pattern_] `=` [_Expression_]<sub>_except struct or lazy boolean operator expression_</sub>
> &nbsp;&nbsp; `while` `let` [_Pattern_] `=` [_Scrutinee_]<sub>_except lazy boolean operator expression_</sub>
> [_BlockExpression_]

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.
If the value of the scrutinee matches the pattern, the loop body block executes then control returns to the pattern matching statement.
Otherwise, the while expression completes.
Expand Down Expand Up @@ -264,6 +265,7 @@ In the case a `loop` has an associated `break`, it is not considered diverging,
[_BlockExpression_]: block-expr.md
[_Expression_]: ../expressions.md
[_Pattern_]: ../patterns.md
[_Scrutinee_]: match-expr.md
[`match` expression]: match-expr.md
[boolean]: ../types/boolean.md
[scrutinee]: ../glossary.md#scrutinee
Expand Down
5 changes: 4 additions & 1 deletion src/expressions/match-expr.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

> **<sup>Syntax</sup>**\
> _MatchExpression_ :\
> &nbsp;&nbsp; `match` [_Expression_]<sub>_except struct expression_</sub> `{`\
> &nbsp;&nbsp; `match` _Scrutinee_ `{`\
> &nbsp;&nbsp; &nbsp;&nbsp; [_InnerAttribute_]<sup>\*</sup>\
> &nbsp;&nbsp; &nbsp;&nbsp; _MatchArms_<sup>?</sup>\
> &nbsp;&nbsp; `}`
>
>_Scrutinee_ :\
> &nbsp;&nbsp; [_Expression_]<sub>_except struct expression_</sub>
>
> _MatchArms_ :\
> &nbsp;&nbsp; ( _MatchArm_ `=>`
> ( [_ExpressionWithoutBlock_][_Expression_] `,`
Expand Down

0 comments on commit d9699fa

Please sign in to comment.