Skip to content

Commit 9368de2

Browse files
authored
Merge pull request #2327 from nrc/macro-defs
Some macros 2.0 macro defs
2 parents e52b383 + aa758d6 commit 9368de2

File tree

6 files changed

+460
-14
lines changed

6 files changed

+460
-14
lines changed

src/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,7 @@ create_config! {
684684
"Enables unstable features. Only available on nightly channel";
685685
disable_all_formatting: bool, false, false, "Don't reformat anything";
686686
skip_children: bool, false, false, "Don't reformat out of line modules";
687+
hide_parse_errors: bool, false, false, "Hide errors from the parser";
687688
error_on_line_overflow: bool, true, false, "Error if unable to get all lines within max_width";
688689
error_on_unformatted: bool, false, false,
689690
"Error if unable to get comments or string literals within max_width, \

src/lib.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
#![feature(rustc_private)]
12+
#![feature(type_ascription)]
1213

1314
#[macro_use]
1415
extern crate derive_new;
@@ -597,8 +598,16 @@ pub fn format_input<T: Write>(
597598
}
598599
let codemap = Rc::new(CodeMap::new(FilePathMapping::empty()));
599600

600-
let tty_handler =
601-
Handler::with_tty_emitter(ColorConfig::Auto, true, false, Some(codemap.clone()));
601+
let tty_handler = if config.hide_parse_errors() {
602+
let silent_emitter = Box::new(EmitterWriter::new(
603+
Box::new(Vec::new()),
604+
Some(codemap.clone()),
605+
false,
606+
));
607+
Handler::with_emitter(true, false, silent_emitter)
608+
} else {
609+
Handler::with_tty_emitter(ColorConfig::Auto, true, false, Some(codemap.clone()))
610+
};
602611
let mut parse_session = ParseSess::with_span_handler(tty_handler, codemap.clone());
603612

604613
let main_file = match input {

0 commit comments

Comments
 (0)