mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Replace ParseSess::set_dcx with DiagCtxt::set_emitter
Replacing the error emitter doesn't accidentally clear the error count.
This commit is contained in:
@@ -712,6 +712,10 @@ fn fallback_fluent_bundle(&self) -> &FluentBundle {
|
||||
inner.emitter = new_emitter;
|
||||
}
|
||||
|
||||
pub fn set_emitter(&self, emitter: Box<dyn Emitter + DynSend>) {
|
||||
self.inner.borrow_mut().emitter = emitter;
|
||||
}
|
||||
|
||||
/// Translate `message` eagerly with `args` to `SubdiagMessage::Eager`.
|
||||
pub fn eagerly_translate<'a>(
|
||||
&self,
|
||||
|
||||
@@ -337,8 +337,4 @@ pub fn proc_macro_quoted_spans(&self) -> impl Iterator<Item = (usize, Span)> + '
|
||||
pub fn dcx(&self) -> DiagCtxtHandle<'_> {
|
||||
self.dcx.handle()
|
||||
}
|
||||
|
||||
pub fn set_dcx(&mut self, dcx: DiagCtxt) {
|
||||
self.dcx = dcx;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
extern crate rustc_session;
|
||||
extern crate rustc_span;
|
||||
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use rustc_errors::emitter::Emitter;
|
||||
use rustc_errors::registry::{self, Registry};
|
||||
use rustc_errors::translation::Translate;
|
||||
@@ -17,8 +19,6 @@
|
||||
use rustc_session::config;
|
||||
use rustc_span::source_map::SourceMap;
|
||||
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
struct DebugEmitter {
|
||||
source_map: Arc<SourceMap>,
|
||||
diagnostics: Arc<Mutex<Vec<DiagInner>>>,
|
||||
@@ -67,10 +67,10 @@ fn main() {
|
||||
locale_resources: rustc_driver::DEFAULT_LOCALE_RESOURCES.to_owned(),
|
||||
lint_caps: rustc_hash::FxHashMap::default(),
|
||||
psess_created: Some(Box::new(|parse_sess| {
|
||||
parse_sess.set_dcx(DiagCtxt::new(Box::new(DebugEmitter {
|
||||
parse_sess.dcx().set_emitter(Box::new(DebugEmitter {
|
||||
source_map: parse_sess.clone_source_map(),
|
||||
diagnostics,
|
||||
})));
|
||||
}));
|
||||
})),
|
||||
register_lints: None,
|
||||
override_queries: None,
|
||||
|
||||
Reference in New Issue
Block a user