-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
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:
rust-clippy/clippy_lints/src/utils/conf.rs
Lines 326 to 335 in 8bb4690
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)), | |
} | |
} | |
} |
.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