Skip to content

Add a file allowing cross-crate configuration of lints #45832

Closed
@oli-obk

Description

@oli-obk

Right now, if your project has a certain set of lints it wants to use, it needs to repeat the #![deny(foo)] entries in every single crate of the project.

In the clippy project it has frequently been requested (rust-lang/rust-clippy#1313) that we add a clippy.toml file which would have entries for allowing, warning and denying lints, instead of requiring -A, -W or -D flags to the compiler.

I think this is something that should be solved on the rustc side. As a minimal version I propose to add a --lint-file=foo.toml or --lint-settings=foo.toml setting, which is default-filled by cargo by crawling up the directory tree and looking for a lints.toml or rustc.toml (or a green bikshed).

To reduce repeating the lint modifiers, I propose to use the keys allow, deny, warn and forbid of Vec<String> type:

deny = [
    "foo",
    "bar",
]

Does this require an RFC?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-dev-toolsRelevant to the dev-tools subteam, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions