-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Add --deny-warnings functionality for all commands. #8424
Copy link
Copy link
Closed
Labels
A-diagnosticsArea: Error and warning messages generated by Cargo itself.Area: Error and warning messages generated by Cargo itself.A-lintsArea: rustc lint configurationArea: rustc lint configurationC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Error and warning messages generated by Cargo itself.Area: Error and warning messages generated by Cargo itself.A-lintsArea: rustc lint configurationArea: rustc lint configurationC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Type
Fields
Give feedbackNo fields configured for issues without a type.
Tracking issue: #14802
Describe the problem you are trying to solve
I often automate
cargoand I typically want any automation to halt whencargoemits warnings. AFAICT the only way to do this is to try to parse the output for the way warnings are typically produced.(Related issue: there are two categories of warnings which is confusing and needs clarification, which I filed as #8423 .)
Describe the solution you'd like
Add a commandline flag called
--deny-warningsand if set, if a warning is encountered, this ensures the process will exit with a non-zero status and that no "non-dry-run" operations proceed. For example, withcargo publish --deny-warningsany of the early local packaging-style lint warnings will causecargo publishto avoid making any requests tocrates.io.
Notes
I'm not sure about the option name
--deny-warningswhich I took from the#![deny(warnings)]rust compilation attribute, but I can't think of anything clearer and concise.--treat-warnings-like-errors,--exit-with-error-when-encountering-warnings,--don't-just-warn-me-stop-me!, and--please-save-me-from-myselfall are too cumbersome.Related Tickets
This is related to #3591 because in some way these are opposites (disabling warnings versus escalating them to errors). There might be some common CLI magic that addresses both issues and is clear enough to users.
Even if they use separate cli and/or config specification, if both implemented, they might lead to nonsensical / confusing combinations which a good UX would complain-and-exit about, for example:
cargo do-stuff --hide-warnings --deny-warningsor something similar should probably say "I can't tell what you meant to do."