From 6b90080371ff44d0074a465945dfdb0de4b50774 Mon Sep 17 00:00:00 2001 From: Frank Steffahn Date: Wed, 4 Mar 2020 18:34:32 +0100 Subject: [PATCH] Fix expression and statement grammar. Semicolon or comma in expression statements or match arms, respectively, are optional, but part of the statement / match arm. Also remove a note about proc-macros from the page about BlockExpression. Closes #773 and closes #774. --- src/expressions/block-expr.md | 3 --- src/expressions/match-expr.md | 7 +++---- src/statements.md | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/expressions/block-expr.md b/src/expressions/block-expr.md index c35c3d678..291634f3c 100644 --- a/src/expressions/block-expr.md +++ b/src/expressions/block-expr.md @@ -28,9 +28,6 @@ a following semicolon except if its outer expression is a flow control expression. Furthermore, extra semicolons between statements are allowed, but these semicolons do not affect semantics. -> Note: The semicolon following a statement is not a part of the statement -> itself. They are invalid when using the `stmt` macro matcher. - When evaluating a block expression, each statement, except for item declaration statements, is executed sequentially. Then the final expression is executed, if given. diff --git a/src/expressions/match-expr.md b/src/expressions/match-expr.md index dcbf69fe7..9a0cb8d61 100644 --- a/src/expressions/match-expr.md +++ b/src/expressions/match-expr.md @@ -9,10 +9,10 @@ > > _MatchArms_ :\ >    ( _MatchArm_ `=>` -> ( [_BlockExpression_] `,`? -> | [_Expression_] `,` ) +> ( [_ExpressionWithoutBlock_][_Expression_] `,` +> | [_ExpressionWithBlock_][_Expression_] `,`? ) > )\*\ ->    _MatchArm_ `=>` ( [_BlockExpression_] | [_Expression_] ) `,`? +>    _MatchArm_ `=>` [_Expression_] `,`? > > _MatchArm_ :\ >    [_OuterAttribute_]\* _MatchArmPatterns_ _MatchArmGuard_? @@ -146,7 +146,6 @@ expression in the same expression contexts as [attributes on block expressions]. [_Expression_]: ../expressions.md -[_BlockExpression_]: block-expr.md#block-expressions [place expression]: ../expressions.md#place-expressions-and-value-expressions [value expression]: ../expressions.md#place-expressions-and-value-expressions [_InnerAttribute_]: ../attributes.md diff --git a/src/statements.md b/src/statements.md index 9b5bd94f1..5d8e0e95d 100644 --- a/src/statements.md +++ b/src/statements.md @@ -69,7 +69,7 @@ from the point of declaration until the end of the enclosing block scope. > **Syntax**\ > _ExpressionStatement_ :\ >       [_ExpressionWithoutBlock_][expression] `;`\ ->    | [_ExpressionWithBlock_][expression] +>    | [_ExpressionWithBlock_][expression] `;`? An *expression statement* is one that evaluates an [expression] and ignores its result. As a rule, an expression statement's purpose is to trigger the effects