@@ -23,9 +23,44 @@ to name, convention, language, and compiler version. Attributes are modeled
2323on Attributes in [ ECMA-335] , with the syntax coming from [ ECMA-334] \( C#).
2424
2525r[ attributes.inner]
26- _ Inner attributes_ , written with a bang (` ! ` ) after the hash (` # ` ), apply to the
27- item that the attribute is declared within. _ Outer attributes_ , written without
28- the bang after the hash, apply to the thing that follows the attribute.
26+ _ Inner attributes_ , written with a bang (` ! ` ) after the hash (` # ` ), apply to the form that the attribute is declared within.
27+
28+ > [ !EXAMPLE]
29+ > ``` rust
30+ > // General metadata applied to the enclosing module or crate.
31+ > #![crate_type = " lib" ]
32+ >
33+ > // Inner attribute applies to the entire function.
34+ > fn some_unused_variables () {
35+ > #![allow(unused_variables)]
36+ >
37+ > let x = ();
38+ > let y = ();
39+ > let z = ();
40+ > }
41+ > ```
42+
43+ r [attributes . outer]
44+ _Outer attributes_ , written without the bang after the hash , apply to the form that follows the attribute .
45+
46+ > [! EXAMPLE ]
47+ > ```rust
48+ > // A function marked as a unit test
49+ > #[test]
50+ > fn test_foo () {
51+ > /* ... */
52+ > }
53+ >
54+ > // A conditionally-compiled module
55+ > #[cfg(target_os = " linux" )]
56+ > mod bar {
57+ > /* ... */
58+ > }
59+ >
60+ > // A lint attribute used to suppress a warning/error
61+ > #[allow(non_camel_case_types)]
62+ > type int8_t = i8 ;
63+ > ```
2964
3065r [attributes . input]
3166The attribute consists of a path to the attribute , followed by an optional
@@ -56,7 +91,7 @@ Attributes can be classified into the following kinds:
5691* [Tool attributes ](#tool - attributes )
5792
5893r [attributes . allowed- position ]
59- Attributes may be applied to many things in the language:
94+ Attributes may be applied to many forms in the language :
6095
6196* All [item declarations ] accept outer attributes while [external blocks ],
6297 [functions ], [implementations ], and [modules ] accept inner attributes .
@@ -74,38 +109,6 @@ Attributes may be applied to many things in the language:
74109 parameters accept outer attributes . This includes attributes on variadic parameters
75110 denoted with `... ` in function pointers and [external blocks ][variadic functions ].
76111
77- Some examples of attributes:
78-
79- ``` rust
80- // General metadata applied to the enclosing module or crate.
81- #![crate_type = " lib" ]
82-
83- // A function marked as a unit test
84- #[test]
85- fn test_foo () {
86- /* ... */
87- }
88-
89- // A conditionally-compiled module
90- #[cfg(target_os = " linux" )]
91- mod bar {
92- /* ... */
93- }
94-
95- // A lint attribute used to suppress a warning/error
96- #[allow(non_camel_case_types)]
97- type int8_t = i8 ;
98-
99- // Inner attribute applies to the entire function.
100- fn some_unused_variables () {
101- #![allow(unused_variables)]
102-
103- let x = ();
104- let y = ();
105- let z = ();
106- }
107- ```
108-
109112r [attributes . meta]
110113## Meta item attribute syntax
111114
@@ -196,7 +199,7 @@ r[attributes.activity]
196199
197200r[ attributes.activity.intro]
198201An attribute is either active or inert. During attribute processing, * active
199- attributes* remove themselves from the thing they are on while * inert attributes*
202+ attributes* remove themselves from the form they are on while * inert attributes*
200203stay on.
201204
202205The [ ` cfg ` ] and [ ` cfg_attr ` ] attributes are active.
0 commit comments