Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silently ignore cargo::rustc-check-cfg to avoid MSRV annoyance when stabilizing -Zcheck-cfg #13438

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -916,10 +916,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
}
}
Comment on lines 917 to 922
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imo we should make each of these conditioned this on nightly vs stable

Copy link
Member Author

@Urgau Urgau Feb 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't this create the same issue we trying to avoid?

or do you mean that the silencing part should be conditioned on nightly/stable ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean that it should not be silenced on nightly, so that nightly users get the warning (which is useful!)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main problem we are trying to avoid is when this is stabilized but not yet in people's MSRV: they will either have to live with the build script warning on their MSRV or deal with the check-cfg warning on the latest Rust toolchain.

(btw I keep going back and forth between "meh, this is fine" and "we probably should still warn")

"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 @@ -208,10 +208,8 @@ fn parse_links_overrides(
let list = value.list(key)?;
output.check_cfgs.extend(list.iter().map(|v| v.0.clone()));
} else {
gctx.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 @@ -471,9 +471,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 @@ -555,7 +553,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