diff --git a/src/bin/rustfmt.rs b/src/bin/rustfmt.rs index 2789b5f6cdd..de906729b31 100644 --- a/src/bin/rustfmt.rs +++ b/src/bin/rustfmt.rs @@ -54,14 +54,15 @@ fn lookup_project_file(input_file: &Path) -> io::Result { // current = try!(fs::canonicalize(current)); loop { - // If the current directory has no parent, we're done searching. - if !current.pop() { - return Err(io::Error::new(io::ErrorKind::NotFound, "Config not found")); - } let config_file = current.join("rustfmt.toml"); if fs::metadata(&config_file).is_ok() { return Ok(config_file); } + + // If the current directory has no parent, we're done searching. + if !current.pop() { + return Err(io::Error::new(io::ErrorKind::NotFound, "Config not found")); + } } }