Skip to content

Commit

Permalink
Auto merge of rust-lang#10592 - beetrees:parent-dir-bug-fix, r=giraffate
Browse files Browse the repository at this point in the history
Fix bug with getting parent directories in `lookup_conf_file`

Currently `lookup_conf_file` doesn't canonicalize the configuration directory before using [`PathBuf::pop`](https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.pop) to get the parent directory. This isn't usually an issue when clippy is invoked via `cargo clippy` as `CARGO_MANIFEST_DIR` is already canonicalized. However, this currently causes `clippy-driver` to ignore any `clippy.toml` in any parent directories when  `CARGO_MANIFEST_DIR` and `CLIPPY_CONF_DIR` are not set.

changelog: Fix a bug that would cause parent directories not to be searched for `clippy.toml` when using `clippy-driver` directly.
  • Loading branch information
bors committed Apr 4, 2023
2 parents 85d9f17 + 3b22352 commit 73e412b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion clippy_lints/src/utils/conf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,8 @@ pub fn lookup_conf_file() -> io::Result<(Option<PathBuf>, Vec<String>)> {
// If neither of those exist, use ".".
let mut current = env::var_os("CLIPPY_CONF_DIR")
.or_else(|| env::var_os("CARGO_MANIFEST_DIR"))
.map_or_else(|| PathBuf::from("."), PathBuf::from);
.map_or_else(|| PathBuf::from("."), PathBuf::from)
.canonicalize()?;

let mut found_config: Option<PathBuf> = None;
let mut warnings = vec![];
Expand Down

0 comments on commit 73e412b

Please sign in to comment.