From 0eadf02b6a3130221331c726e21cda6b4a95acf3 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Fri, 20 Jun 2025 16:55:38 -0700 Subject: [PATCH 1/5] Unwrap no_link --- src/items/extern-crates.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/items/extern-crates.md b/src/items/extern-crates.md index 3f1039580..abb65faa1 100644 --- a/src/items/extern-crates.md +++ b/src/items/extern-crates.md @@ -76,9 +76,7 @@ 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. +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. [identifier]: ../identifiers.md [RFC 940]: https://github.com/rust-lang/rfcs/blob/master/text/0940-hyphens-considered-harmful.md From 237b3bd05d25c1ccd1f000c339fb54665760f374 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Fri, 20 Jun 2025 17:03:59 -0700 Subject: [PATCH 2/5] Linkify "attribute" and add an intro rule name --- src/items/extern-crates.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/items/extern-crates.md b/src/items/extern-crates.md index abb65faa1..d9b1b7c92 100644 --- a/src/items/extern-crates.md +++ b/src/items/extern-crates.md @@ -76,7 +76,8 @@ 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 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. [identifier]: ../identifiers.md [RFC 940]: https://github.com/rust-lang/rfcs/blob/master/text/0940-hyphens-considered-harmful.md From f751568dca0dccd78115f5e8514b63e0ad0cb5e8 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Fri, 20 Jun 2025 17:04:42 -0700 Subject: [PATCH 3/5] Add a no_link example --- src/items/extern-crates.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/items/extern-crates.md b/src/items/extern-crates.md index d9b1b7c92..b2fa28494 100644 --- a/src/items/extern-crates.md +++ b/src/items/extern-crates.md @@ -79,6 +79,15 @@ r[items.extern-crate.no_link] r[items.extern-crate.no_link.intro] The *`no_link` [attribute][attributes]* 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. +> [!EXAMPLE] +> +> ```rust,ignore +> #[no_link] +> extern crate other_crate; +> +> other_crate::some_macro!(); +> ``` + [identifier]: ../identifiers.md [RFC 940]: https://github.com/rust-lang/rfcs/blob/master/text/0940-hyphens-considered-harmful.md [`macro_use` attribute]: ../macros-by-example.md#the-macro_use-attribute From 0e464c96d44ae6aaf4d2d0c358284a56360dd63d Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Fri, 20 Jun 2025 17:04:49 -0700 Subject: [PATCH 4/5] Update no_link to use the attribute template --- src/items/extern-crates.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/items/extern-crates.md b/src/items/extern-crates.md index b2fa28494..f8f42dd72 100644 --- a/src/items/extern-crates.md +++ b/src/items/extern-crates.md @@ -88,6 +88,21 @@ The *`no_link` [attribute][attributes]* may be specified on an `extern crate` it > other_crate::some_macro!(); > ``` +r[items.extern-crate.no_link.syntax] +The `no_link` attribute uses the [MetaWord] syntax and thus does not take any inputs. + +r[items.extern-crate.no_link.allowed-positions] +The `no_link` attribute may be specified on an `extern crate` declaration. + +> [!NOTE] +> `rustc` currently warns on some positions where it is ignored, but this may become an error in the future. + +r[items.extern-crate.no_link.duplicates] +Duplicate instances of the `no_link` attribute are ignored. + +> [!NOTE] +> `rustc` currently warns about unused duplicate `no_link` attributes. + [identifier]: ../identifiers.md [RFC 940]: https://github.com/rust-lang/rfcs/blob/master/text/0940-hyphens-considered-harmful.md [`macro_use` attribute]: ../macros-by-example.md#the-macro_use-attribute From dda1f41ae7817356a26dd2516a3b8ade48bb5680 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Sun, 3 Aug 2025 07:21:38 +0000 Subject: [PATCH 5/5] Revise `no_link` text --- src/items/extern-crates.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/items/extern-crates.md b/src/items/extern-crates.md index f8f42dd72..d0be3406f 100644 --- a/src/items/extern-crates.md +++ b/src/items/extern-crates.md @@ -77,7 +77,10 @@ r[items.extern-crate.no_link] ## The `no_link` attribute r[items.extern-crate.no_link.intro] -The *`no_link` [attribute][attributes]* 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. +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] > @@ -89,19 +92,19 @@ The *`no_link` [attribute][attributes]* may be specified on an `extern crate` it > ``` r[items.extern-crate.no_link.syntax] -The `no_link` attribute uses the [MetaWord] syntax and thus does not take any inputs. +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 be specified on an `extern crate` declaration. +The `no_link` attribute may only be applied to an `extern crate` declaration. > [!NOTE] -> `rustc` currently warns on some positions where it is ignored, but this may become an error in the future. +> `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` currently warns about unused duplicate `no_link` attributes. +> `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