Skip to content

Commit 6b1063d

Browse files
committed
Pass a path to directory to GitignoreBuilder
1 parent c995c46 commit 6b1063d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

rustfmt-core/rustfmt-lib/src/formatting/syntux/session/ignore_path.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::path::Path;
2+
13
use ignore::gitignore::{Gitignore, GitignoreBuilder};
24

35
use crate::config::{FileName, IgnoreList};
@@ -8,7 +10,11 @@ pub(crate) struct IgnorePathSet {
810

911
impl IgnorePathSet {
1012
pub(crate) fn from_ignore_list(ignore_list: &IgnoreList) -> Result<Self, ignore::Error> {
11-
let mut ignore_builder = GitignoreBuilder::new(ignore_list.rustfmt_toml_path());
13+
let root = ignore_list
14+
.rustfmt_toml_path()
15+
.parent()
16+
.unwrap_or(&Path::new(""));
17+
let mut ignore_builder = GitignoreBuilder::new(root);
1218

1319
for ignore_path in ignore_list {
1420
ignore_builder.add_line(None, &ignore_path.to_string_lossy())?;

0 commit comments

Comments
 (0)