@@ -25,9 +25,43 @@ on Attributes in [ECMA-335], with the syntax coming from [ECMA-334] \(C#).
2525r[ attributes.inner]
2626_ Inner attributes_ , written with a bang (` ! ` ) after the hash (` # ` ), apply to the form that the attribute is declared within.
2727
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+
2843r [attributes . outer]
2944_Outer attributes_ , written without the bang after the hash , apply to the form that follows the attribute .
3045
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+ > ```
64+
3165r [attributes . input]
3266The attribute consists of a path to the attribute , followed by an optional
3367delimited token tree whose interpretation is defined by the attribute .
@@ -75,38 +109,6 @@ Attributes may be applied to many forms in the language:
75109 parameters accept outer attributes . This includes attributes on variadic parameters
76110 denoted with `... ` in function pointers and [external blocks ][variadic functions ].
77111
78- Some examples of attributes:
79-
80- ``` rust
81- // General metadata applied to the enclosing module or crate.
82- #![crate_type = " lib" ]
83-
84- // A function marked as a unit test
85- #[test]
86- fn test_foo () {
87- /* ... */
88- }
89-
90- // A conditionally-compiled module
91- #[cfg(target_os = " linux" )]
92- mod bar {
93- /* ... */
94- }
95-
96- // A lint attribute used to suppress a warning/error
97- #[allow(non_camel_case_types)]
98- type int8_t = i8 ;
99-
100- // Inner attribute applies to the entire function.
101- fn some_unused_variables () {
102- #![allow(unused_variables)]
103-
104- let x = ();
105- let y = ();
106- let z = ();
107- }
108- ```
109-
110112r [attributes . meta]
111113## Meta item attribute syntax
112114
0 commit comments