Skip to content

Clippy should probably say something if it sees both a clippy.toml and a .clippy.toml #8323

@hawkw

Description

@hawkw

Description

I recently wasted a bit of time trying to figure out why my lint configurations in a clippy.toml file were not being honored by Clippy. It turned out that the problem was that the workspace already had a .clippy.toml file, which I hadn't noticed existed.

It appears that when clippy searches for config files, it just picks the first one it finds, and stops looking:

for config_file_name in &CONFIG_FILE_NAMES {
if let Ok(config_file) = current.join(config_file_name).canonicalize() {
match fs::metadata(&config_file) {
Err(e) if e.kind() == io::ErrorKind::NotFound => {},
Err(e) => return Err(e),
Ok(md) if md.is_dir() => {},
Ok(_) => return Ok(Some(config_file)),
}
}
}
. So, it was picking the .clippy.toml file and ignoring the clippy.toml I had created.

Admittedly, this was a pretty silly mistake on my part! But, it would be nice if Clippy could notice when there are multiple config files in a workspace, and say "hey, looks like you have multiple config files in the same workspace, I'm only honoring this one". That would have saved me some confusion.

Version

rustc 1.56.1 (59eed8a2a 2021-11-01)
binary: rustc
commit-hash: 59eed8a2aac0230a8b53e89d4e99d55912ba6b35
commit-date: 2021-11-01
host: x86_64-unknown-linux-gnu
release: 1.56.1
LLVM version: 13.0.0

Additional Labels

@rustbot label +C-enhancement

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-uiArea: Clippy interface, usage and configurationC-enhancementCategory: Enhancement of lints, like adding more cases or adding help messages

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions