File tree Expand file tree Collapse file tree 1 file changed +29
-3
lines changed Expand file tree Collapse file tree 1 file changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -76,9 +76,35 @@ into the [`macro_use` prelude].
76
76
r[ items.extern-crate.no_link]
77
77
## The ` no_link ` attribute
78
78
79
- The * ` no_link ` attribute* may be specified on an ` extern crate ` item to
80
- prevent linking the crate into the output. This is commonly used to load a
81
- crate to access only its macros.
79
+ r[ items.extern-crate.no_link.intro]
80
+ The * ` no_link ` [ attribute] [ attributes ] * may be applied to an ` extern crate ` item to prevent linking the crate.
81
+
82
+ > [ !NOTE]
83
+ > This is helpful, e.g., when only the macros of a crate are needed.
84
+
85
+ > [ !EXAMPLE]
86
+ > <!-- ignore: requires external crates -->
87
+ > ``` rust,ignore
88
+ > #[no_link]
89
+ > extern crate other_crate;
90
+ >
91
+ > other_crate::some_macro!();
92
+ > ```
93
+
94
+ r[items.extern-crate.no_link.syntax]
95
+ The `no_link` attribute uses the [MetaWord] syntax and so does not accept any arguments.
96
+
97
+ r[items.extern-crate.no_link.allowed-positions]
98
+ The `no_link` attribute may only be applied to an `extern crate` declaration.
99
+
100
+ > [!NOTE]
101
+ > `rustc` currently accepts and ignores the attribute in other positions but lints against it. This may become a hard error in the future.
102
+
103
+ r[items.extern-crate.no_link.duplicates]
104
+ Duplicate instances of the `no_link` attribute are ignored.
105
+
106
+ > [!NOTE]
107
+ > `rustc` lints against duplicate use of this attribute.
82
108
83
109
[identifier]: ../identifiers.md
84
110
[RFC 940]: https://github.com/rust-lang/rfcs/blob/master/text/0940-hyphens-considered-harmful.md
You can’t perform that action at this time.
0 commit comments