Skip to content

Commit 5173741

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 ed81578 commit 5173741

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

+7
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

+1
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

+1
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

+1
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

+1-1
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

+1
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

+1
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

+4-4
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

+1
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

+4-4
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
| ^^^^^^^^^^^^^^---

tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// This test checks we won't suggest more than 3 span suggestions for cfg names
33
//
44
//@ check-pass
5+
//@ no-auto-check-cfg
56
//@ compile-flags: --check-cfg=cfg(foo,values("value")) --check-cfg=cfg(bar,values("value")) --check-cfg=cfg(bee,values("value")) --check-cfg=cfg(cow,values("value"))
67

78
#[cfg(value)]

tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: unexpected `cfg` condition name: `value`
2-
--> $DIR/cfg-value-for-cfg-name-duplicate.rs:7:7
2+
--> $DIR/cfg-value-for-cfg-name-duplicate.rs:8:7
33
|
44
LL | #[cfg(value)]
55
| ^^^^^

tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// This test checks that when a single cfg has a value for user's specified name
33
//
44
//@ check-pass
5+
//@ no-auto-check-cfg
56
//@ compile-flags: --check-cfg=cfg(foo,values("my_value")) --check-cfg=cfg(bar,values("my_value"))
67

78
#[cfg(my_value)]

tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: unexpected `cfg` condition name: `my_value`
2-
--> $DIR/cfg-value-for-cfg-name-multiple.rs:7:7
2+
--> $DIR/cfg-value-for-cfg-name-multiple.rs:8:7
33
|
44
LL | #[cfg(my_value)]
55
| ^^^^^^^^

tests/ui/check-cfg/cfg-value-for-cfg-name.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// suggest to use `#[cfg(target_os = "linux")]` instead of `#[cfg(linux)]`
44
//
55
//@ check-pass
6+
//@ no-auto-check-cfg
67
//@ compile-flags: --check-cfg=cfg()
78

89
#[cfg(linux)]

tests/ui/check-cfg/cfg-value-for-cfg-name.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: unexpected `cfg` condition name: `linux`
2-
--> $DIR/cfg-value-for-cfg-name.rs:8:7
2+
--> $DIR/cfg-value-for-cfg-name.rs:9:7
33
|
44
LL | #[cfg(linux)]
55
| ^^^^^ help: found config with similar value: `target_os = "linux"`
@@ -10,7 +10,7 @@ LL | #[cfg(linux)]
1010
= note: `#[warn(unexpected_cfgs)]` on by default
1111

1212
warning: unexpected `cfg` condition name: `linux`
13-
--> $DIR/cfg-value-for-cfg-name.rs:13:7
13+
--> $DIR/cfg-value-for-cfg-name.rs:14:7
1414
|
1515
LL | #[cfg(linux = "os-name")]
1616
| ^^^^^^^^^^^^^^^^^

tests/ui/check-cfg/compact-names.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// This test check that we correctly emit an warning for compact cfg
22
//
33
//@ check-pass
4+
//@ no-auto-check-cfg
45
//@ compile-flags: --check-cfg=cfg()
56

67
#![feature(cfg_target_compact)]

tests/ui/check-cfg/compact-names.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: unexpected `cfg` condition name: `target_architecture`
2-
--> $DIR/compact-names.rs:11:28
2+
--> $DIR/compact-names.rs:12:28
33
|
44
LL | #[cfg(target(os = "linux", architecture = "arm"))]
55
| ^^^^^^^^^^^^^^^^^^^^

tests/ui/check-cfg/compact-values.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// This test check that we correctly emit an warning for compact cfg
22
//
33
//@ check-pass
4+
//@ no-auto-check-cfg
45
//@ compile-flags: --check-cfg=cfg()
56

67
#![feature(cfg_target_compact)]

tests/ui/check-cfg/compact-values.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: unexpected `cfg` condition value: `X`
2-
--> $DIR/compact-values.rs:11:28
2+
--> $DIR/compact-values.rs:12:28
33
|
44
LL | #[cfg(target(os = "linux", pointer_width = "X"))]
55
| ^^^^^^^^^^^^^^^^^^^

tests/ui/check-cfg/concat-values.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ check-pass
2+
//@ no-auto-check-cfg
23
//@ compile-flags: --check-cfg=cfg(my_cfg,values("foo")) --check-cfg=cfg(my_cfg,values("bar"))
34
//@ compile-flags: --check-cfg=cfg(my_cfg,values())
45

tests/ui/check-cfg/concat-values.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: unexpected `cfg` condition value: (none)
2-
--> $DIR/concat-values.rs:5:7
2+
--> $DIR/concat-values.rs:6:7
33
|
44
LL | #[cfg(my_cfg)]
55
| ^^^^^^
@@ -10,7 +10,7 @@ LL | #[cfg(my_cfg)]
1010
= note: `#[warn(unexpected_cfgs)]` on by default
1111

1212
warning: unexpected `cfg` condition value: `unk`
13-
--> $DIR/concat-values.rs:9:7
13+
--> $DIR/concat-values.rs:10:7
1414
|
1515
LL | #[cfg(my_cfg = "unk")]
1616
| ^^^^^^^^^^^^^^

