Skip to content

Commit b8bff79

Browse files
committed
compiletest: add no-auto-check-cfg directive
this directive prevents compiletest from adding any implicit and automatic --check-cfg arguments
1 parent 7d1d207 commit b8bff79

File tree

61 files changed

+155
-119
lines changed

Some content is hidden

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

61 files changed

+155
-119
lines changed

src/tools/compiletest/src/header.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ pub struct TestProps {
208208
pub llvm_cov_flags: Vec<String>,
209209
/// Extra flags to pass to LLVM's `filecheck` tool, in tests that use it.
210210
pub filecheck_flags: Vec<String>,
211+
/// Don't automatically insert any `--check-cfg` args
212+
pub no_auto_check_cfg: bool,
211213
}
212214

213215
mod directives {
@@ -249,6 +251,7 @@ mod directives {
249251
pub const COMPARE_OUTPUT_LINES_BY_SUBSET: &'static str = "compare-output-lines-by-subset";
250252
pub const LLVM_COV_FLAGS: &'static str = "llvm-cov-flags";
251253
pub const FILECHECK_FLAGS: &'static str = "filecheck-flags";
254+
pub const NO_AUTO_CHECK_CFG: &'static str = "no-auto-check-cfg";
252255
// This isn't a real directive, just one that is probably mistyped often
253256
pub const INCORRECT_COMPILER_FLAGS: &'static str = "compiler-flags";
254257
}
@@ -304,6 +307,7 @@ impl TestProps {
304307
remap_src_base: false,
305308
llvm_cov_flags: vec![],
306309
filecheck_flags: vec![],
310+
no_auto_check_cfg: false,
307311
}
308312
}
309313

@@ -567,6 +571,8 @@ impl TestProps {
567571
if let Some(flags) = config.parse_name_value_directive(ln, FILECHECK_FLAGS) {
568572
self.filecheck_flags.extend(split_flags(&flags));
569573
}
574+
575+
config.set_name_directive(ln, NO_AUTO_CHECK_CFG, &mut self.no_auto_check_cfg);
570576
},
571577
);
572578

@@ -860,6 +866,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
860866
"needs-unwind",
861867
"needs-wasmtime",
862868
"needs-xray",
869+
"no-auto-check-cfg",
863870
"no-prefer-dynamic",
864871
"normalize-stderr-32bit",
865872
"normalize-stderr-64bit",

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// This test check that #![allow(unexpected_cfgs)] works with --cfg
22
//
33
//@ check-pass
4+
//@ no-auto-check-cfg
45
//@ compile-flags: --cfg=unexpected --check-cfg=cfg()
56

67
#![allow(unexpected_cfgs)]

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// This test check that local #[allow(unexpected_cfgs)] works
22
//
33
//@ check-pass
4+
//@ no-auto-check-cfg
45
//@ compile-flags: --check-cfg=cfg()
56

67
#[allow(unexpected_cfgs)]

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// This test check that #[allow(unexpected_cfgs)] doesn't work if put on the same level
22
//
33
//@ check-pass
4+
//@ no-auto-check-cfg
45
//@ compile-flags: --check-cfg=cfg()
56

67
#[allow(unexpected_cfgs)]

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: unexpected `cfg` condition name: `FALSE`
2-
--> $DIR/allow-same-level.rs:7:7
2+
--> $DIR/allow-same-level.rs:8:7
33
|
44
LL | #[cfg(FALSE)]
55
| ^^^^^

tests/ui/check-cfg/allow-top-level.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// This test check that a top-level #![allow(unexpected_cfgs)] works
22
//
33
//@ check-pass
4+
//@ no-auto-check-cfg
45
//@ compile-flags: --check-cfg=cfg()
56

67
#![allow(unexpected_cfgs)]

tests/ui/check-cfg/allow-upper-level.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// This test check that #[allow(unexpected_cfgs)] work if put on an upper level
22
//
33
//@ check-pass
4+
//@ no-auto-check-cfg
45
//@ compile-flags: --check-cfg=cfg()
56

