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

Hide warnings from Cargo downloaded subprojects #14035

Merged
merged 3 commits into from
Jan 8, 2025

Conversation

bonzini
Copy link
Collaborator

@bonzini bonzini commented Dec 20, 2024

In Rust, the equivalent of -W/-D options can be added inside the sources themselves (#[warn], #[deny]) and therefore it's quite common for a crate to stop building with newer compilers.

To avoid this, Cargo hides warnings from non-path dependencies using the special flag --cap-lints allow. Do the same for downloaded Cargo subprojects by adding warning_level=0 to the generated subproject's default options. While warning_level=0 generally means "compiler default", Rust has always used it for the similar but inferior option -A warnings, so just replace that with --cap-lints allow.

The question is what to do for pure-Meson Rust subprojects. Here I'm leaving them aside, because they can do the check themselves with meson.is_subproject() if they wanted and because in general I'm tending to treat pure-Meson Rust subprojects as if they follow more the C standards for diagnostics. Therefore I expect them to do something like "use werror when built from git and disable it for releases", or "use #[deny] sparingly and rely more on #[warn] and werror".

This is a better and more backwards-compatible way to disable all warnings,
compared to "-A warnings".  The Rust RFC (https://rust-lang.github.io/rfcs/1193-cap-lints.html)
explains the rationale:

> We would very much like to be able to modify lints, however. For example
> rust-lang/rust#26473 updated the missing_docs lint to also look for missing
> documentation on const items. This ended up breaking some crates in the
> ecosystem due to their usage of #![deny(missing_docs)].

While at it, document that Rust deviates from the other languages in its
interpretation of warning_level=0.

Signed-off-by: Paolo Bonzini <[email protected]>
@bonzini
Copy link
Collaborator Author

bonzini commented Dec 20, 2024

@xclaesse here it is!

@bonzini bonzini force-pushed the rust-caplints-allow branch 2 times, most recently from b1d9e29 to 9ded347 Compare December 20, 2024 18:08
This adds --cap-lints allow, matching how Cargo builds them.  In the case of
Cargo, this is only applied to non-path dependencies.

Without this change, clippy will complain about dependencies as well.

Signed-off-by: Paolo Bonzini <[email protected]>
@bonzini bonzini force-pushed the rust-caplints-allow branch from 9ded347 to a88a3fb Compare December 20, 2024 18:10
…nd line

Meson builds libraries before running clippy, thus all dependencies must be present
and clippy is run only for the warnings (instead, Cargo treats clippy as a separate
toolchain and builds everything).  In Meson's case thus it is pointless to run
clippy whenever --cap-lints allow is included in the command line.

Signed-off-by: Paolo Bonzini <[email protected]>
@bonzini bonzini added this to the 1.7 milestone Dec 31, 2024
@jpakkane jpakkane merged commit 04067fc into mesonbuild:master Jan 8, 2025
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants