-
Notifications
You must be signed in to change notification settings - Fork 2.9k
User control over cargo warnings #12235
Copy link
Copy link
Open
Labels
A-diagnosticsArea: Error and warning messages generated by Cargo itself.Area: Error and warning messages generated by Cargo itself.C-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`E-hardExperience: HardExperience: HardS-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Error and warning messages generated by Cargo itself.Area: Error and warning messages generated by Cargo itself.C-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`E-hardExperience: HardExperience: HardS-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Problem
Today, cargo maintainers are very cautious as to what warnings are created because they cannot be turned off by the user when they are intended. The problem is we've not had a mechanism to control it. With #12115, we'll now have a mechanism
Turning existing warnings into lints:
[patch]inconfig.tomltriggers unhelpful warnings #11782cargo publish#7380Cargo.tomlwarnings into errors #2568warning: doc tests are not supported for crate type(s) cdylibeven with explicitdoctest = false#15964Porting clippy lints to cargo
Examples of new lints:
cargo publishshould warn on invalid categories/keywords #4300rerun-if-changed=PATHandPATHpoints to none-existing file #6003core#7760[lib]and[package]when publishing #6827package.homepage(see Add guidance on setting homepage in manifest #13293)includepatterns should report invalid paths #14390cargo packagecargo package(and publish) includestargetfolder #15398 (comment)Proposed Solution
As package and workspace level lint control, turning existing warnings into diagnostics where possible
Tasks
Cargo.toml(feat: Addrustcstyle errors for manifest parsing #13172)im_a_teapotlint should be unstable (see Cleanup linting system #13797 for context) (implemented in Error when unstable lints are specified but not enabled #13805)rustcandclippy(see Add tooling to document lints #14025)text-direction-codepoint-in-commentlint #16374, Addtext-direction-codepoint-in-literallint #16373package.homepage#15871build.warningscontrolunwrap-Z) (what should be the behavior of lints for runtime controlled unstable features likehint-mostly-unused, always run or only with-Z)Snippet(e.g. in-memory manifests), at least provide anOriginunused_dependencies(feat(lints): Emit unused_dependencies lint #16600). Started with anignored = ["dep_name], then ignoringdirect & transitive(fix(compile): Ignore unused deps if also transitive #16935, Revert "feat(lints): Add unused deps ignore list" #16937)Non-blocking
Cargo.lock.cargo/config.tomlrust_2024_compatibilitylint group #13740 skipped it for 2024)Cargo.toml(ie port warnings off ofshell.warnfor consistency)Rejected
_::warningsdynamic group (rustorcargo?): specialized warning for specific workflows that is being superseded by other mechanismsOpen questions
workspace.lints(with a sometimes fallback tolintssimilar to*.resolver)Notes
There will still be lints that are not related to the package but related to the user or / invocation. At a later stage, we can consider user-level lint levels.
Showing lint reason once per package:
Deferred reducing boilerplate
Deferred json messages
Deferred: whether to make lint docs more like clippy
Out of scope: CLI control. That would be evaluated for
[lints]as a whole, potentially through config. Note that existing runtime lint control is not officially supported in Cargo but done through an escape hatch