rust-lang / rust-lang/rust-clippy

Expect `lints.workspace = true` for crates in a workspace with a `[workspace.lints]` section

Open
#11,933 10 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-lint T-cargo
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

What it does

If your workspace has a [lints] table specifying lints, then this lint checks that the lints.workspace = true value is set in the Cargo.toml of all packages in the workspace, to ensure that those lints are actually applied.

We also might want to check for the other workspace-inheritable things, but those should be separate lints since people might want to only enforce this for some of them, and I don't personally use any of them, so I'm less qualified to talk about that.

Advantage

Specifying lint levels once in the package workspace is nice, but it's easy to forget to add the corresponding field to the Cargo.toml for each package member, which can result in extra lints specified in the package workspace silently not being applied. Having this lint will allow me to be confident that those lints are picked up in all of my packages.

See my post on URLO asking about how to check for this for the problem it solves.

Drawbacks

Some people might deliberately not inherit the workspace table for all lints, enough that I feel like allow-by-default is probably the play (idk if this belongs in cargo or pedantic, but one of those feels right).

Example

If the workspace Cargo.toml has:

...
[workspace.lints.clippy]
# Unimportant what's here, just that something is set
# Also should apply if it's not clippy lints but some other linter
pedantic = "warn"
...

And the package Cargo.toml is missing a

[lints]
workspace = true

Then we can add it for them.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing existing Clippy lints that inspect Cargo.toml metadata and how workspace lint configuration is represented. Use the provided workspace and package Cargo.toml examples to define the missing-inheritance case, then add coverage showing that packages with a workspace lint section are checked while intentional non-inheritance remains possible.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.