Report fatal lexer errors in --cfg command line arguments

This commit is contained in:
Fabian Wolff 2021-10-02 19:15:45 +02:00
parent ed937594d3
commit 041212f8fb
5 changed files with 37 additions and 7 deletions

View file

@ -174,9 +174,14 @@ impl ParseSess {
}
}
pub fn with_silent_emitter() -> Self {
pub fn with_silent_emitter(fatal_note: Option<String>) -> Self {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let handler = Handler::with_emitter(false, None, Box::new(SilentEmitter));
let fatal_handler = Handler::with_tty_emitter(ColorConfig::Auto, false, None, None);
let handler = Handler::with_emitter(
false,
None,
Box::new(SilentEmitter { fatal_handler, fatal_note }),
);
ParseSess::with_span_handler(handler, sm)
}