diff --git a/src/items/extern-crates.md b/src/items/extern-crates.md index 3f1039580..d0be3406f 100644 --- a/src/items/extern-crates.md +++ b/src/items/extern-crates.md @@ -76,9 +76,35 @@ into the [`macro_use` prelude]. r[items.extern-crate.no_link] ## The `no_link` attribute -The *`no_link` attribute* may be specified on an `extern crate` item to -prevent linking the crate into the output. This is commonly used to load a -crate to access only its macros. +r[items.extern-crate.no_link.intro] +The *`no_link` [attribute][attributes]* may be applied to an `extern crate` item to prevent linking the crate. + +> [!NOTE] +> This is helpful, e.g., when only the macros of a crate are needed. + +> [!EXAMPLE] +> +> ```rust,ignore +> #[no_link] +> extern crate other_crate; +> +> other_crate::some_macro!(); +> ``` + +r[items.extern-crate.no_link.syntax] +The `no_link` attribute uses the [MetaWord] syntax and so does not accept any arguments. + +r[items.extern-crate.no_link.allowed-positions] +The `no_link` attribute may only be applied to an `extern crate` declaration. + +> [!NOTE] +> `rustc` currently accepts and ignores the attribute in other positions but lints against it. This may become a hard error in the future. + +r[items.extern-crate.no_link.duplicates] +Duplicate instances of the `no_link` attribute are ignored. + +> [!NOTE] +> `rustc` lints against duplicate use of this attribute. [identifier]: ../identifiers.md [RFC 940]: https://github.com/rust-lang/rfcs/blob/master/text/0940-hyphens-considered-harmful.md