mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-28 20:16:58 +03:00
bin: Properly handle a directories named rustfmt.toml
`lookup_project_file` could erroneously find a *directory* named `rustmfmt.toml` if there was one in its lookup path, and so ignore any configuration file it should have found further up. The error handling resulted in this silently using the default configuration.
This commit is contained in:
+5
-2
@@ -57,8 +57,11 @@ fn lookup_project_file(input_file: &Path) -> io::Result<PathBuf> {
|
||||
|
||||
loop {
|
||||
let config_file = current.join("rustfmt.toml");
|
||||
if fs::metadata(&config_file).is_ok() {
|
||||
return Ok(config_file);
|
||||
if let Ok(md) = fs::metadata(&config_file) {
|
||||
// Properly handle unlikely situation of a directory named `rustfmt.toml`.
|
||||
if md.is_file() {
|
||||
return Ok(config_file);
|
||||
}
|
||||
}
|
||||
|
||||
// If the current directory has no parent, we're done searching.
|
||||
|
||||
Reference in New Issue
Block a user