Skip to content

Commit 51d1b41

Browse files
refactor: don't emit parse errors on main_file ignore matches
1 parent 1fcc9ba commit 51d1b41

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/formatting.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,17 @@ fn format_project<T: FormatHandler>(
7070
Ok(set) => set,
7171
Err(e) => return Err(ErrorKind::InvalidGlobPattern(e)),
7272
};
73-
if config.skip_children() && ignore_path_set.is_match(&main_file) {
73+
let is_ignore_match = ignore_path_set.is_match(&main_file);
74+
if config.skip_children() && is_ignore_match {
7475
return Ok(FormatReport::new());
7576
}
7677

7778
// Parse the crate.
7879
let source_map = Rc::new(SourceMap::new(FilePathMapping::empty()));
7980
let mut parse_session = make_parse_sess(source_map.clone(), config);
81+
if is_ignore_match {
82+
parse_session.span_diagnostic = Handler::with_emitter(true, None, silent_emitter());
83+
}
8084
let mut report = FormatReport::new();
8185
let directory_ownership = input.to_directory_ownership();
8286
let krate = match parse_crate(

0 commit comments

Comments
 (0)