Skip to content

Commit 909fcfc

Browse files
committed
Stabilize checking of cfgs at compile-time: --check-cfg option
1 parent 99d0186 commit 909fcfc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+60
-95
lines changed

compiler/rustc_session/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1373,7 +1373,7 @@ pub fn rustc_short_optgroups() -> Vec<RustcOptGroup> {
13731373
opt::flag_s("h", "help", "Display this message"),
13741374
opt::multi_s("", "cfg", "Configure the compilation environment.
13751375
SPEC supports the syntax `NAME[=\"VALUE\"]`.", "SPEC"),
1376-
opt::multi("", "check-cfg", "Provide list of valid cfg options for checking", "SPEC"),
1376+
opt::multi_s("", "check-cfg", "Provide list of expected cfgs for checking", "SPEC"),
13771377
opt::multi_s(
13781378
"L",
13791379
"",

src/librustdoc/doctest.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,8 @@ pub(crate) fn generate_args_file(file_path: &Path, options: &RustdocOptions) ->
6060
for cfg in &options.cfgs {
6161
content.push(format!("--cfg={cfg}"));
6262
}
63-
if !options.check_cfgs.is_empty() {
64-
content.push("-Zunstable-options".to_string());
65-
for check_cfg in &options.check_cfgs {
66-
content.push(format!("--check-cfg={check_cfg}"));
67-
}
63+
for check_cfg in &options.check_cfgs {
64+
content.push(format!("--check-cfg={check_cfg}"));
6865
}
6966

7067
for lib_str in &options.lib_strs {

src/librustdoc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ fn opts() -> Vec<RustcOptGroup> {
242242
o.optmulti("L", "library-path", "directory to add to crate search path", "DIR")
243243
}),
244244
stable("cfg", |o| o.optmulti("", "cfg", "pass a --cfg to rustc", "")),
245-
unstable("check-cfg", |o| o.optmulti("", "check-cfg", "pass a --check-cfg to rustc", "")),
245+
stable("check-cfg", |o| o.optmulti("", "check-cfg", "pass a --check-cfg to rustc", "")),
246246
stable("extern", |o| o.optmulti("", "extern", "pass an --extern to rustc", "NAME[=PATH]")),
247247
unstable("extern-html-root-url", |o| {
248248
o.optmulti(

tests/rustdoc-ui/check-cfg/check-cfg.rs renamed to tests/rustdoc-ui/check-cfg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@ check-pass
2-
//@ compile-flags: --check-cfg=cfg() -Z unstable-options
2+
//@ compile-flags: --check-cfg=cfg()
33

44
/// uniz is nor a builtin nor pass as arguments so is unexpected
55
#[cfg(uniz)]

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

Lines changed: 0 additions & 11 deletions
This file was deleted.

tests/rustdoc-ui/check-cfg/check-cfg-unstable.rs

Lines changed: 0 additions & 2 deletions
This file was deleted.

tests/rustdoc-ui/check-cfg/check-cfg-unstable.stderr

Lines changed: 0 additions & 2 deletions
This file was deleted.

tests/ui/check-cfg/allow-at-crate-level.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This test check that #![allow(unexpected_cfgs)] works with --cfg
22
//
33
//@ check-pass
4-
//@ compile-flags: --cfg=unexpected --check-cfg=cfg() -Z unstable-options
4+
//@ compile-flags: --cfg=unexpected --check-cfg=cfg()
55

66
#![allow(unexpected_cfgs)]
77

tests/ui/check-cfg/allow-macro-cfg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This test check that local #[allow(unexpected_cfgs)] works
22
//
33
//@ check-pass
4-
//@ compile-flags: --check-cfg=cfg() -Z unstable-options
4+
//@ compile-flags: --check-cfg=cfg()
55

66
#[allow(unexpected_cfgs)]
77
fn foo() {

0 commit comments

Comments
 (0)