From bea65c71ae009a80710992d14dd0cb849dbf3d0b Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 20 May 2024 08:58:45 -0500 Subject: [PATCH 1/6] docs(ref): Remove blog post link Blog posts are not evergreen documentation. --- src/doc/src/reference/build-scripts.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/doc/src/reference/build-scripts.md b/src/doc/src/reference/build-scripts.md index 1f1fd0041dc..3b26691743e 100644 --- a/src/doc/src/reference/build-scripts.md +++ b/src/doc/src/reference/build-scripts.md @@ -258,8 +258,6 @@ identifier, the value should be a string. ### `cargo::rustc-check-cfg=CHECK_CFG` {#rustc-check-cfg} -*See the announcement [blog post][check-cfg-blog-post] for more a global view of the feature.* - Add to the list of expected config names and values that is used when checking the _reachable_ cfg expressions. @@ -295,7 +293,6 @@ if foo_bar_condition { For a more complete example see in the [build script examples][build-script-examples] page the [conditional compilation][conditional-compilation-example] example. -[check-cfg-blog-post]: https://blog.rust-lang.org/2024/05/06/check-cfg.html [option-check-cfg]: ../../rustc/command-line-arguments.md#option-check-cfg [build-script-examples]: build-script-examples.md [conditional-compilation-example]: build-script-examples.md#conditional-compilation From 27e067c8d5cef4e8530c21853232b8fa23c3dc0b Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 20 May 2024 08:59:40 -0500 Subject: [PATCH 2/6] docs(ref): Fix typo on check-cfg --- src/doc/src/reference/build-scripts.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/src/reference/build-scripts.md b/src/doc/src/reference/build-scripts.md index 3b26691743e..d99582fe0b8 100644 --- a/src/doc/src/reference/build-scripts.md +++ b/src/doc/src/reference/build-scripts.md @@ -278,7 +278,7 @@ currently enabled. This includes all possible values of a given cfg name. It is recommended to group the `cargo::rustc-check-cfg` and [`cargo::rustc-cfg`][option-cfg] instructions as closely as possible in order to -avoid typos, missing check-cfg, stalled cfgs... +avoid typos, missing check-cfg, stale cfgs... #### Example of using `cargo::rustc-check-cfg` and `cargo::rustc-cfg` together From 88b15d7473f1b421d7f37000e6fb1feb2f19101b Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 20 May 2024 09:02:16 -0500 Subject: [PATCH 3/6] docs(ref): Simplify text for link to check-cfg example --- src/doc/src/reference/build-scripts.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/doc/src/reference/build-scripts.md b/src/doc/src/reference/build-scripts.md index d99582fe0b8..4aa1805770e 100644 --- a/src/doc/src/reference/build-scripts.md +++ b/src/doc/src/reference/build-scripts.md @@ -290,11 +290,10 @@ if foo_bar_condition { } ``` -For a more complete example see in the [build script examples][build-script-examples] page -the [conditional compilation][conditional-compilation-example] example. +For a more complete example see the +[conditional compilation][conditional-compilation-example] example. [option-check-cfg]: ../../rustc/command-line-arguments.md#option-check-cfg -[build-script-examples]: build-script-examples.md [conditional-compilation-example]: build-script-examples.md#conditional-compilation ### `cargo::rustc-env=VAR=VALUE` {#rustc-env} From 1162546c8b1a51794714ac03cf1dc18d45957fbc Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 20 May 2024 09:03:15 -0500 Subject: [PATCH 4/6] docs(ref): Flatten the check-cfg structure --- src/doc/src/reference/build-scripts.md | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/doc/src/reference/build-scripts.md b/src/doc/src/reference/build-scripts.md index 4aa1805770e..14064b3e4de 100644 --- a/src/doc/src/reference/build-scripts.md +++ b/src/doc/src/reference/build-scripts.md @@ -271,6 +271,9 @@ The instruction can be used like this: ```rust,no_run // build.rs println!("cargo::rustc-check-cfg=cfg(foo, values(\"bar\"))"); +if foo_bar_condition { + println!("cargo::rustc-cfg=foo=\"bar\""); +} ``` Note that all possible cfgs should be defined, regardless of which cfgs are @@ -280,17 +283,7 @@ It is recommended to group the `cargo::rustc-check-cfg` and [`cargo::rustc-cfg`][option-cfg] instructions as closely as possible in order to avoid typos, missing check-cfg, stale cfgs... -#### Example of using `cargo::rustc-check-cfg` and `cargo::rustc-cfg` together - -```rust,no_run -// build.rs -println!("cargo::rustc-check-cfg=cfg(foo, values(\"bar\"))"); -if foo_bar_condition { - println!("cargo::rustc-cfg=foo=\"bar\""); -} -``` - -For a more complete example see the +See also the [conditional compilation][conditional-compilation-example] example. [option-check-cfg]: ../../rustc/command-line-arguments.md#option-check-cfg From bd744f0919a00c868e740f92e386ec0fcf5c634c Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 20 May 2024 09:44:58 -0500 Subject: [PATCH 5/6] docs(ref): Integrate link to unexpected_cfgs lint --- src/doc/src/reference/build-scripts.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/doc/src/reference/build-scripts.md b/src/doc/src/reference/build-scripts.md index 14064b3e4de..87b26421e72 100644 --- a/src/doc/src/reference/build-scripts.md +++ b/src/doc/src/reference/build-scripts.md @@ -259,10 +259,9 @@ identifier, the value should be a string. ### `cargo::rustc-check-cfg=CHECK_CFG` {#rustc-check-cfg} Add to the list of expected config names and values that is used when checking -the _reachable_ cfg expressions. +the _reachable_ cfg expressions with the [`unexpected_cfgs`][unexpected-cfgs] lint. For details on the syntax of `CHECK_CFG`, see `rustc` [`--check-cfg` flag][option-check-cfg]. -See also the [`unexpected_cfgs`][unexpected-cfgs] lint. > Note: `cargo:rustc-check-cfg` (single-colon) can be used if your MSRV is below Rust 1.77 From a0fb4ac6e7527cfdf4a344d23c111322f8dc95dd Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 20 May 2024 09:52:45 -0500 Subject: [PATCH 6/6] docs(ref): Link to the more full docs on check-cfg --- src/doc/src/reference/build-scripts.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/doc/src/reference/build-scripts.md b/src/doc/src/reference/build-scripts.md index 87b26421e72..3837ebdc30d 100644 --- a/src/doc/src/reference/build-scripts.md +++ b/src/doc/src/reference/build-scripts.md @@ -261,7 +261,8 @@ identifier, the value should be a string. Add to the list of expected config names and values that is used when checking the _reachable_ cfg expressions with the [`unexpected_cfgs`][unexpected-cfgs] lint. -For details on the syntax of `CHECK_CFG`, see `rustc` [`--check-cfg` flag][option-check-cfg]. +The syntax of `CHECK_CFG` mirrors the `rustc` [`--check-cfg` flag][option-check-cfg], see +[Checking conditional configurations][checking-conditional-configurations] for more details. > Note: `cargo:rustc-check-cfg` (single-colon) can be used if your MSRV is below Rust 1.77 @@ -285,6 +286,7 @@ avoid typos, missing check-cfg, stale cfgs... See also the [conditional compilation][conditional-compilation-example] example. +[checking-conditional-configurations]: ../../rustc/check-cfg.html [option-check-cfg]: ../../rustc/command-line-arguments.md#option-check-cfg [conditional-compilation-example]: build-script-examples.md#conditional-compilation