Rollup merge of #119601 - nnethercote:Emitter-cleanups, r=oli-obk
`Emitter` cleanups Some improvements I found while looking at this code. r? `@oli-obk`
This commit is contained in:
commit
da700b39df
13 changed files with 465 additions and 52 deletions
|
@ -2035,23 +2035,14 @@ fn check_error_format_stability(
|
|||
early_dcx: &mut EarlyDiagCtxt,
|
||||
unstable_opts: &UnstableOptions,
|
||||
error_format: ErrorOutputType,
|
||||
json_rendered: HumanReadableErrorType,
|
||||
) {
|
||||
if !unstable_opts.unstable_options {
|
||||
if let ErrorOutputType::Json { pretty: true, json_rendered } = error_format {
|
||||
early_dcx.abort_if_error_and_set_error_format(ErrorOutputType::Json {
|
||||
pretty: false,
|
||||
json_rendered,
|
||||
});
|
||||
if let ErrorOutputType::Json { pretty: true, .. } = error_format {
|
||||
early_dcx.early_fatal("`--error-format=pretty-json` is unstable");
|
||||
}
|
||||
if let ErrorOutputType::HumanReadable(HumanReadableErrorType::AnnotateSnippet(_)) =
|
||||
error_format
|
||||
{
|
||||
early_dcx.abort_if_error_and_set_error_format(ErrorOutputType::Json {
|
||||
pretty: false,
|
||||
json_rendered,
|
||||
});
|
||||
early_dcx.early_fatal("`--error-format=human-annotate-rs` is unstable");
|
||||
}
|
||||
}
|
||||
|
@ -2649,7 +2640,7 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
|
|||
let mut unstable_opts = UnstableOptions::build(early_dcx, matches);
|
||||
let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(early_dcx, matches);
|
||||
|
||||
check_error_format_stability(early_dcx, &unstable_opts, error_format, json_rendered);
|
||||
check_error_format_stability(early_dcx, &unstable_opts, error_format);
|
||||
|
||||
if !unstable_opts.unstable_options && json_unused_externs.is_enabled() {
|
||||
early_dcx.early_fatal(
|
||||
|
|
|
@ -17,8 +17,8 @@ use rustc_data_structures::profiling::{SelfProfiler, SelfProfilerRef};
|
|||
use rustc_data_structures::sync::{
|
||||
AtomicU64, DynSend, DynSync, Lock, Lrc, OneThread, Ordering::SeqCst,
|
||||
};
|
||||
use rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitterWriter;
|
||||
use rustc_errors::emitter::{DynEmitter, EmitterWriter, HumanReadableErrorType};
|
||||
use rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitter;
|
||||
use rustc_errors::emitter::{DynEmitter, HumanEmitter, HumanReadableErrorType};
|
||||
use rustc_errors::json::JsonEmitter;
|
||||
use rustc_errors::registry::Registry;
|
||||
use rustc_errors::{
|
||||
|
@ -1000,7 +1000,7 @@ fn default_emitter(
|
|||
let (short, color_config) = kind.unzip();
|
||||
|
||||
if let HumanReadableErrorType::AnnotateSnippet(_) = kind {
|
||||
let emitter = AnnotateSnippetEmitterWriter::new(
|
||||
let emitter = AnnotateSnippetEmitter::new(
|
||||
Some(source_map),
|
||||
bundle,
|
||||
fallback_bundle,
|
||||
|
@ -1009,7 +1009,7 @@ fn default_emitter(
|
|||
);
|
||||
Box::new(emitter.ui_testing(sopts.unstable_opts.ui_testing))
|
||||
} else {
|
||||
let emitter = EmitterWriter::stderr(color_config, fallback_bundle)
|
||||
let emitter = HumanEmitter::stderr(color_config, fallback_bundle)
|
||||
.fluent_bundle(bundle)
|
||||
.sm(Some(source_map))
|
||||
.short_message(short)
|
||||
|
@ -1504,7 +1504,7 @@ fn mk_emitter(output: ErrorOutputType) -> Box<DynEmitter> {
|
|||
let emitter: Box<DynEmitter> = match output {
|
||||
config::ErrorOutputType::HumanReadable(kind) => {
|
||||
let (short, color_config) = kind.unzip();
|
||||
Box::new(EmitterWriter::stderr(color_config, fallback_bundle).short_message(short))
|
||||
Box::new(HumanEmitter::stderr(color_config, fallback_bundle).short_message(short))
|
||||
}
|
||||
config::ErrorOutputType::Json { pretty, json_rendered } => Box::new(JsonEmitter::basic(
|
||||
pretty,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue