Skip to content

cargo clippy not obeying [lints.clippy] from Cargo.toml, but only for some lints #11237

Closed
@Kmeakin

Description

@Kmeakin

Summary

Clippy does not obey the lint_name = "allow" key under [lints.clippy] from Cargo.toml for certain lints, but does work as expected for others. The lints have to be silenced with #[allow(...)] instead.

In the example below, must_use_candidate obeys the [lints.clippy] settings, but wildcard_imports doesn't.

Other lints that don't obey [lints.clippy] that I have encountered:

  • too_many_lines
  • option_if_let_else

Reproducer

Cargo.toml:

[package]
name = "clippy-test"
version = "0.1.0"
edition = "2021"

[lints.clippy]
pedantic = "warn"

must_use_candidate = "allow"
wildcard_imports = "allow"

.cargo/config.toml:

[unstable]
lints = true

src/lib.rs:

mod foo {
    pub struct A;
}

// "usage of wildcard import" reported
use foo::*;

// "this function could have a `#[must_use]` attribute" not reported
pub fn a() -> A {
    A
}

Version

rustc 1.73.0-nightly (864bdf784 2023-07-25)
binary: rustc
commit-hash: 864bdf7843e1ceabc824ed86d97006acad6af643
commit-date: 2023-07-25
host: x86_64-unknown-linux-gnu
release: 1.73.0-nightly
LLVM version: 16.0.5


### Additional Labels

_No response_

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions