Skip to content

Commit ec35bff

Browse files
committed
Auto merge of #13869 - Urgau:check-cfg-docs-2, r=weihanglo
Add more documentation to `cargo::rustc-check-cfg` This PR add more documentation to `cargo::rustc-check-cfg` by: 1. mentioning `cargo:rustc-check-cfg` for MSRV 2. it also add a link to [the check-cfg blog post](https://blog.rust-lang.org/2024/05/06/check-cfg.html) (since it gives a big overview of the feature in general) 3. it also adds a link to the build-script-examples page where a more complete example for the use of `cargo::rustc-cfg` and `cargo::rustc-check-cfg` is displayed Fixes #13868 r? `@weihanglo`
2 parents cfbc4b7 + 1ddc6b6 commit ec35bff

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/doc/src/reference/build-scripts.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,16 @@ identifier, the value should be a string.
258258

259259
### `cargo::rustc-check-cfg=CHECK_CFG` {#rustc-check-cfg}
260260

261+
*See the announcement [blog post][check-cfg-blog-post] for more a global view of the feature.*
262+
261263
Add to the list of expected config names and values that is used when checking
262264
the _reachable_ cfg expressions.
263265

264266
For details on the syntax of `CHECK_CFG`, see `rustc` [`--check-cfg` flag][option-check-cfg].
265267
See also the [`unexpected_cfgs`][unexpected-cfgs] lint.
266268

269+
> Note: `cargo:rustc-check-cfg` (single-colon) can be used if your MSRV is below Rust 1.77
270+
267271
The instruction can be used like this:
268272

269273
```rust,no_run
@@ -288,7 +292,13 @@ if foo_bar_condition {
288292
}
289293
```
290294

295+
For a more complete example see in the [build script examples][build-script-examples] page
296+
the [conditional compilation][conditional-compilation-example] example.
297+
298+
[check-cfg-blog-post]: https://blog.rust-lang.org/2024/05/06/check-cfg.html
291299
[option-check-cfg]: ../../rustc/command-line-arguments.md#option-check-cfg
300+
[build-script-examples]: build-script-examples.md
301+
[conditional-compilation-example]: build-script-examples.md#conditional-compilation
292302

293303
### `cargo::rustc-env=VAR=VALUE` {#rustc-env}
294304

0 commit comments

Comments
 (0)