Skip to content

Commit 276c6d1

Browse files
committed
Add doc for -Zextra-check-cfg and rustc-check-cfg
1 parent 805f5c2 commit 276c6d1

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/doc/src/reference/unstable.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,6 +1201,7 @@ It's values are:
12011201
Note than this command line options will probably become the default when stabilizing.
12021202
- `names`: enables well known names checking via `--check-cfg=names()`.
12031203
- `values`: enables well known values checking via `--check-cfg=values()`.
1204+
- `output`: enable the use of `rustc-check-cfg` in build script.
12041205

12051206
For instance:
12061207

@@ -1211,6 +1212,29 @@ cargo check -Z unstable-options -Z check-cfg=values
12111212
cargo check -Z unstable-options -Z check-cfg=features,names,values
12121213
```
12131214

1215+
Or for `output`:
1216+
1217+
```rust,no_run
1218+
// build.rs
1219+
println!("cargo:rustc-check-cfg=names(foo, bar)");
1220+
```
1221+
1222+
```
1223+
cargo check -Z unstable-options -Z check-cfg=output
1224+
```
1225+
1226+
### `cargo:rustc-check-cfg=CHECK_CFG`
1227+
1228+
The `rustc-check-cfg` instruction tells Cargo to pass the given value to the
1229+
`--check-cfg` flag to the compiler. This may be used for compile-time
1230+
detection of unexpected conditional compilation name and/or values.
1231+
1232+
This can only be used in combination with `-Zcheck-cfg=output` otherwise it is ignored
1233+
with a warning.
1234+
1235+
If you want to integrate with Cargo features, use `-Zcheck-cfg=features` instead of
1236+
trying to do it manually with this option.
1237+
12141238
### workspace-inheritance
12151239

12161240
* RFC: [#2906](https://github.com/rust-lang/rfcs/blob/master/text/2906-cargo-workspace-deduplicate.md)

0 commit comments

Comments
 (0)