reference icon indicating copy to clipboard operation
reference copied to clipboard

Unclear block attribute positions

Open pushkine opened this issue 3 years ago • 1 comments

The Attributes on block expressions section specifies when inner attributes are allowed in blocks, it's unclear whether that applies to outer attributes too? Even more confusing is that the example showcases outer attributes instead

https://github.com/rust-lang/reference/blob/411c2f0d5cebf48453ae2d136ad0c5e611d39aec/src/expressions/block-expr.md?plain=1#L143-L164

pushkine avatar Feb 02 '22 13:02 pushkine

It seems reasonable to me to add an example of an inner attribute and also a demonstration of where it is invalid (such as a closure?).

Those restrictions are for inner attributes only. Perhaps as a reminder, it could link to https://github.com/rust-lang/reference/blob/411c2f0d5cebf48453ae2d136ad0c5e611d39aec/src/expressions.md#expression-attributes to explain the limitations on outer attributes when used as an expression/statement?

ehuss avatar Feb 02 '22 15:02 ehuss