From e4842f2e635a7a88a7a05a8775d14cf2b0ea8e6b Mon Sep 17 00:00:00 2001 From: bors Date: Wed, 28 Feb 2024 15:14:12 +0000 Subject: [PATCH] Auto merge of #13438 - Urgau:check-cfg-msrv-annoyance, r=ehuss 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` --- src/cargo/core/compiler/custom_build.rs | 6 ++---- src/cargo/util/config/target.rs | 6 ++---- tests/testsuite/check_cfg.rs | 6 ++---- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/cargo/core/compiler/custom_build.rs b/src/cargo/core/compiler/custom_build.rs index 99311a5ffd1..3df41328ef3 100644 --- a/src/cargo/core/compiler/custom_build.rs +++ b/src/cargo/core/compiler/custom_build.rs @@ -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" => { diff --git a/src/cargo/util/config/target.rs b/src/cargo/util/config/target.rs index 0e2029ffc56..1e546c1edc1 100644 --- a/src/cargo/util/config/target.rs +++ b/src/cargo/util/config/target.rs @@ -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" => { diff --git a/tests/testsuite/check_cfg.rs b/tests/testsuite/check_cfg.rs index 5f34774094e..4ce5894346b 100644 --- a/tests/testsuite/check_cfg.rs +++ b/tests/testsuite/check_cfg.rs @@ -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(); } @@ -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(); }