Skip to content

Commit 8ba25d0

Browse files
committed
SilentEmitter::fatal_note doesn't need to be optional.
1 parent a9a2e15 commit 8ba25d0

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

compiler/rustc_errors/src/emitter.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ impl Emitter for HumanEmitter {
558558
/// failures of rustc, as witnessed e.g. in issue #89358.
559559
pub struct SilentEmitter {
560560
pub fatal_dcx: DiagCtxt,
561-
pub fatal_note: Option<String>,
561+
pub fatal_note: String,
562562
}
563563

564564
impl Translate for SilentEmitter {
@@ -576,13 +576,11 @@ impl Emitter for SilentEmitter {
576576
None
577577
}
578578

579-
fn emit_diagnostic(&mut self, d: &Diagnostic) {
580-
if d.level == Level::Fatal {
581-
let mut d = d.clone();
582-
if let Some(ref note) = self.fatal_note {
583-
d.note(note.clone());
584-
}
585-
self.fatal_dcx.emit_diagnostic(d);
579+
fn emit_diagnostic(&mut self, diag: &Diagnostic) {
580+
if diag.level == Level::Fatal {
581+
let mut diag = diag.clone();
582+
diag.note(self.fatal_note.clone());
583+
self.fatal_dcx.emit_diagnostic(diag);
586584
}
587585
}
588586
}

compiler/rustc_interface/src/interface.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ pub struct Compiler {
4545
pub(crate) fn parse_cfg(dcx: &DiagCtxt, cfgs: Vec<String>) -> Cfg {
4646
cfgs.into_iter()
4747
.map(|s| {
48-
let sess = ParseSess::with_silent_emitter(Some(format!(
48+
let sess = ParseSess::with_silent_emitter(format!(
4949
"this error occurred on the command line: `--cfg={s}`"
50-
)));
50+
));
5151
let filename = FileName::cfg_spec_source_code(&s);
5252

5353
macro_rules! error {
@@ -107,9 +107,9 @@ pub(crate) fn parse_check_cfg(dcx: &DiagCtxt, specs: Vec<String>) -> CheckCfg {
107107
let mut check_cfg = CheckCfg { exhaustive_names, exhaustive_values, ..CheckCfg::default() };
108108

109109
for s in specs {
110-
let sess = ParseSess::with_silent_emitter(Some(format!(
110+
let sess = ParseSess::with_silent_emitter(format!(
111111
"this error occurred on the command line: `--check-cfg={s}`"
112-
)));
112+
));
113113
let filename = FileName::cfg_spec_source_code(&s);
114114

115115
macro_rules! error {

compiler/rustc_session/src/parse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ impl ParseSess {
258258
}
259259
}
260260

261-
pub fn with_silent_emitter(fatal_note: Option<String>) -> Self {
261+
pub fn with_silent_emitter(fatal_note: String) -> Self {
262262
let fallback_bundle = fallback_fluent_bundle(Vec::new(), false);
263263
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
264264
let fatal_dcx = DiagCtxt::with_tty_emitter(None, fallback_bundle).disable_warnings();

0 commit comments

Comments
 (0)