|
1 | 1 | # Attributes
|
2 | 2 |
|
3 |
| -> **<sup>Syntax</sup>** |
4 |
| -> _Attribute_ : |
5 |
| -> _InnerAttribute_ | _OuterAttribute_ |
6 |
| -> |
7 |
| -> _InnerAttribute_ : |
8 |
| -> `#![` MetaItem `]` |
9 |
| -> |
10 |
| -> _OuterAttribute_ : |
11 |
| -> `#[` MetaItem `]` |
12 |
| -> |
13 |
| -> _MetaItem_ : |
14 |
| -> IDENTIFIER |
15 |
| -> | IDENTIFIER `=` LITERAL |
16 |
| -> | IDENTIFIER `(` LITERAL `)` |
17 |
| -> | IDENTIFIER `(` _MetaSeq_ `)` |
18 |
| -> |
19 |
| -> _MetaSeq_ : |
20 |
| -> EMPTY |
21 |
| -> | _MetaItem_ |
| 3 | +> **<sup>Syntax</sup>** |
| 4 | +> _Attribute_ : |
| 5 | +> _InnerAttribute_ | _OuterAttribute_ |
| 6 | +> |
| 7 | +> _InnerAttribute_ : |
| 8 | +> `#![` MetaItem `]` |
| 9 | +> |
| 10 | +> _OuterAttribute_ : |
| 11 | +> `#[` MetaItem `]` |
| 12 | +> |
| 13 | +> _MetaItem_ : |
| 14 | +> IDENTIFIER |
| 15 | +> | IDENTIFIER `=` LITERAL |
| 16 | +> | IDENTIFIER `(` LITERAL `)` |
| 17 | +> | IDENTIFIER `(` _MetaSeq_ `)` |
| 18 | +> |
| 19 | +> _MetaSeq_ : |
| 20 | +> EMPTY |
| 21 | +> | _MetaItem_ |
22 | 22 | > | _MetaItem_ `,` _MetaSeq_
|
23 | 23 |
|
24 | 24 | Any [item declaration] or [generic lifetime or type parameter][generics] may
|
@@ -116,7 +116,7 @@ On an `extern` block, the following attributes are interpreted:
|
116 | 116 | declarations in this block to be linked correctly. `link` supports an optional
|
117 | 117 | `kind` key with three possible values: `dylib`, `static`, and `framework`. See
|
118 | 118 | [external blocks](items/external-blocks.html) for more about external blocks.
|
119 |
| - Two examples: `#[link(name = "readline")]` and |
| 119 | + Two examples: `#[link(name = "readline")]` and |
120 | 120 | `#[link(name = "CoreFoundation", kind = "framework")]`.
|
121 | 121 | - `linked_from` - indicates what native library this block of FFI items is
|
122 | 122 | coming from. This attribute is of the form `#[linked_from = "foo"]` where
|
@@ -165,6 +165,8 @@ information on macro scope.
|
165 | 165 | object file that this item's contents will be placed into.
|
166 | 166 | - `no_mangle` - on any item, do not apply the standard name mangling. Set the
|
167 | 167 | symbol for this item to its identifier.
|
| 168 | +- `used` - on statics, this forces the compiler to keep the variable in the |
| 169 | + output object file. |
168 | 170 |
|
169 | 171 | ### Deprecation
|
170 | 172 |
|
@@ -450,7 +452,7 @@ When used on a function in an implementation, the attribute does nothing.
|
450 | 452 | > { five() };
|
451 | 453 | > if true { five() } else { 0i32 };
|
452 | 454 | > match true {
|
453 |
| -> _ => five() |
| 455 | +> _ => five() |
454 | 456 | > };
|
455 | 457 | > }
|
456 | 458 | > ```
|
|
0 commit comments