Skip to content

Commit 1f59f7f

Browse files
committed
More attributes improvements
Improve the flow of documentation by showing the definition on the first sentence and then have what takes attributes be its own paragraph later on. Moar links of course. Explain that the rest of the page after that will be descriptions of attributes that are in use today.
1 parent d2e694d commit 1f59f7f

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

src/attributes.md

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,31 @@
2121
>    | _MetaItem_
2222
>    | _MetaItem_ `,` _MetaSeq_
2323
24-
Any [item declaration], [statement], [block expression] or
25-
[generic lifetime or type parameter][generics] may have an attribute applied to
26-
it. Attributes are modeled on Attributes in [ECMA-335], with the syntax coming
27-
from [ECMA-334]\ (C#). An _attribute_ is a general, free-form metadatum that is
28-
interpreted according to name, convention, and language and compiler version.
24+
An _attribute_ is a general, free-form metadatum that is interpreted according
25+
to name, convention, and language and compiler version. Attributes are modeled
26+
on Attributes in [ECMA-335], with the syntax coming from [ECMA-334]\ (C#).
27+
2928
Attributes may appear as any of:
3029

31-
* A single identifier, the attribute name
30+
* A single identifier, the _attribute name+
3231
* An identifier followed by the equals sign '=' and a literal, providing a
33-
key/value pair
32+
key-value pair
3433
* An identifier followed by a parenthesized literal, providing a
35-
key/value pair
34+
key-value pair
3635
* An identifier followed by a parenthesized list of sub-attribute arguments
3736

3837
_Inner attributes_, written with a bang ("!") after the hash ("#"), apply to the
39-
item or block expression that the attribute is declared within. _Outer
40-
attributes_, written without the bang after the hash, apply to the thing that
41-
follows the attribute.
38+
thing that the attribute is declared within. _Outer attributes_, written without
39+
the bang after the hash, apply to the thing that follows the attribute.
40+
41+
Any [item declaration], [statement], [block expression] or
42+
[generic lifetime or type parameter][generics] may have an attribute applied
43+
to it. Statemetns and generic lifetime or type parameters can only take outer
44+
attributes while block expressions can only take inner attributes. All item
45+
declarations can take outer attributes while [external blocks], [functions],
46+
[implementations], and [modules] allow inner attributes.
4247

43-
An example of attributes:
48+
Some examples of attributes:
4449

4550
```rust
4651
// General metadata applied to the enclosing module or crate.
@@ -63,6 +68,9 @@ mod bar {
6368
type int8_t = i8;
6469
```
6570

71+
The rest of this page will describe which attribute names that have meaning and
72+
their respective meaning.
73+
6674
## Crate-only attributes
6775

6876
- `crate_name` - specify the crate's crate name.
@@ -545,4 +553,7 @@ You can implement `derive` for your own type through [procedural macros].
545553
[item declaration]: items.html
546554
[generics]: generics.html
547555
[statement]: statements.html
548-
[block expression]: expressions/block-expr.html
556+
[block expression]: expressions/block-expr.html
557+
[external blocks]: items/external-blocks.html
558+
[implementations]: items/implementations.html
559+
[modules]: items/modules.html

0 commit comments

Comments
 (0)