@@ -610,7 +610,7 @@ and may optionally begin with any number of `attributes` that apply to the conta
610
610
Attributes on the anonymous crate module define important metadata that influences
611
611
the behavior of the compiler.
612
612
613
- ~~~~
613
+ ~~~~ {.rust}
614
614
// Crate ID
615
615
#![crate_id = "projx#2.5"]
616
616
@@ -1697,7 +1697,7 @@ as any of:
1697
1697
1698
1698
Attributes with a bang ("!") after the hash ("#") apply to the item that the
1699
1699
attribute is declared within. Attributes that do not have a bang after the
1700
- hash by a semi-colon apply to the next item.
1700
+ hash apply to the item that follows the attribute .
1701
1701
1702
1702
An example of attributes:
1703
1703
@@ -1729,53 +1729,54 @@ pub type int8_t = i8;
1729
1729
1730
1730
### Crate-only attributes
1731
1731
1732
+ - ` crate_id ` - specify the this crate's crate ID.
1732
1733
- ` crate_type ` - see [ linkage] ( #linkage ) .
1733
1734
- ` feature ` - see [ compiler features] ( #compiler-features ) .
1735
+ - ` no_main ` - disable emitting the ` main ` symbol. Useful when some other
1736
+ object being linked to defines ` main ` .
1734
1737
- ` no_start ` - disable linking to the ` native ` crate, which specifies the
1735
1738
"start" language item.
1736
- - ` no_main ` - disable emitting the ` main ` symbol. Useful when some
1737
- other object being linked to defines ` main ` .
1738
1739
- ` no_std ` - disable linking to the ` std ` crate.
1739
- - ` crate_id ` - specify the this crate's crate ID.
1740
1740
1741
1741
### Module-only attributes
1742
1742
1743
- - ` path ` - specifies the file to load the module from. `#[ path="foo.rs"] mod
1744
- bar;` is equivalent to ` mod bar { /* contents of foo.rs * / }`
1745
1743
- ` macro_escape ` - macros defined in this module will be visible in the
1746
1744
module's parent, after this module has been included.
1747
1745
- ` no_implicit_prelude ` - disable injecting ` use std::prelude::* ` in this
1748
1746
module.
1747
+ - ` path ` - specifies the file to load the module from. `#[ path="foo.rs"] mod
1748
+ bar;` is equivalent to ` mod bar { /* contents of foo.rs * / }`. The path is
1749
+ taken relative to the directory that the current module is in.
1749
1750
1750
1751
### Function-only attributes
1751
1752
1752
- - ` start ` - indicates that this function should be used as the entry point,
1753
- overriding the "start" language item. See the "start" [ language
1754
- item] ( #language-items ) for more details.
1755
- - ` main ` - indicates that this function should be passed to the entry point,
1756
- rather than the function in the crate root named ` main ` .
1757
1753
- ` macro_registrar ` - when using loadable syntax extensions, mark this
1758
1754
function as the registration point for the current crate's syntax
1759
1755
extensions.
1756
+ - ` main ` - indicates that this function should be passed to the entry point,
1757
+ rather than the function in the crate root named ` main ` .
1758
+ - ` start ` - indicates that this function should be used as the entry point,
1759
+ overriding the "start" language item. See the "start" [ language
1760
+ item] ( #language-items ) for more details.
1760
1761
1761
1762
### Static-only attributes
1762
1763
1764
+ - ` address_insignificant ` - references to this static may alias with
1765
+ references to other statics, potentially of unrelated type.
1763
1766
- ` thread_local ` - on a ` static mut ` , this signals that the value of this
1764
1767
static may change depending on the current thread. The exact consequences of
1765
1768
this are implementation-defined.
1766
- - ` address_insignificant ` - references to this static may alias with
1767
- references to other statics, potentially of unrelated type.
1768
1769
1769
1770
### FFI attributes
1770
1771
1771
1772
On an ` extern ` block, the following attributes are interpreted:
1772
1773
1773
- - ` link ` - indicate that a native library should be linked to for the
1774
- declarations in this block to be linked correctly. See [ external
1775
- blocks] ( #external-blocks )
1776
1774
- ` link_args ` - specify arguments to the linker, rather than just the library
1777
1775
name and type. This is feature gated and the exact behavior is
1778
1776
implementation-defined (due to variety of linker invocation syntax).
1777
+ - ` link ` - indicate that a native library should be linked to for the
1778
+ declarations in this block to be linked correctly. See [ external
1779
+ blocks] ( #external-blocks )
1779
1780
1780
1781
On declarations inside an ` extern ` block, the following attributes are
1781
1782
interpreted:
@@ -1787,25 +1788,29 @@ interpreted:
1787
1788
1788
1789
### Miscellaneous attributes
1789
1790
1790
- - ` simd ` - on certain tuple structs, derive the arithmetic operators, which
1791
- lower to the target's SIMD instructions, if any.
1792
1791
- ` link_section ` - on statics and functions, this specifies the section of the
1793
1792
object file that this item's contents will be placed into.
1794
- - ` static_assert ` - on statics whose type is ` bool ` , terminates compilation
1795
- with an error if it is not initialized to ` true ` .
1796
- - ` repr ` - on C-like enums, this sets the underlying type used for
1797
- representation. Useful for FFI.
1793
+ - ` macro_export ` - export a macro for cross-crate usage.
1798
1794
- ` no_mangle ` - on any item, do not apply the standard name mangling. Set the
1799
1795
symbol for this item to its identifier.
1800
1796
- ` packed ` - on structs or enums, eliminate any padding that would be used to
1801
1797
align fields.
1798
+ - ` repr ` - on C-like enums, this sets the underlying type used for
1799
+ representation. Useful for FFI. Takes one argument, which is the primitive
1800
+ type this enum should be represented for, or ` C ` , which specifies that it
1801
+ should be the default ` enum ` size of the C ABI for that platform. Note that
1802
+ enum representation in C is undefined, and this may be incorrect when the C
1803
+ code is compiled with certain flags.
1804
+ - ` simd ` - on certain tuple structs, derive the arithmetic operators, which
1805
+ lower to the target's SIMD instructions, if any.
1806
+ - ` static_assert ` - on statics whose type is ` bool ` , terminates compilation
1807
+ with an error if it is not initialized to ` true ` .
1802
1808
- ` unsafe_destructor ` - allow implementations of the "drop" language item
1803
1809
where the type it is implemented for does not implement the "send" language
1804
1810
item.
1805
1811
- ` unsafe_no_drop_flag ` - on structs, remove the flag that prevents
1806
1812
destructors from being run twice. Destructors might be run multiple times on
1807
1813
the same object with this attribute.
1808
- - ` macro_export ` - export a macro for cross-crate usage.
1809
1814
1810
1815
### Conditional compilation
1811
1816
0 commit comments