|
5 | 5 | > `;`\
|
6 | 6 | > | [_Item_]\
|
7 | 7 | > | [_LetStatement_]\
|
| 8 | +> | [_LetElseStatement_]\ |
8 | 9 | > | [_ExpressionStatement_]\
|
9 | 10 | > | [_MacroInvocationSemi_]
|
10 | 11 |
|
@@ -65,6 +66,25 @@ inference. Any variables introduced by a variable declaration are visible
|
65 | 66 | from the point of declaration until the end of the enclosing block scope,
|
66 | 67 | except when they are shadowed by another variable declaration.
|
67 | 68 |
|
| 69 | + |
| 70 | +### `let else` statements |
| 71 | + |
| 72 | +> **<sup>Syntax</sup>**\ |
| 73 | +> _LetElseStatement_ :\ |
| 74 | +> [_OuterAttribute_]<sup>\*</sup> `let` [_PatternNoTopAlt_] |
| 75 | +> ( `:` [_Type_] )<sup>?</sup> `=` [_Expression_] `else` [_BlockExpression_] `;` |
| 76 | +
|
| 77 | +A *`let else` statement* introduces a new set of [variables], given by a |
| 78 | +refutable [pattern]. The pattern is followed optionally by a type |
| 79 | +annotation. When no type annotation is given, the compiler will infer the type, |
| 80 | +or signal an error if insufficient type information is available for definite |
| 81 | +inference. It is is then followed by an initializer expression as well as a |
| 82 | +diverging `else` block. |
| 83 | + |
| 84 | +Any variables introduced by a variable declaration are visible |
| 85 | +from the point of declaration until the end of the enclosing block scope, |
| 86 | +except when they are shadowed by another variable declaration. |
| 87 | + |
68 | 88 | ## Expression statements
|
69 | 89 |
|
70 | 90 | > **<sup>Syntax</sup>**\
|
@@ -128,10 +148,12 @@ statement are [`cfg`], and [the lint check attributes].
|
128 | 148 | [`cfg`]: conditional-compilation.md
|
129 | 149 | [the lint check attributes]: attributes/diagnostics.md#lint-check-attributes
|
130 | 150 | [pattern]: patterns.md
|
| 151 | +[_BlockExpression_]: expressions/block-expr.md |
131 | 152 | [_ExpressionStatement_]: #expression-statements
|
132 | 153 | [_Expression_]: expressions.md
|
133 | 154 | [_Item_]: items.md
|
134 | 155 | [_LetStatement_]: #let-statements
|
| 156 | +[_LetElseStatement_]: #let-else-statements |
135 | 157 | [_MacroInvocationSemi_]: macros.md#macro-invocation
|
136 | 158 | [_OuterAttribute_]: attributes.md
|
137 | 159 | [_PatternNoTopAlt_]: patterns.md
|
|
0 commit comments