Skip to content

Commit 6e80f3a

Browse files
committed
Move --check-cfg documentation to stable books
1 parent 980d483 commit 6e80f3a

38 files changed

+137
-134
lines changed

compiler/rustc_lint/src/context/diagnostics/check_cfg.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ pub(super) fn unexpected_cfg_name(
168168
diag.note("see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration");
169169
} else {
170170
diag.help(format!("to expect this configuration use `--check-cfg={inst}`"));
171-
diag.note("see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration");
171+
diag.note("see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration");
172172
}
173173
}
174174

@@ -272,6 +272,6 @@ pub(super) fn unexpected_cfg_value(
272272
if !is_cfg_a_well_know_name {
273273
diag.help(format!("to expect this configuration use `--check-cfg={inst}`"));
274274
}
275-
diag.note("see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration");
275+
diag.note("see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration");
276276
}
277277
}

compiler/rustc_session/src/config/cfg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ impl CheckCfg {
257257
// `tests/ui/check-cfg/well-known-values.rs` (in order to test the
258258
// expected values of the new config) and bless the all directory.
259259
//
260-
// Don't forget to update `src/doc/unstable-book/src/compiler-flags/check-cfg.md`
260+
// Don't forget to update `src/doc/rustc/src/check-cfg.md`
261261
// in the unstable book as well!
262262

263263
ins!(sym::debug_assertions, no_values);

src/doc/rustc/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
- [Profile-guided Optimization](profile-guided-optimization.md)
7878
- [Instrumentation-based Code Coverage](instrument-coverage.md)
7979
- [Linker-plugin-based LTO](linker-plugin-lto.md)
80+
- [Checking conditional configurations](check-cfg.md)
8081
- [Exploit Mitigations](exploit-mitigations.md)
8182
- [Symbol Mangling](symbol-mangling/index.md)
8283
- [v0 Symbol Format](symbol-mangling/v0.md)

src/doc/unstable-book/src/compiler-flags/check-cfg.md renamed to src/doc/rustc/src/check-cfg.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
# `check-cfg`
2-
3-
The tracking issue for this feature is: [#82450](https://github.com/rust-lang/rust/issues/82450).
4-
5-
------------------------
6-
7-
This feature enables checking of conditional configuration.
1+
# Checking conditional configurations
82

93
`rustc` accepts the `--check-cfg` option, which specifies whether to check conditions and how to
104
check them. The `--check-cfg` option takes a value, called the _check cfg specification_.

src/doc/rustc/src/command-line-arguments.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ The value can either be a single identifier or two identifiers separated by `=`.
1818
For examples, `--cfg 'verbose'` or `--cfg 'feature="serde"'`. These correspond
1919
to `#[cfg(verbose)]` and `#[cfg(feature = "serde")]` respectively.
2020

21+
<a id="option-check-cfg"></a>
22+
## `--check-cfg`: enables checking conditional configurations
23+
24+
This flag will enable checking conditional configurations.
25+
Refer to the [Checking conditional configurations](check-cfg.md) of this book
26+
for further details and explanation.
27+
28+
For examples, `--check-cfg 'cfg(verbose)'` or `--check-cfg 'cfg(feature, values("serde"))'`.
29+
These correspond to `#[cfg(verbose)]` and `#[cfg(feature = "serde")]` respectively.
30+
2131
<a id="option-l-search-path"></a>
2232
## `-L`: add a directory to the library search path
2333

src/doc/rustdoc/src/command-line-arguments.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,20 @@ This flag accepts the same values as `rustc --cfg`, and uses it to configure
131131
compilation. The example above uses `feature`, but any of the `cfg` values
132132
are acceptable.
133133

134+
## `--check-cfg`: check configuration flags
135+
136+
This flag accepts the same values as `rustc --check-cfg`, and uses it to
137+
check configuration flags.
138+
139+
Using this flag looks like this:
140+
141+
```bash
142+
$ rustdoc src/lib.rs --check-cfg='cfg(my_cfg, values("foo", "bar"))'
143+
```
144+
145+
The example above check every well known names and values (`target_os`, `doc`, `test`, ...)
146+
and check the values of `my_cfg`: `foo` and `bar`.
147+
134148
## `--extern`: specify a dependency's location
135149

136150
Using this flag looks like this:

src/doc/rustdoc/src/unstable-features.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -618,22 +618,6 @@ crate being documented (`foobar`) and a path to output the calls
618618
To scrape examples from test code, e.g. functions marked `#[test]`, then
619619
add the `--scrape-tests` flag.
620620

621-
### `--check-cfg`: check configuration flags
622-
623-
* Tracking issue: [#82450](https://github.com/rust-lang/rust/issues/82450)
624-
625-
This flag accepts the same values as `rustc --check-cfg`, and uses it to check configuration flags.
626-
627-
Using this flag looks like this:
628-
629-
```bash
630-
$ rustdoc src/lib.rs -Z unstable-options \
631-
--check-cfg='cfg(feature, values("foo", "bar"))'
632-
```
633-
634-
The example above check every well known names and values (`target_os`, `doc`, `test`, ...)
635-
and check the values of `feature`: `foo` and `bar`.
636-
637621
### `--generate-link-to-definition`: Generate links on types in source code
638622

639623
* Tracking issue: [#89095](https://github.com/rust-lang/rust/issues/89095)

tests/rustdoc-ui/check-cfg.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | #[cfg(uniz)]
55
| ^^^^ help: there is a config with a similar name: `unix`
66
|
77
= help: to expect this configuration use `--check-cfg=cfg(uniz)`
8-
= note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration
8+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
99
= note: `#[warn(unexpected_cfgs)]` on by default
1010

1111
warning: 1 warning emitted

tests/rustdoc-ui/doctest/check-cfg-test.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | #[cfg(feature = "invalid")]
66
|
77
= note: expected values for `feature` are: `test`
88
= help: to expect this configuration use `--check-cfg=cfg(feature, values("invalid"))`
9-
= note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration
9+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
1010
= note: `#[warn(unexpected_cfgs)]` on by default
1111

1212
warning: 1 warning emitted

tests/ui/check-cfg/allow-same-level.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | #[cfg(FALSE)]
66
|
77
= help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, `windows`
88
= help: to expect this configuration use `--check-cfg=cfg(FALSE)`
9-
= note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration
9+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
1010
= note: `#[warn(unexpected_cfgs)]` on by default
1111

1212
warning: 1 warning emitted

0 commit comments

Comments
 (0)