67
#[allow(unexpected_cfgs)]

tests/ui/check-cfg/cargo-feature.none.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: unexpected `cfg` condition value: `serde`
2-
--> $DIR/cargo-feature.rs:13:7
2+
--> $DIR/cargo-feature.rs:14:7
33
|
44
LL | #[cfg(feature = "serde")]
55
| ^^^^^^^^^^^^^^^^^ help: remove the condition
@@ -10,7 +10,7 @@ LL | #[cfg(feature = "serde")]
1010
= note: `#[warn(unexpected_cfgs)]` on by default
1111

1212
warning: unexpected `cfg` condition value: (none)
13-
--> $DIR/cargo-feature.rs:17:7
13+
--> $DIR/cargo-feature.rs:18:7
1414
|
1515
LL | #[cfg(feature)]
1616
| ^^^^^^^ help: remove the condition
@@ -20,7 +20,7 @@ LL | #[cfg(feature)]
2020
= note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration
2121

2222
warning: unexpected `cfg` condition name: `tokio_unstable`
23-
--> $DIR/cargo-feature.rs:21:7
23+
--> $DIR/cargo-feature.rs:22:7
2424
|
2525
LL | #[cfg(tokio_unstable)]
2626
| ^^^^^^^^^^^^^^
@@ -30,7 +30,7 @@ LL | #[cfg(tokio_unstable)]
3030
= note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration
3131

3232
warning: unexpected `cfg` condition name: `CONFIG_NVME`
33-
--> $DIR/cargo-feature.rs:25:7
33+
--> $DIR/cargo-feature.rs:26:7
3434
|
3535
LL | #[cfg(CONFIG_NVME = "m")]
3636
| ^^^^^^^^^^^^^^^^^

tests/ui/check-cfg/cargo-feature.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// list of all the expected names
44
//
55
//@ check-pass
6+
//@ no-auto-check-cfg
67
//@ revisions: some none
78
//@ rustc-env:CARGO_CRATE_NAME=foo
89
//@ [none]compile-flags: --check-cfg=cfg(feature,values())

tests/ui/check-cfg/cargo-feature.some.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: unexpected `cfg` condition value: `serde`
2-
--> $DIR/cargo-feature.rs:13:7
2+
--> $DIR/cargo-feature.rs:14:7
33
|
44
LL | #[cfg(feature = "serde")]
55
| ^^^^^^^^^^^^^^^^^
@@ -10,7 +10,7 @@ LL | #[cfg(feature = "serde")]
1010
= note: `#[warn(unexpected_cfgs)]` on by default
1111

1212
warning: unexpected `cfg` condition value: (none)
13-
--> $DIR/cargo-feature.rs:17:7
13+
--> $DIR/cargo-feature.rs:18:7
1414
|
1515
LL | #[cfg(feature)]
1616
| ^^^^^^^- help: specify a config value: `= "bitcode"`
@@ -20,7 +20,7 @@ LL | #[cfg(feature)]
2020
= note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration
2121

2222
warning: unexpected `cfg` condition name: `tokio_unstable`
23-
--> $DIR/cargo-feature.rs:21:7
23+
--> $DIR/cargo-feature.rs:22:7
2424
|
2525
LL | #[cfg(tokio_unstable)]
2626
| ^^^^^^^^^^^^^^
@@ -30,7 +30,7 @@ LL | #[cfg(tokio_unstable)]
3030
= note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration
3131

3232
warning: unexpected `cfg` condition value: `m`
33-
--> $DIR/cargo-feature.rs:25:7
33+
--> $DIR/cargo-feature.rs:26:7
3434
|
3535
LL | #[cfg(CONFIG_NVME = "m")]
3636
| ^^^^^^^^^^^^^^---

0 commit comments

Comments
 (0)