Skip to content

Commit

Permalink
Auto merge of #13500 - ehuss:beta-check-cfg, r=weihanglo
Browse files Browse the repository at this point in the history
[beta-1.77] Backport ignore `cargo::rustc-check-cfg`

This is a beta backport of #13438 (comment) to disable the warning when `cargo::rustc-check-cfg` is used in a build script on stable in order to provide a broader window where we can stabilize check-cfg, and allow developers to avoid the warning when they use a range of different Rust versions (such as stable and nightly).

Also backports to fix CI:
* #13455 — Remove unnecessary use statement in metabuild
  • Loading branch information
bors committed Feb 29, 2024
2 parents 837c09f + 6014cef commit 3fe68ea
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
9 changes: 2 additions & 7 deletions src/cargo/core/compiler/custom_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -915,10 +915,8 @@ impl BuildOutput {
if extra_check_cfg {
check_cfgs.push(value.to_string());
} else {
warnings.push(format!(
"{}{} requires -Zcheck-cfg flag",
syntax_prefix, key
));
// silently ignoring the instruction to try to
// minimise MSRV annoyance when stabilizing -Zcheck-cfg
}
}
"rustc-env" => {
Expand Down Expand Up @@ -1076,9 +1074,6 @@ fn prepare_metabuild(cx: &Context<'_, '_>, unit: &Unit, deps: &[String]) -> Carg
.map(|d| d.unit.target.crate_name())
})
.collect();
for dep in &meta_deps {
output.push(format!("use {};\n", dep));
}
output.push("fn main() {\n".to_string());
for dep in &meta_deps {
output.push(format!(" {}::metabuild();\n", dep));
Expand Down
6 changes: 2 additions & 4 deletions src/cargo/util/config/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,8 @@ fn parse_links_overrides(
let list = value.list(key)?;
output.check_cfgs.extend(list.iter().map(|v| v.0.clone()));
} else {
config.shell().warn(format!(
"target config `{}.{}` requires -Zcheck-cfg flag",
target_key, key
))?;
// silently ignoring the instruction to try to
// minimise MSRV annoyance when stabilizing -Zcheck-cfg
}
}
"rustc-env" => {
Expand Down
6 changes: 2 additions & 4 deletions tests/testsuite/check_cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,9 +456,7 @@ fn build_script_override_feature_gate() {
.build();

p.cargo("check")
.with_stderr_contains(
"warning: target config[..]rustc-check-cfg[..] requires -Zcheck-cfg flag",
)
.with_stderr_does_not_contain("warning: [..]rustc-check-cfg[..]")
.run();
}

Expand Down Expand Up @@ -540,7 +538,7 @@ fn build_script_feature_gate() {
.build();

p.cargo("check")
.with_stderr_contains("warning[..]cargo::rustc-check-cfg requires -Zcheck-cfg flag")
.with_stderr_does_not_contain("warning: [..]rustc-check-cfg[..]")
.with_status(0)
.run();
}
Expand Down

0 comments on commit 3fe68ea

Please sign in to comment.