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

Include lints.rust.unexpected_cfgs.check-cfg in the fingerprint #13958

Merged
merged 2 commits into from
May 28, 2024

Conversation

Urgau
Copy link
Member

@Urgau Urgau commented May 23, 2024

What does this PR try to resolve?

When changing the --check-cfg args in the lints.rust.unexpected_cfgs.check-cfg lint config, the build should be restarted as the arguments we pass to the compiler change, and they can change the diagnostics output by generating new or removing some unexpected_cfgs warning(s).

How should we test and review this PR?

Look at the before and after test (separate commit).

Additional information

Similar to #13012 which did that for the declared features.
Contrary to that PR, I didn't add a new DirtyReason variant, since even the [lints] table didn't get one.

r? @epage

@rustbot rustbot added A-rebuild-detection Area: rebuild detection and fingerprinting S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 23, 2024
Comment on lines 1424 to 1443
// Include all the args from `[lints.rust.unexpected_cfgs.check-cfg]`
let mut lint_check_cfg = Vec::new();
if let Ok(Some(lints)) = unit.pkg.manifest().resolved_toml().resolved_lints() {
if let Some(rust_lints) = lints.get("rust") {
if let Some(unexpected_cfgs) = rust_lints.get("unexpected_cfgs") {
if let Some(config) = unexpected_cfgs.config() {
if let Some(check_cfg) = config.get("check-cfg") {
if let Ok(check_cfgs) =
toml::Value::try_into::<Vec<String>>(check_cfg.clone())
{
lint_check_cfg = check_cfgs;
}
}
}
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than re-looking up this entry, we should see if there is a good way to make this reuseable

Example areas to explore

  • I assume we fingerprint the build script check-cfg. Can we mix the two
  • We already check lint_rustflags. Should we instead move the lookup to be a part of that?

Copy link
Member Author

@Urgau Urgau May 23, 2024

Choose a reason for hiding this comment

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

I assume we fingerprint the build script check-cfg. Can we mix the two

I don't know, I'm not sure we do anything special for build-script. I think they are just seen as deps in fingerprint.

We already check lint_rustflags. Should we instead move the lookup to be a part of that?

I had the same though since lint_rustflags creates the different --warn, --allow, ... flags. We could add the --check-cfg args at some point, but not right now since we need to gate all --check-cfg args behind the compiler supporting check-cfg stably, which can only be done when we have access to the BuildRunner1 and Unit (I think) which we don't have access to when lint_rustflags is called

Footnotes

  1. https://github.com/rust-lang/cargo/blob/3830c0ccc239b92d9cd86c8b13b1b22f749b31c9/src/cargo/core/compiler/mod.rs#L1314-L1318

Copy link
Member Author

Choose a reason for hiding this comment

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

I looked a bit more and I think the best way forward would be to add the --check-cfg args in toml::lints_to_rustflags so that we don't need to lookup them here and in check_cfg_args. I've added a fixme for that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Created #13975 (so the hack can be tracked) and updated the code with your suggested wording (as well as changing it to a HACK).

@Urgau Urgau force-pushed the check-cfg-config-fingerprint branch from bb3af49 to dfb69e6 Compare May 28, 2024 18:03
@epage
Copy link
Contributor

epage commented May 28, 2024

@bors r+

@bors
Copy link
Collaborator

bors commented May 28, 2024

📌 Commit dfb69e6 has been approved by epage

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 28, 2024
@bors
Copy link
Collaborator

bors commented May 28, 2024

⌛ Testing commit dfb69e6 with merge 431db31...

@bors
Copy link
Collaborator

bors commented May 28, 2024

☀️ Test successful - checks-actions
Approved by: epage
Pushing 431db31 to master...

@bors bors merged commit 431db31 into rust-lang:master May 28, 2024
21 checks passed
bors added a commit to rust-lang-ci/rust that referenced this pull request May 28, 2024
Update cargo

5 commits in a8d72c675ee52dd57f0d8f2bae6655913c15b2fb..431db31d0dbeda320caf8ef8535ea48eb3093407
2024-05-24 03:34:17 +0000 to 2024-05-28 18:17:31 +0000
- Include `lints.rust.unexpected_cfgs.check-cfg` in the fingerprint (rust-lang/cargo#13958)
- feat(test): Auto-redact elapsed time (rust-lang/cargo#13973)
- chore: Update to snapbox 0.6 (rust-lang/cargo#13963)
- fix: check if rev is full commit sha for github fast path (rust-lang/cargo#13969)
- test: switch from `drop` to `let _` due to nightly rustc change (rust-lang/cargo#13964)

r? ghost
@ehuss ehuss added this to the 1.80.0 milestone Jun 2, 2024
bors added a commit that referenced this pull request Sep 19, 2024
Cleanup duplicated check-cfg lint logic

### What does this PR try to resolve?

This PR clean-ups some duplication left by #13958, because of Cargo MSRV.

Fixes #13975

### How should we test and review this PR?

The tests in `tests/testsuite/check_cfg.rs` show no change in behaviours (except for the better error messages). I suggest maybe reviewing commit by commit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rebuild-detection Area: rebuild detection and fingerprinting S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants