rustfmt: Simplify match in project file lookup loop
This commit changes the match in `lookup_project_file` to use pattern guards.
This commit is contained in:
parent
fe5fa874da
commit
72427356eb
|
@ -65,19 +65,17 @@ fn lookup_project_file(dir: &Path) -> FmtResult<Option<PathBuf>> {
|
||||||
loop {
|
loop {
|
||||||
let config_file = current.join("rustfmt.toml");
|
let config_file = current.join("rustfmt.toml");
|
||||||
match fs::metadata(&config_file) {
|
match fs::metadata(&config_file) {
|
||||||
Ok(md) => {
|
// Only return if it's a file to handle the unlikely situation of a directory named
|
||||||
// Properly handle unlikely situation of a directory named `rustfmt.toml`.
|
// `rustfmt.toml`.
|
||||||
if md.is_file() {
|
Ok(ref md) if md.is_file() => return Ok(Some(config_file)),
|
||||||
return Ok(Some(config_file));
|
// Return the error if it's something other than `NotFound`; otherwise we didn't find
|
||||||
}
|
// the project file yet, and continue searching.
|
||||||
}
|
|
||||||
// If it's not found, we continue searching; otherwise something went wrong and we
|
|
||||||
// return the error.
|
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
if e.kind() != ErrorKind::NotFound {
|
if e.kind() != ErrorKind::NotFound {
|
||||||
return Err(FmtError::from(e));
|
return Err(FmtError::from(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the current directory has no parent, we're done searching.
|
// If the current directory has no parent, we're done searching.
|
||||||
|
|
Loading…
Reference in a new issue