Feature Request: Add an option to display only errors in cargo check #15407
Labels
A-diagnostics
Area: Error and warning messages generated by Cargo itself.
C-feature-request
Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
S-needs-info
Status: Needs more info, such as a reproduction or more background for a feature request.
Problem
Summary
In collaborative projects, developers often encounter warnings (warnings) generated by code written by other team members. While warnings are important for improving code quality, they may not always be the immediate focus of the developer. Errors (errors), on the other hand, are critical and need to be addressed promptly as they block compilation. Currently,
cargo check
outputs both warnings and errors without an option to filter them.This feature request proposes adding an option to
cargo check
to display only errors, making it easier for developers to focus on critical issues while leaving warnings for later or for other team members to address.Motivation
In large-scale projects, especially those involving multiple contributors, warnings can accumulate due to different coding styles, incomplete implementations, or temporary issues. However, fixing warnings is often not the immediate priority for a developer working on a specific task. Errors, which prevent code from compiling, are more urgent and need immediate attention.
A typical scenario:
cargo check
to verify their changes.Proposed Solution
Introduce a new command-line flag for
cargo check
, such as:--only-errors
: When specified, cargo check will suppress warnings and display only errors.Alternatively:
--filter=errors
: A more generic filtering mechanism that allows selecting specific message types (e.g., errors, warnings, or both).Design Details
Expected output:
Notes
Alternatives
While this functionality can currently be achieved using external tools like grep or jq, these methods require additional setup and are not intuitive for developers unfamiliar with shell scripting or JSON processing. Examples:
grep
:jq
:These approaches are functional but lack the simplicity and integration of a built-in Cargo feature.
Impact
Additional Context
This feature aligns with the philosophy of making Rust tooling ergonomic and developer-friendly. Similar filtering mechanisms exist in other build systems and compilers, making this a familiar and expected feature for developers transitioning to Rust.
I hope this feature can be considered for inclusion in Cargo. Thank you for your time and efforts in maintaining and improving the Rust ecosystem!
The text was updated successfully, but these errors were encountered: