Skip to content

Commit a0a42ad

Browse files
committed
Update regular tests for always-on check-cfg
1 parent 2e73d67 commit a0a42ad

File tree

8 files changed

+48
-42
lines changed

8 files changed

+48
-42
lines changed

Diff for: tests/testsuite/build_script.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -2609,7 +2609,10 @@ fn cfg_test() {
26092609
)
26102610
.file(
26112611
"build.rs",
2612-
r#"fn main() { println!("cargo::rustc-cfg=foo"); }"#,
2612+
r#"fn main() {
2613+
println!("cargo::rustc-cfg=foo");
2614+
println!("cargo::rustc-check-cfg=cfg(foo)");
2615+
}"#,
26132616
)
26142617
.file(
26152618
"src/lib.rs",
@@ -2723,6 +2726,7 @@ fn cfg_override_test() {
27232726
r#"
27242727
[target.{}.a]
27252728
rustc-cfg = ["foo"]
2729+
rustc-check-cfg = ["cfg(foo)"]
27262730
"#,
27272731
rustc_host()
27282732
),
@@ -5557,9 +5561,10 @@ fn build_script_rerun_when_target_rustflags_change() {
55575561
use std::env;
55585562
55595563
fn main() {
5564+
println!("cargo::rustc-check-cfg=cfg(enable)");
55605565
if let Ok(rustflags) = env::var("CARGO_ENCODED_RUSTFLAGS") {
55615566
if !rustflags.is_empty() {
5562-
println!("cargo::rustc-cfg=enable")
5567+
println!("cargo::rustc-cfg=enable");
55635568
}
55645569
}
55655570
}

Diff for: tests/testsuite/cargo/z_help/stdout.term.svg

+29-31
Loading

Diff for: tests/testsuite/features_namespaced.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,8 @@ fn no_implicit_feature() {
377377
r#"
378378
fn main() {
379379
if cfg!(feature = "regex") { println!("regex"); }
380-
if cfg!(feature = "lazy_static") { println!("lazy_static"); }
380+
// #[expect(unexpected_cfgs)]
381+
// if cfg!(feature = "lazy_static") { println!("lazy_static"); }
381382
}
382383
"#,
383384
)

Diff for: tests/testsuite/package_features.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,9 @@ fn virtual_with_specific() {
189189
.file(
190190
"a/src/lib.rs",
191191
r#"
192-
#[cfg(not_feature = "f1")]
192+
#[cfg(not(feature = "f1"))]
193193
compile_error!{"f1 is missing"}
194-
#[cfg(not_feature = "f2")]
194+
#[cfg(not(feature = "f2"))]
195195
compile_error!{"f2 is missing"}
196196
"#,
197197
)
@@ -211,9 +211,9 @@ fn virtual_with_specific() {
211211
.file(
212212
"b/src/lib.rs",
213213
r#"
214-
#[cfg(not_feature = "f2")]
214+
#[cfg(not(feature = "f2"))]
215215
compile_error!{"f2 is missing"}
216-
#[cfg(not_feature = "f3")]
216+
#[cfg(not(feature = "f3"))]
217217
compile_error!{"f3 is missing"}
218218
"#,
219219
)

Diff for: tests/testsuite/profiles.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ fn profile_overrides() {
3232
[RUNNING] `rustc --crate-name test --edition=2015 src/lib.rs [..]--crate-type lib \
3333
--emit=[..]link[..]\
3434
-C opt-level=1[..]\
35-
-C debug-assertions=on \
35+
-C debug-assertions=on[..] \
3636
-C metadata=[..] \
3737
-C rpath \
3838
--out-dir [..] \
@@ -141,7 +141,7 @@ fn check_opt_level_override(profile_level: &str, rustc_level: &str) {
141141
--emit=[..]link \
142142
-C opt-level={level}[..]\
143143
-C debuginfo=2 [..]\
144-
-C debug-assertions=on \
144+
-C debug-assertions=on[..] \
145145
-C metadata=[..] \
146146
--out-dir [..] \
147147
-L dependency=[CWD]/target/debug/deps`

Diff for: tests/testsuite/rustc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ fn lib() {
4141
[COMPILING] foo v0.0.1 ([CWD])
4242
[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type lib \
4343
--emit=[..]link[..]-C debuginfo=2 [..]\
44-
-C debug-assertions=off \
44+
-C debug-assertions=off [..] \
4545
-C metadata=[..] \
4646
--out-dir [..] \
4747
-L dependency=[CWD]/target/debug/deps`
@@ -69,7 +69,7 @@ fn build_main_and_allow_unstable_options() {
6969
-L dependency=[CWD]/target/debug/deps`
7070
[RUNNING] `rustc --crate-name {name} --edition=2015 src/main.rs [..]--crate-type bin \
7171
--emit=[..]link[..]-C debuginfo=2 [..]\
72-
-C debug-assertions \
72+
-C debug-assertions [..] \
7373
-C metadata=[..] \
7474
--out-dir [..] \
7575
-L dependency=[CWD]/target/debug/deps \

Diff for: tests/testsuite/rustflags.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1530,6 +1530,7 @@ fn two_matching_in_config() {
15301530
.file(
15311531
"src/main.rs",
15321532
r#"
1533+
#![allow(unexpected_cfgs)]
15331534
fn main() {
15341535
if cfg!(foo = "a") {
15351536
println!("a");

Diff for: tests/testsuite/weak_dep_features.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use std::fmt::Write;
99
// Helper to create lib.rs files that check features.
1010
fn require(enabled_features: &[&str], disabled_features: &[&str]) -> String {
1111
let mut s = String::new();
12+
writeln!(s, "#![allow(unexpected_cfgs)]").unwrap();
1213
for feature in enabled_features {
1314
writeln!(s, "#[cfg(not(feature=\"{feature}\"))] compile_error!(\"expected feature {feature} to be enabled\");",
1415
feature=feature).unwrap();

0 commit comments

Comments
 (0)