2121>   ;  ; | _ MetaItem_
2222>   ;  ; | _ MetaItem_ ` , ` _ MetaSeq_
2323
24- Any item declaration may have an _ attribute _ applied to it. Attributes in Rust
25- are modeled on Attributes in ECMA-335, with the syntax coming from ECMA-334
26- (C#). An attribute is a general, free-form metadatum that is interpreted
27- according to name, convention, and language and compiler version. Attributes
28- may appear as any of:
24+ Any [ item declaration] or [ generic lifetime or type parameter ] [ generics ] may
25+ have an attribute applied to it. Attributes are modeled on Attributes in
26+ [ ECMA-335 ] , with the syntax coming from [ ECMA-334 ] \( C#). An _ attribute _ is a
27+ general, free-form metadatum that is interpreted according to name, convention,
28+ and language and compiler version. Attributes may appear as any of:
2929
3030* A single identifier, the attribute name
3131* An identifier followed by the equals sign '=' and a literal, providing a
@@ -34,9 +34,10 @@ may appear as any of:
3434 key/value pair
3535* An identifier followed by a parenthesized list of sub-attribute arguments
3636
37- Attributes with a bang ("!") after the hash ("#") apply to the item that the
38- attribute is declared within. Attributes that do not have a bang after the hash
39- apply to the item that follows the attribute.
37+ _ Inner attributes_ , written with a bang ("!") after the hash ("#"), apply to the
38+ item that the attribute is declared within. _ Outer attributes_ , written without
39+ the bang after the hash, apply to the item or generic parameter that follow the
40+ attribute.
4041
4142An example of attributes:
4243
@@ -101,7 +102,8 @@ type int8_t = i8;
101102- ` test ` - indicates that this function is a test function, to only be compiled
102103 in case of ` --test ` .
103104 - ` ignore ` - indicates that this test function is disabled.
104- - ` should_panic ` - indicates that this test function should panic, inverting the success condition.
105+ - ` should_panic ` - indicates that this test function should panic, inverting the
106+ success condition.
105107- ` cold ` - The function is unlikely to be executed, so optimize it (and calls
106108 to it) differently.
107109
@@ -153,9 +155,9 @@ which can be used to control type layout.
153155- ` no_link ` on an ` extern crate ` — even if we load this crate for macros, don't
154156 link it into the output.
155157
156- See the [ macros section of the
157- book] ( ../book/first-edition/macros.html#scoping-and-macro-importexport ) for more information on
158- macro scope.
158+ See the [ macros section of the first edition of the
159+ book] ( ../book/first-edition/macros.html#scoping-and-macro-importexport ) for more
160+ information on macro scope.
159161
160162## Miscellaneous attributes
161163
@@ -213,8 +215,8 @@ release builds.
213215Configuration options are boolean (on or off) and are named either with a
214216single identifier (e.g. ` foo ` ) or an identifier and a string (e.g. ` foo = "bar" ` ;
215217the quotes are required and spaces around the ` = ` are unimportant). Note that
216- similarly-named options, such as ` foo ` , ` foo="bar" ` and ` foo="baz" ` may each be set
217- or unset independently.
218+ similarly-named options, such as ` foo ` , ` foo="bar" ` and ` foo="baz" ` may each be
219+ set or unset independently.
218220
219221Configuration options are either provided by the compiler or passed in on the
220222command line using ` --cfg ` (e.g. ` rustc main.rs --cfg foo --cfg 'bar="baz"' ` ).
@@ -537,3 +539,7 @@ You can implement `derive` for your own type through [procedural macros].
537539[ let statement ] : statements.html#let-statements
538540[ unstable book plugin ] : ../unstable-book/language-features/plugin.html#lint-plugins
539541[ zero-variant enum ] : items/enumerations.html#zero-variant-enums
542+ [ ECMA-334 ] : https://www.ecma-international.org/publications/standards/Ecma-334.htm
543+ [ ECMA-335 ] : https://www.ecma-international.org/publications/standards/Ecma-335.htm
544+ [ item declaration ] : items.html
545+ [ generics ] : generics.html
0 commit comments