Skip to content

Commit 0b17a75

Browse files
committed
fixup! Merge configs from parent directories
1 parent fc9e0bc commit 0b17a75

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

rustfmt-core/rustfmt-bin/src/bin/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ fn format(opt: Opt) -> Result<i32> {
488488
if opt.verbose {
489489
if let Some(paths) = config_paths.as_ref() {
490490
println!(
491-
"Using rustfmt config files {}",
491+
"Using rustfmt config file(s) {}",
492492
paths
493493
.into_iter()
494494
.map(|p| p.display().to_string())

rustfmt-core/rustfmt-lib/src/config.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -273,14 +273,10 @@ impl Config {
273273

274274
// List of closest -> most distant rustfmt config from the current directory.
275275
let config_paths: Option<Vec<_>> = paths.into_iter().filter(|p| p.is_some()).collect();
276-
let has_paths = config_paths.as_ref().and_then(|paths| {
277-
if paths.is_empty() {
278-
None
279-
} else {
280-
Some(paths.len())
281-
}
282-
});
283-
if has_paths.is_some() {
276+
let has_paths = config_paths
277+
.as_ref()
278+
.map_or(false, |paths| !paths.is_empty());
279+
if has_paths {
284280
return Ok(config_paths);
285281
}
286282

rustfmt-core/rustfmt-lib/src/config/options.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,7 @@ impl IgnoreList {
292292
p.strip_prefix(new_rustfmt_toml_path.parent().unwrap())
293293
.map(PathBuf::from)
294294
})
295-
.filter(|p| p.is_ok())
296-
.map(|p| p.unwrap())
295+
.flatten()
297296
.collect();
298297

299298
let mut path_set = other.path_set;

0 commit comments

Comments
 (0)