Skip to content

Commit

Permalink
Auto merge of rust-lang#13438 - Urgau:check-cfg-msrv-annoyance, r=ehuss
Browse files Browse the repository at this point in the history
Silently ignore `cargo::rustc-check-cfg` to avoid MSRV annoyance when stabilizing `-Zcheck-cfg`

This PR, removes the warning when trying to use `cargo::rustc-check-cfg` on stable or nightly (without the nightly-only `-Zcheck-cfg` flag) to avoid MSRV annoyance when stabilizing `-Zcheck-cfg`.

See this [Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/check-cfg.20backwards.20compatible.20warnings) for more information and context.

cc `@ehuss`
  • Loading branch information
bors authored and ehuss committed Feb 28, 2024
1 parent 837c09f commit e4842f2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
6 changes: 2 additions & 4 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
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 e4842f2

Please sign in to comment.