Skip to content

Commit ae980ec

Browse files
committed
impl From<ignore::Error> for ErrorKind
Improves the ergonomics of calling `IgnorePathSet::from_ignore_list`
1 parent fa1d8fa commit ae980ec

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/ignore_path.rs

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use ignore::{self, gitignore};
22

33
use crate::config::{FileName, IgnoreList};
4+
use crate::ErrorKind;
45

56
pub(crate) struct IgnorePathSet {
67
ignore_set: gitignore::Gitignore,
@@ -30,6 +31,12 @@ impl IgnorePathSet {
3031
}
3132
}
3233

34+
impl From<ignore::Error> for ErrorKind {
35+
fn from(error: ignore::Error) -> Self {
36+
ErrorKind::InvalidGlobPattern(error)
37+
}
38+
}
39+
3340
#[cfg(test)]
3441
mod test {
3542
use rustfmt_config_proc_macro::nightly_only_test;

src/parse/session.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,7 @@ fn default_handler(
124124

125125
impl ParseSess {
126126
pub(crate) fn new(config: &Config) -> Result<ParseSess, ErrorKind> {
127-
let ignore_path_set = match IgnorePathSet::from_ignore_list(&config.ignore()) {
128-
Ok(ignore_path_set) => Lrc::new(ignore_path_set),
129-
Err(e) => return Err(ErrorKind::InvalidGlobPattern(e)),
130-
};
127+
let ignore_path_set = Lrc::new(IgnorePathSet::from_ignore_list(&config.ignore())?);
131128
let source_map = Lrc::new(SourceMap::new(FilePathMapping::empty()));
132129
let can_reset_errors = Lrc::new(AtomicBool::new(false));
133130

0 commit comments

Comments
 (0)