mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 05:51:58 +00:00
SilentEmitter::fatal_note
doesn't need to be optional.
This commit is contained in:
parent
a9a2e1565a
commit
8ba25d0989
@ -558,7 +558,7 @@ impl Emitter for HumanEmitter {
|
||||
/// failures of rustc, as witnessed e.g. in issue #89358.
|
||||
pub struct SilentEmitter {
|
||||
pub fatal_dcx: DiagCtxt,
|
||||
pub fatal_note: Option<String>,
|
||||
pub fatal_note: String,
|
||||
}
|
||||
|
||||
impl Translate for SilentEmitter {
|
||||
@ -576,13 +576,11 @@ impl Emitter for SilentEmitter {
|
||||
None
|
||||
}
|
||||
|
||||
fn emit_diagnostic(&mut self, d: &Diagnostic) {
|
||||
if d.level == Level::Fatal {
|
||||
let mut d = d.clone();
|
||||
if let Some(ref note) = self.fatal_note {
|
||||
d.note(note.clone());
|
||||
}
|
||||
self.fatal_dcx.emit_diagnostic(d);
|
||||
fn emit_diagnostic(&mut self, diag: &Diagnostic) {
|
||||
if diag.level == Level::Fatal {
|
||||
let mut diag = diag.clone();
|
||||
diag.note(self.fatal_note.clone());
|
||||
self.fatal_dcx.emit_diagnostic(diag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,9 +45,9 @@ pub struct Compiler {
|
||||
pub(crate) fn parse_cfg(dcx: &DiagCtxt, cfgs: Vec<String>) -> Cfg {
|
||||
cfgs.into_iter()
|
||||
.map(|s| {
|
||||
let sess = ParseSess::with_silent_emitter(Some(format!(
|
||||
let sess = ParseSess::with_silent_emitter(format!(
|
||||
"this error occurred on the command line: `--cfg={s}`"
|
||||
)));
|
||||
));
|
||||
let filename = FileName::cfg_spec_source_code(&s);
|
||||
|
||||
macro_rules! error {
|
||||
@ -107,9 +107,9 @@ pub(crate) fn parse_check_cfg(dcx: &DiagCtxt, specs: Vec<String>) -> CheckCfg {
|
||||
let mut check_cfg = CheckCfg { exhaustive_names, exhaustive_values, ..CheckCfg::default() };
|
||||
|
||||
for s in specs {
|
||||
let sess = ParseSess::with_silent_emitter(Some(format!(
|
||||
let sess = ParseSess::with_silent_emitter(format!(
|
||||
"this error occurred on the command line: `--check-cfg={s}`"
|
||||
)));
|
||||
));
|
||||
let filename = FileName::cfg_spec_source_code(&s);
|
||||
|
||||
macro_rules! error {
|
||||
|
@ -258,7 +258,7 @@ impl ParseSess {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_silent_emitter(fatal_note: Option<String>) -> Self {
|
||||
pub fn with_silent_emitter(fatal_note: String) -> Self {
|
||||
let fallback_bundle = fallback_fluent_bundle(Vec::new(), false);
|
||||
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
|
||||
let fatal_dcx = DiagCtxt::with_tty_emitter(None, fallback_bundle).disable_warnings();
|
||||
|
Loading…
Reference in New Issue
Block a user