Merge pull request #790 from kamalmarhubi/handle-rustfmt-toml-dir

bin: Properly handle a directories named rustfmt.toml
This commit is contained in:
Marcus Klaas de Vries 2016-01-31 11:32:00 +01:00
commit 02f38558cf

View file

@ -57,9 +57,12 @@ 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() {
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.
if !current.pop() {