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

feat(warnings): add build.warnings option #14388

Merged
merged 3 commits into from
Nov 9, 2024
Merged

Conversation

arlosi
Copy link
Contributor

@arlosi arlosi commented Aug 12, 2024

What does this PR try to resolve?

Allows control over warnings via a new Cargo configuration option build.warnings.

The primary use case is wanting CI runs to deny warnings, while keeping them as warnings for local development. While this is currently possible by conditionally setting RUSTFLAGS in CI, that approach is not available for projects that already use another mechanism for setting RUSTFLAGS, since the two would conflict. Additionally, we may in the future make this apply to more than warnings from rustc.

  • Adds build.warnings config option.

Option values:

  • deny emits an error if any warnings occurred
  • warn is the current existing behavior
  • allow hides the warnings

The option currently only applies to warnings coming from rustc, however it's documented as allowing additional categories of warnings from Cargo to be added.

Fixes #8424
Fixes #14258

How should we test and review this PR?

Tests are included in the PR. For local testing, after building cargo with this PR, run

CARGO_BUILD_WARNINGS=deny CARGO_UNSTABLE_WARNINGS=true cargo check

@rustbot
Copy link
Collaborator

rustbot commented Aug 12, 2024

r? @epage

rustbot has assigned @epage.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-build-execution Area: anything dealing with executing the compiler A-configuration Area: cargo config files and env vars A-documenting-cargo-itself Area: Cargo's documentation A-unstable Area: nightly unstable support S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 12, 2024
@bors
Copy link
Contributor

bors commented Aug 19, 2024

☔ The latest upstream changes (presumably #14423) made this pull request unmergeable. Please resolve the merge conflicts.

@epage
Copy link
Contributor

epage commented Sep 14, 2024

Thanks for the updates!

@arlosi arlosi force-pushed the warnings2 branch 2 times, most recently from f364c80 to 6c80335 Compare September 19, 2024 21:49
@bors
Copy link
Contributor

bors commented Oct 8, 2024

☔ The latest upstream changes (presumably #14137) made this pull request unmergeable. Please resolve the merge conflicts.

src/cargo/util/context/mod.rs Outdated Show resolved Hide resolved
tests/testsuite/warning_override.rs Outdated Show resolved Hide resolved
@bors
Copy link
Contributor

bors commented Oct 29, 2024

☔ The latest upstream changes (presumably #14743) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link
Contributor

@epage epage left a comment

Choose a reason for hiding this comment

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

CI failure needs to be looked at. I'm assuming its unrelated

tests/testsuite/fix.rs Outdated Show resolved Hide resolved
@arlosi arlosi added this pull request to the merge queue Nov 9, 2024
Merged via the queue into rust-lang:master with commit d8cb5fb Nov 9, 2024
20 checks passed
@arlosi arlosi deleted the warnings2 branch November 9, 2024 01:05
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 10, 2024
Update cargo

16 commits in 0310497822a7a673a330a5dd068b7aaa579a265e..4a2d8dc636445b276288543882e076f254b3ae95
2024-11-01 19:27:56 +0000 to 2024-11-09 19:10:33 +0000
- test: adjust `cargo_test_env` to unblock rust submodule update (rust-lang/cargo#14803)
- feat(warnings): add build.warnings option (rust-lang/cargo#14388)
- Revert "feat: Add `CARGO_RUSTC_CURRENT_DIR`" (rust-lang/cargo#14799)
- CI: make the `lint-docs` job required (rust-lang/cargo#14797)
- Switch CI from bors to merge queue (rust-lang/cargo#14718)
- docs(test):  Document Execs assertions based on port effort (rust-lang/cargo#14793)
- fix(test): Make redactions consistent with snapbox (rust-lang/cargo#14790)
- test(gc): Update remaining unordered tests to snapbox (rust-lang/cargo#14785)
- Normalize the `target` paths (rust-lang/cargo#14497)
- rustfix: replace special-case duplicate handling with error (rust-lang/cargo#14782)
- test: Update some emaining unordered tests to snapbox (rust-lang/cargo#14781)
- Change config paths to only check CARGO_HOME for cargo-script (rust-lang/cargo#14749)
- Enable transfer feature in triagebot (rust-lang/cargo#14777)
- Add transactional semantics to `rustfix` (rust-lang/cargo#14747)
- doc: fix `GlobalContext` reference (rust-lang/cargo#14773)
- chore: update handlebars to v6, fix build error (rust-lang/cargo#14772)
@rustbot rustbot added this to the 1.84.0 milestone Nov 10, 2024
mati865 pushed a commit to mati865/rust that referenced this pull request Nov 12, 2024
Update cargo

16 commits in 0310497822a7a673a330a5dd068b7aaa579a265e..4a2d8dc636445b276288543882e076f254b3ae95
2024-11-01 19:27:56 +0000 to 2024-11-09 19:10:33 +0000
- test: adjust `cargo_test_env` to unblock rust submodule update (rust-lang/cargo#14803)
- feat(warnings): add build.warnings option (rust-lang/cargo#14388)
- Revert "feat: Add `CARGO_RUSTC_CURRENT_DIR`" (rust-lang/cargo#14799)
- CI: make the `lint-docs` job required (rust-lang/cargo#14797)
- Switch CI from bors to merge queue (rust-lang/cargo#14718)
- docs(test):  Document Execs assertions based on port effort (rust-lang/cargo#14793)
- fix(test): Make redactions consistent with snapbox (rust-lang/cargo#14790)
- test(gc): Update remaining unordered tests to snapbox (rust-lang/cargo#14785)
- Normalize the `target` paths (rust-lang/cargo#14497)
- rustfix: replace special-case duplicate handling with error (rust-lang/cargo#14782)
- test: Update some emaining unordered tests to snapbox (rust-lang/cargo#14781)
- Change config paths to only check CARGO_HOME for cargo-script (rust-lang/cargo#14749)
- Enable transfer feature in triagebot (rust-lang/cargo#14777)
- Add transactional semantics to `rustfix` (rust-lang/cargo#14747)
- doc: fix `GlobalContext` reference (rust-lang/cargo#14773)
- chore: update handlebars to v6, fix build error (rust-lang/cargo#14772)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-build-execution Area: anything dealing with executing the compiler A-configuration Area: cargo config files and env vars A-documenting-cargo-itself Area: Cargo's documentation A-unstable Area: nightly unstable support A-workspaces Area: workspaces S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

silence warnings in the terminal Add --deny-warnings functionality for all commands.
6 participants