21
21
>   ;  ; | _ MetaItem_
22
22
>   ;  ; | _ MetaItem_ ` , ` _ MetaSeq_
23
23
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
+
29
28
Attributes may appear as any of:
30
29
31
- * A single identifier, the attribute name
30
+ * A single identifier, the _ attribute name+
32
31
* An identifier followed by the equals sign '=' and a literal, providing a
33
- key/ value pair
32
+ key- value pair
34
33
* An identifier followed by a parenthesized literal, providing a
35
- key/ value pair
34
+ key- value pair
36
35
* An identifier followed by a parenthesized list of sub-attribute arguments
37
36
38
37
_ 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.
42
47
43
- An example of attributes:
48
+ Some examples of attributes:
44
49
45
50
``` rust
46
51
// General metadata applied to the enclosing module or crate.
@@ -63,6 +68,9 @@ mod bar {
63
68
type int8_t = i8 ;
64
69
```
65
70
71
+ The rest of this page will describe which attribute names that have meaning and
72
+ their respective meaning.
73
+
66
74
## Crate-only attributes
67
75
68
76
- ` crate_name ` - specify the crate's crate name.
@@ -545,4 +553,7 @@ You can implement `derive` for your own type through [procedural macros].
545
553
[ item declaration ] : items.html
546
554
[ generics ] : generics.html
547
555
[ 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