feat(compile): Stabilize build.warnings#16796
Conversation
|
r? @weihanglo rustbot has assigned @weihanglo. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
@rfcbot fcp merge cargo |
|
Team member @epage has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
|
Right now, we exactly mirror My one concern is with
From this, I would lean towards making |
|
FYI I found a bug where |
build.warningsbuild.warnings
This comment has been minimized.
This comment has been minimized.
This allows users to either - hide warnings (rust-lang#14258) - error on warnings (rust-lang#8424) `build.warnings` is setup to mirror the behavior of `RUSTFLAGS=-Dwarnings`, including - only errors for lint warnings and not hard warnings - only errors for local warnings and not non-local warnings visible with `--verbose --verbose` - stop the build without `--keep-going` These conditions were not originally met and also came as feedback from rust-lang/rust which has been dogfooding this since the merge of rust-lang/rust#148332. Things are a bit different with `RUSTFLAGS=-Awarnings`: - Hard warnings are hidden for rustc but not cargo (rustc seems in the wrong imo) - In particular, we shouldn't mask the edition warning for Cargo Script - both hide the warning summary line (number of warnings per crate) - both hide non-local warnings for `--verbose --verbose` One design constraint we are operating on with this is that changing `build.warnings` should not cause a rebuild, unlike a `RUSTFLAGS` solution. Closes rust-lang#14802
This comment has been minimized.
This comment has been minimized.
a4e366a to
e98cf0d
Compare
|
I really hope this goes through. |
953e363 to
f1831ee
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Regarding the "hard warnings" discussion, I provided a suggestion here to add a |
|
Please do not allow people to override rustc's decision to force-show a warning :/ we only do that for cases where it really matters. |
|
🔔 This is now entering its final comment period, as per the review above. 🔔 |
|
@rust-rfcbot reviewed Though
Could we have some definition of hard warnings written down somewhere? I don't think we need to make a formal/stable definition, but at least we should capture what we have today. I guess they are
The current implementation is somehow subtle and I am lost |
This comment has been minimized.
This comment has been minimized.
Hard warnings are those that you cannot control the level of, including
|
| ## Checking for warnings | ||
|
|
||
| Customarily, projects want to be "warnings clean" on official branches while being lax for local development. | ||
| [`build.warnings = "deny"`] can be used to fail a CI job if warnings are present. |
There was a problem hiding this comment.
Not a blocker: would love to see we discourage RUSTFLAGS=-Dwarnings explicitly. Maybe this could even be a build optimization topic, like you can reuse dependencies between builds if dropping RUSTFLAGS=-Dwarnings in favor or this.
|
Should there be a consideration for unknown config strings? I'm considering the suggestion in #14802 (comment) that there be additional options for different behaviors. If cargo just errors on an unknown string, that could make it more difficult to add new options in the future. |
|
I think there are some unsaid assumptions that I want to check. You are suggesting we warn on unknown values so that for persistent configs, we act like it is Did I get that right? |
This is a valid concern, though the one of the major use cases here is setting Behavior of some existing config: These enum-based will error during deserialize time.
The We added Besides, |
I don't know what the expected behavior should be. For example, if you have I suppose it depends on how it is expected that people use and specify the setting. If it is mostly CI, or things like rustc bootstrap, then there might be decent ways to work around it if new options are added (and they error on old versions). I'm thinking like how hard would it be to have different settings in a GitHub Actions matrix on different versions? |
|
I looked in #14388 and I'm not seeing a motivation for why we didn't take the standard approach of erroring for use of a nightly feature on stable. When we don't error, normally we warn about the use and particularly warn about unsupported values. We have neither here. Unsure if this was from discussion elsewhere that didn't get recorded or it was overlooked in the implementation and review. I'm normally an advocate for avoiding MSRV bumps where it makes sense. If I had advocated for it, I'm unsure what my motivation was. It might have been
At least for myself, I isolate different types of feedback to different jobs. So I have warnings specific jobs. These are also special because I pin the rust version so CI doesn't go red for a contributor just because a new Rust release comes out. In a situation like this, there isn't an issue with trying to support multiple Rust versions with this setting. If I were to do that, I would likely have a field on the matrix for whether to check warnings and then set the value conditioned on that. |
It was likely an oversight. I was less clear around the policies at the time, and we had recently implemented support for accessing crates.io using the sparse protocol. In that case, we ignored the value rather than erroring. The intent was that it was an opt-in that did not change behavior (ideally), and made it easier to integrate into a CI pipeline with multiple versions. In the case of |
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
☔ The latest upstream changes (possibly da06c61) made this pull request unmergeable. Please resolve the merge conflicts. |
View all comments
What does this PR try to resolve?
This allows users to either
--deny-warningsfunctionality for all commands. #8424)build.warningsserves a similar purpose asRUSTFLAGS=-Dwarnings/RUSTFLAGS=-Awarningsbut without invalidation caches.build.warnings = "deny"will--verbose --verbose--keep-going(this matches
RUSTFLAGS=-Dwarnings)These conditions were not originally met and also came as feedback from rust-lang/rust which has been dogfooding this since the merge of rust-lang/rust#148332.
build.warnings = "allow"willRUSTFLAGS=-Awarningswill suppress rustc hard warnings--verbose --verboseCloses #14802
How to test and review this PR?
My main concern over this was how the naming scheme would extend to rust-lang/rfcs#3730 but that RFC has not gained much interest
buildseems as good of a home as any.