tests/ui/check-cfg/diagnotics.cargo.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: unexpected `cfg` condition name: `featur`
2-
--> $DIR/diagnotics.rs:7:7
2+
--> $DIR/diagnotics.rs:8:7
33
|
44
LL | #[cfg(featur)]
55
| ^^^^^^ help: there is a config with a similar name: `feature`
@@ -9,7 +9,7 @@ LL | #[cfg(featur)]
99
= note: `#[warn(unexpected_cfgs)]` on by default
1010

1111
warning: unexpected `cfg` condition name: `featur`
12-
--> $DIR/diagnotics.rs:11:7
12+
--> $DIR/diagnotics.rs:12:7
1313
|
1414
LL | #[cfg(featur = "foo")]
1515
| ^^^^^^^^^^^^^^
@@ -21,7 +21,7 @@ LL | #[cfg(feature = "foo")]
2121
| ~~~~~~~
2222

2323
warning: unexpected `cfg` condition name: `featur`
24-
--> $DIR/diagnotics.rs:15:7
24+
--> $DIR/diagnotics.rs:16:7
2525
|
2626
LL | #[cfg(featur = "fo")]
2727
| ^^^^^^^^^^^^^
@@ -34,7 +34,7 @@ LL | #[cfg(feature = "foo")]
3434
| ~~~~~~~~~~~~~~~
3535

3636
warning: unexpected `cfg` condition name: `no_value`
37-
--> $DIR/diagnotics.rs:22:7
37+
--> $DIR/diagnotics.rs:23:7
3838
|
3939
LL | #[cfg(no_value)]
4040
| ^^^^^^^^ help: there is a config with a similar name: `no_values`
@@ -43,7 +43,7 @@ LL | #[cfg(no_value)]
4343
= note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration
4444

4545
warning: unexpected `cfg` condition name: `no_value`
46-
--> $DIR/diagnotics.rs:26:7
46+
--> $DIR/diagnotics.rs:27:7
4747
|
4848
LL | #[cfg(no_value = "foo")]
4949
| ^^^^^^^^^^^^^^^^
@@ -56,7 +56,7 @@ LL | #[cfg(no_values)]
5656
| ~~~~~~~~~
5757

5858
warning: unexpected `cfg` condition value: `bar`
59-
--> $DIR/diagnotics.rs:30:7
59+
--> $DIR/diagnotics.rs:31:7
6060
|
6161
LL | #[cfg(no_values = "bar")]
6262
| ^^^^^^^^^--------

tests/ui/check-cfg/diagnotics.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ check-pass
2+
//@ no-auto-check-cfg
23
//@ revisions: cargo rustc
34
//@ [rustc]unset-rustc-env:CARGO_CRATE_NAME
45
//@ [cargo]rustc-env:CARGO_CRATE_NAME=foo

tests/ui/check-cfg/diagnotics.rustc.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: unexpected `cfg` condition name: `featur`
2-
--> $DIR/diagnotics.rs:7:7
2+
--> $DIR/diagnotics.rs:8:7
33
|
44
LL | #[cfg(featur)]
55
| ^^^^^^ help: there is a config with a similar name: `feature`
@@ -10,7 +10,7 @@ LL | #[cfg(featur)]
1010
= note: `#[warn(unexpected_cfgs)]` on by default
1111

1212
warning: unexpected `cfg` condition name: `featur`
13-
--> $DIR/diagnotics.rs:11:7
13+
--> $DIR/diagnotics.rs:12:7
1414
|
1515
LL | #[cfg(featur = "foo")]
1616
| ^^^^^^^^^^^^^^
@@ -23,7 +23,7 @@ LL | #[cfg(feature = "foo")]
2323
| ~~~~~~~
2424

2525
warning: unexpected `cfg` condition name: `featur`
26-
--> $DIR/diagnotics.rs:15:7
26+
--> $DIR/diagnotics.rs:16:7
2727
|
2828
LL | #[cfg(featur = "fo")]
2929
| ^^^^^^^^^^^^^
@@ -37,7 +37,7 @@ LL | #[cfg(feature = "foo")]
3737
| ~~~~~~~~~~~~~~~
3838

3939
warning: unexpected `cfg` condition name: `no_value`
40-
--> $DIR/diagnotics.rs:22:7
40+
--> $DIR/diagnotics.rs:23:7
4141
|
4242
LL | #[cfg(no_value)]
4343
| ^^^^^^^^ help: there is a config with a similar name: `no_values`
@@ -46,7 +46,7 @@ LL | #[cfg(no_value)]
4646
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
4747

4848
warning: unexpected `cfg` condition name: `no_value`
49-
--> $DIR/diagnotics.rs:26:7
49+
--> $DIR/diagnotics.rs:27:7
5050
|
5151
LL | #[cfg(no_value = "foo")]
5252
| ^^^^^^^^^^^^^^^^
@@ -59,7 +59,7 @@ LL | #[cfg(no_values)]
5959
| ~~~~~~~~~
6060

6161
warning: unexpected `cfg` condition value: `bar`
62-
--> $DIR/diagnotics.rs:30:7
62+
--> $DIR/diagnotics.rs:31:7
6363
|
6464
LL | #[cfg(no_values = "bar")]
6565
| ^^^^^^^^^--------

tests/ui/check-cfg/empty-values.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Check that we detect unexpected value when none are allowed
22
//
33
//@ check-pass
4+
//@ no-auto-check-cfg
45
//@ compile-flags: --check-cfg=cfg(foo,values())
56

67
#[cfg(foo = "foo")]

0 commit comments

Comments
 (0)