Skip to content

Commit

Permalink
fixup! Merge configs from parent directories
Browse files Browse the repository at this point in the history
  • Loading branch information
ayazhafiz committed May 22, 2020
1 parent fc9e0bc commit 0b17a75
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion rustfmt-core/rustfmt-bin/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ fn format(opt: Opt) -> Result<i32> {
if opt.verbose {
if let Some(paths) = config_paths.as_ref() {
println!(
"Using rustfmt config files {}",
"Using rustfmt config file(s) {}",
paths
.into_iter()
.map(|p| p.display().to_string())
Expand Down
12 changes: 4 additions & 8 deletions rustfmt-core/rustfmt-lib/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,10 @@ impl Config {

// List of closest -> most distant rustfmt config from the current directory.
let config_paths: Option<Vec<_>> = paths.into_iter().filter(|p| p.is_some()).collect();
let has_paths = config_paths.as_ref().and_then(|paths| {
if paths.is_empty() {
None
} else {
Some(paths.len())
}
});
if has_paths.is_some() {
let has_paths = config_paths
.as_ref()
.map_or(false, |paths| !paths.is_empty());
if has_paths {
return Ok(config_paths);
}

Expand Down
3 changes: 1 addition & 2 deletions rustfmt-core/rustfmt-lib/src/config/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,7 @@ impl IgnoreList {
p.strip_prefix(new_rustfmt_toml_path.parent().unwrap())
.map(PathBuf::from)
})
.filter(|p| p.is_ok())
.map(|p| p.unwrap())
.flatten()
.collect();

let mut path_set = other.path_set;
Expand Down

0 comments on commit 0b17a75

Please sign in to comment.