From d49d136b3a0e9749e4aa517b7aa6490752444cf7 Mon Sep 17 00:00:00 2001 From: Yacin Tmimi Date: Tue, 19 Mar 2024 12:58:23 -0400 Subject: conditionally ignore fatal diagnostic in the SilentEmitter This change is primarily meant to allow rustfmt to ignore all diagnostics when using the `SilentEmitter`. Back in PR 121301 the `SilentEmitter` was shared between rustc and rustfmt. This changed rustfmt's behavior from ignoring all diagnostic to emitting fatal diagnostics. These changes allow rustfmt to maintain it's previous behaviour when using the SilentEmitter, while allowing rustc code to still emit fatal diagnostics. --- compiler/rustc_interface/src/interface.rs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'compiler/rustc_interface/src') diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs index 1a82e6c6910..edf52fe8c34 100644 --- a/compiler/rustc_interface/src/interface.rs +++ b/compiler/rustc_interface/src/interface.rs @@ -48,6 +48,7 @@ pub(crate) fn parse_cfg(dcx: &DiagCtxt, cfgs: Vec) -> Cfg { let psess = ParseSess::with_silent_emitter( vec![crate::DEFAULT_LOCALE_RESOURCE, rustc_parse::DEFAULT_LOCALE_RESOURCE], format!("this error occurred on the command line: `--cfg={s}`"), + true, ); let filename = FileName::cfg_spec_source_code(&s); @@ -111,6 +112,7 @@ pub(crate) fn parse_check_cfg(dcx: &DiagCtxt, specs: Vec) -> CheckCfg { let psess = ParseSess::with_silent_emitter( vec![crate::DEFAULT_LOCALE_RESOURCE, rustc_parse::DEFAULT_LOCALE_RESOURCE], format!("this error occurred on the command line: `--check-cfg={s}`"), + true, ); let filename = FileName::cfg_spec_source_code(&s); -- cgit 1.4.1-3-g733a5