Skip to content

Commit ef60a45

Browse files
committed
Auto merge of #13937 - epage:docs, r=weihanglo
docs(ref): Simplify check-cfg build.rs docs ### What does this PR try to resolve? After looking over the rust documentation updates, decided to look over Cargo's build.rs documentation. - Removed link to the blog post as that is not evergreen documentation - Collapsed down the example to put more emphasis on the more complete example ### How should we test and review this PR? ### Additional information
2 parents 2332d7a + a0fb4ac commit ef60a45

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

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

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -258,13 +258,11 @@ 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-
263261
Add to the list of expected config names and values that is used when checking
264-
the _reachable_ cfg expressions.
262+
the _reachable_ cfg expressions with the [`unexpected_cfgs`][unexpected-cfgs] lint.
265263

266-
For details on the syntax of `CHECK_CFG`, see `rustc` [`--check-cfg` flag][option-check-cfg].
267-
See also the [`unexpected_cfgs`][unexpected-cfgs] lint.
264+
The syntax of `CHECK_CFG` mirrors the `rustc` [`--check-cfg` flag][option-check-cfg], see
265+
[Checking conditional configurations][checking-conditional-configurations] for more details.
268266

269267
> Note: `cargo:rustc-check-cfg` (single-colon) can be used if your MSRV is below Rust 1.77
270268
@@ -273,31 +271,23 @@ The instruction can be used like this:
273271
```rust,no_run
274272
// build.rs
275273
println!("cargo::rustc-check-cfg=cfg(foo, values(\"bar\"))");
274+
if foo_bar_condition {
275+
println!("cargo::rustc-cfg=foo=\"bar\"");
276+
}
276277
```
277278

278279
Note that all possible cfgs should be defined, regardless of which cfgs are
279280
currently enabled. This includes all possible values of a given cfg name.
280281

281282
It is recommended to group the `cargo::rustc-check-cfg` and
282283
[`cargo::rustc-cfg`][option-cfg] instructions as closely as possible in order to
283-
avoid typos, missing check-cfg, stalled cfgs...
284-
285-
#### Example of using `cargo::rustc-check-cfg` and `cargo::rustc-cfg` together
286-
287-
```rust,no_run
288-
// build.rs
289-
println!("cargo::rustc-check-cfg=cfg(foo, values(\"bar\"))");
290-
if foo_bar_condition {
291-
println!("cargo::rustc-cfg=foo=\"bar\"");
292-
}
293-
```
284+
avoid typos, missing check-cfg, stale cfgs...
294285

295-
For a more complete example see in the [build script examples][build-script-examples] page
296-
the [conditional compilation][conditional-compilation-example] example.
286+
See also the
287+
[conditional compilation][conditional-compilation-example] example.
297288

298-
[check-cfg-blog-post]: https://blog.rust-lang.org/2024/05/06/check-cfg.html
289+
[checking-conditional-configurations]: ../../rustc/check-cfg.html
299290
[option-check-cfg]: ../../rustc/command-line-arguments.md#option-check-cfg
300-
[build-script-examples]: build-script-examples.md
301291
[conditional-compilation-example]: build-script-examples.md#conditional-compilation
302292

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

0 commit comments

Comments
 (0)