1
Fork 0

Rename Handler as DiagCtxt.

This commit is contained in:
Nicholas Nethercote 2023-12-17 21:48:57 +11:00
parent 321b6565a5
commit cde19c016e
58 changed files with 216 additions and 204 deletions

View file

@ -17,7 +17,7 @@ impl<'a> IntoDiagnostic<'a> for FeatureGateError {
#[track_caller]
fn into_diagnostic(
self,
handler: &'a rustc_errors::Handler,
handler: &'a rustc_errors::DiagCtxt,
) -> rustc_errors::DiagnosticBuilder<'a, ErrorGuaranteed> {
let mut diag = handler.struct_err(self.explain);
diag.set_span(self.span);

View file

@ -11,7 +11,7 @@ use crate::lint::{
use rustc_ast::node_id::NodeId;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::sync::{AppendOnlyVec, Lock, Lrc};
use rustc_errors::{emitter::SilentEmitter, Handler};
use rustc_errors::{emitter::SilentEmitter, DiagCtxt};
use rustc_errors::{
fallback_fluent_bundle, Diagnostic, DiagnosticBuilder, DiagnosticId, DiagnosticMessage,
ErrorGuaranteed, IntoDiagnostic, MultiSpan, Noted, StashKey,
@ -189,7 +189,7 @@ pub fn add_feature_diagnostics_for_issue(
/// Info about a parsing session.
pub struct ParseSess {
pub span_diagnostic: Handler,
pub span_diagnostic: DiagCtxt,
pub unstable_features: UnstableFeatures,
pub config: Cfg,
pub check_config: CheckCfg,
@ -227,11 +227,11 @@ impl ParseSess {
pub fn new(locale_resources: Vec<&'static str>, file_path_mapping: FilePathMapping) -> Self {
let fallback_bundle = fallback_fluent_bundle(locale_resources, false);
let sm = Lrc::new(SourceMap::new(file_path_mapping));
let handler = Handler::with_tty_emitter(Some(sm.clone()), fallback_bundle);
let handler = DiagCtxt::with_tty_emitter(Some(sm.clone()), fallback_bundle);
ParseSess::with_span_handler(handler, sm)
}
pub fn with_span_handler(handler: Handler, source_map: Lrc<SourceMap>) -> Self {
pub fn with_span_handler(handler: DiagCtxt, source_map: Lrc<SourceMap>) -> Self {
Self {
span_diagnostic: handler,
unstable_features: UnstableFeatures::from_environment(None),
@ -256,8 +256,8 @@ impl ParseSess {
pub fn with_silent_emitter(fatal_note: Option<String>) -> Self {
let fallback_bundle = fallback_fluent_bundle(Vec::new(), false);
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let fatal_handler = Handler::with_tty_emitter(None, fallback_bundle).disable_warnings();
let handler = Handler::with_emitter(Box::new(SilentEmitter { fatal_handler, fatal_note }))
let fatal_handler = DiagCtxt::with_tty_emitter(None, fallback_bundle).disable_warnings();
let handler = DiagCtxt::with_emitter(Box::new(SilentEmitter { fatal_handler, fatal_note }))
.disable_warnings();
ParseSess::with_span_handler(handler, sm)
}

View file

@ -22,9 +22,9 @@ use rustc_errors::emitter::{DynEmitter, EmitterWriter, HumanReadableErrorType};
use rustc_errors::json::JsonEmitter;
use rustc_errors::registry::Registry;
use rustc_errors::{
error_code, fallback_fluent_bundle, DiagnosticBuilder, DiagnosticId, DiagnosticMessage,
ErrorGuaranteed, FluentBundle, Handler, IntoDiagnostic, LazyFallbackBundle, MultiSpan, Noted,
TerminalUrl,
error_code, fallback_fluent_bundle, DiagCtxt, DiagnosticBuilder, DiagnosticId,
DiagnosticMessage, ErrorGuaranteed, FluentBundle, IntoDiagnostic, LazyFallbackBundle,
MultiSpan, Noted, TerminalUrl,
};
use rustc_macros::HashStable_Generic;
pub use rustc_span::def_id::StableCrateId;
@ -677,7 +677,7 @@ impl Session {
}
#[inline]
pub fn diagnostic(&self) -> &Handler {
pub fn diagnostic(&self) -> &DiagCtxt {
&self.parse_sess.span_diagnostic
}
@ -1416,7 +1416,7 @@ pub fn build_session(
);
let emitter = default_emitter(&sopts, registry, source_map.clone(), bundle, fallback_bundle);
let mut span_diagnostic = Handler::with_emitter(emitter)
let mut span_diagnostic = DiagCtxt::with_emitter(emitter)
.with_flags(sopts.unstable_opts.diagnostic_handler_flags(can_emit_warnings));
if let Some(ice_file) = ice_file {
span_diagnostic = span_diagnostic.with_ice_file(ice_file);
@ -1725,15 +1725,15 @@ enum IncrCompSession {
InvalidBecauseOfErrors { session_directory: PathBuf },
}
/// A wrapper around an [`Handler`] that is used for early error emissions.
/// A wrapper around an [`DiagCtxt`] that is used for early error emissions.
pub struct EarlyErrorHandler {
handler: Handler,
handler: DiagCtxt,
}
impl EarlyErrorHandler {
pub fn new(output: ErrorOutputType) -> Self {
let emitter = mk_emitter(output);
Self { handler: Handler::with_emitter(emitter) }
Self { handler: DiagCtxt::with_emitter(emitter) }
}
pub fn abort_if_errors(&self) {
@ -1747,7 +1747,7 @@ impl EarlyErrorHandler {
self.handler.abort_if_errors();
let emitter = mk_emitter(output);
self.handler = Handler::with_emitter(emitter);
self.handler = DiagCtxt::with_emitter(emitter);
}
#[allow(rustc::untranslatable_diagnostic)]