44> _ BlockExpression_ :\
55>   ;  ; ` { ` \
66>   ;  ;   ;  ; [ _ InnerAttribute_ ] <sup >\* </sup >\
7- >   ;  ;   ;  ; [ _ Statement_ ] <sup >\* </sup >\
8- >   ;  ;   ;  ; [ _ Expression_ ] <sup >?</sup >\
7+ >   ;  ;   ;  ; _ Statements_ <sup >?</sup >\
98>   ;  ; ` } `
9+ >
10+ > _ Statements_ :\
11+ >   ;  ;   ;  ; [ _ Statement_ ] <sup >\+ </sup >\
12+ >   ;  ; | [ _ Statement_ ] <sup >\+ </sup > [ _ ExpressionWithoutBlock_ ] \
13+ >   ;  ; | [ _ ExpressionWithoutBlock_ ]
1014
1115A * block expression* , or * block* , is a control flow expression and anonymous
1216namespace scope for items and variable declarations. As a control flow
@@ -101,11 +105,19 @@ let a = unsafe { an_unsafe_fn() };
101105
102106## Attributes on block expressions
103107
104- Block expressions allow [ outer attributes] and [ inner attributes] directly after
105- the opening brace when the block expression is the outer expression of an
106- [ expression statement] or the final expression of another block expression. The
107- attributes that have meaning on a block expression are [ ` cfg ` ] and [ the lint
108- check attributes] .
108+ [ Inner attributes] are allowed directly after the opening brace of a block
109+ expression in the following situations:
110+
111+ * [ Function] and [ method] bodies.
112+ * Loop bodies ([ ` loop ` ] , [ ` while ` ] , [ ` while let ` ] , and [ ` for ` ] ).
113+ * Block expressions used as a [ statement] .
114+ * Block expressions as elements of [ array expressions] , [ tuple expressions] ,
115+ [ call expressions] , tuple-style [ struct] and [ enum variant] expressions.
116+ * A block expression as the tail expression of another block expression.
117+ <!-- Keep list in sync with expressions.md -->
118+
119+ The attributes that have meaning on a block expression are [ ` cfg ` ] and [ the
120+ lint check attributes] .
109121
110122For example, this function returns ` true ` on unix platforms and ` false ` on other
111123platforms.
@@ -117,15 +129,26 @@ fn is_unix_platform() -> bool {
117129}
118130```
119131
132+ [ _ExpressionWithoutBlock_ ] : expressions.html
120133[ _InnerAttribute_ ] : attributes.html
121134[ _Statement_ ] : statements.html
122- [ _Expression_ ] : expressions.html
135+ [ `cfg` ] : conditional-compilation.html
136+ [ `for` ] : expressions/loop-expr.html#iterator-loops
137+ [ `loop` ] : expressions/loop-expr.html#infinite-loops
138+ [ `while let` ] : expressions/loop-expr.html#predicate-pattern-loops
139+ [ `while` ] : expressions/loop-expr.html#predicate-loops
140+ [ array expressions ] : expressions/array-expr.html
141+ [ call expressions ] : expressions/call-expr.html
142+ [ enum variant ] : expressions/enum-variant-expr.html
143+ [ expression attributes ] : expressions.html#expression-attributes
123144[ expression ] : expressions.html
124- [ statements ] : statements.html
125- [ value expressions ] : expressions.html#place-expressions-and-value-expressions
126- [ outer attributes ] : attributes.html
145+ [ function ] : items/functions.html
127146[ inner attributes ] : attributes.html
128- [ expression statement ] : statements.html#expression-statements
129- [ `cfg` ] : conditional-compilation.html
147+ [ method ] : items/associated-items.html#methods
148+ [ statement ] : statements.html
149+ [ statements ] : statements.html
150+ [ struct ] : expressions/struct-expr.html
130151[ the lint check attributes ] : attributes.html#lint-check-attributes
152+ [ tuple expressions ] : expressions/tuple-expr.html
131153[ unsafe operations ] : unsafety.html
154+ [ value expressions ] : expressions.html#place-expressions-and-value-expressions
0 commit comments