Skip to content

User control over cargo warnings #12235

@epage

Description

@epage

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:

Porting clippy lints to cargo

Examples of new lints:

Proposed Solution

As package and workspace level lint control, turning existing warnings into diagnostics where possible

Tasks

Non-blocking

  • rustc-like diagnostics for parsing Cargo.lock
  • rustc-like diagnostics for parsing .cargo/config.toml
  • Deciding how to handle edition compatibility groups and groups in general (since refactor: Remove rust_2024_compatibility lint group #13740 skipped it for 2024)
    • Should we reuse rustc groups or not?
  • rustc-like diagnostics for processing Cargo.toml (ie port warnings off of shell.warn for consistency)
  • Diagnostic summary
  • Paths are not relative to the same root as rustc's

Rejected

  • _::warnings dynamic group (rust or cargo?): specialized warning for specific workflows that is being superseded by other mechanisms

Open questions

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:

  • When inherited, we could potentially show it once per workspace just like rustc would do for a crate level attribute
  • Starting with this now as an MVP, we can always re-evaluate later

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: 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`E-hardExperience: HardS-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions