Rename EmitterWriter
as HumanEmitter
.
For consistency with other `Emitter` impls, such as `JsonEmitter`, `SilentEmitter`, `SharedEmitter`, etc.
This commit is contained in:
parent
e51e98dde6
commit
cb9abcae79
9 changed files with 29 additions and 29 deletions
|
@ -1393,7 +1393,7 @@ fn report_ice(
|
||||||
) {
|
) {
|
||||||
let fallback_bundle =
|
let fallback_bundle =
|
||||||
rustc_errors::fallback_fluent_bundle(crate::DEFAULT_LOCALE_RESOURCES.to_vec(), false);
|
rustc_errors::fallback_fluent_bundle(crate::DEFAULT_LOCALE_RESOURCES.to_vec(), false);
|
||||||
let emitter = Box::new(rustc_errors::emitter::EmitterWriter::stderr(
|
let emitter = Box::new(rustc_errors::emitter::HumanEmitter::stderr(
|
||||||
rustc_errors::ColorConfig::Auto,
|
rustc_errors::ColorConfig::Auto,
|
||||||
fallback_bundle,
|
fallback_bundle,
|
||||||
));
|
));
|
||||||
|
|
|
@ -61,13 +61,13 @@ impl HumanReadableErrorType {
|
||||||
self,
|
self,
|
||||||
mut dst: Box<dyn WriteColor + Send>,
|
mut dst: Box<dyn WriteColor + Send>,
|
||||||
fallback_bundle: LazyFallbackBundle,
|
fallback_bundle: LazyFallbackBundle,
|
||||||
) -> EmitterWriter {
|
) -> HumanEmitter {
|
||||||
let (short, color_config) = self.unzip();
|
let (short, color_config) = self.unzip();
|
||||||
let color = color_config.suggests_using_colors();
|
let color = color_config.suggests_using_colors();
|
||||||
if !dst.supports_color() && color {
|
if !dst.supports_color() && color {
|
||||||
dst = Box::new(Ansi::new(dst));
|
dst = Box::new(Ansi::new(dst));
|
||||||
}
|
}
|
||||||
EmitterWriter::new(dst, fallback_bundle).short_message(short)
|
HumanEmitter::new(dst, fallback_bundle).short_message(short)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -501,7 +501,7 @@ pub trait Emitter: Translate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Translate for EmitterWriter {
|
impl Translate for HumanEmitter {
|
||||||
fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
|
fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
|
||||||
self.fluent_bundle.as_ref()
|
self.fluent_bundle.as_ref()
|
||||||
}
|
}
|
||||||
|
@ -511,7 +511,7 @@ impl Translate for EmitterWriter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Emitter for EmitterWriter {
|
impl Emitter for HumanEmitter {
|
||||||
fn source_map(&self) -> Option<&Lrc<SourceMap>> {
|
fn source_map(&self) -> Option<&Lrc<SourceMap>> {
|
||||||
self.sm.as_ref()
|
self.sm.as_ref()
|
||||||
}
|
}
|
||||||
|
@ -622,7 +622,7 @@ impl ColorConfig {
|
||||||
|
|
||||||
/// Handles the writing of `HumanReadableErrorType::Default` and `HumanReadableErrorType::Short`
|
/// Handles the writing of `HumanReadableErrorType::Default` and `HumanReadableErrorType::Short`
|
||||||
#[derive(Setters)]
|
#[derive(Setters)]
|
||||||
pub struct EmitterWriter {
|
pub struct HumanEmitter {
|
||||||
#[setters(skip)]
|
#[setters(skip)]
|
||||||
dst: IntoDynSyncSend<Destination>,
|
dst: IntoDynSyncSend<Destination>,
|
||||||
sm: Option<Lrc<SourceMap>>,
|
sm: Option<Lrc<SourceMap>>,
|
||||||
|
@ -647,14 +647,14 @@ pub struct FileWithAnnotatedLines {
|
||||||
multiline_depth: usize,
|
multiline_depth: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EmitterWriter {
|
impl HumanEmitter {
|
||||||
pub fn stderr(color_config: ColorConfig, fallback_bundle: LazyFallbackBundle) -> EmitterWriter {
|
pub fn stderr(color_config: ColorConfig, fallback_bundle: LazyFallbackBundle) -> HumanEmitter {
|
||||||
let dst = from_stderr(color_config);
|
let dst = from_stderr(color_config);
|
||||||
Self::create(dst, fallback_bundle)
|
Self::create(dst, fallback_bundle)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create(dst: Destination, fallback_bundle: LazyFallbackBundle) -> EmitterWriter {
|
fn create(dst: Destination, fallback_bundle: LazyFallbackBundle) -> HumanEmitter {
|
||||||
EmitterWriter {
|
HumanEmitter {
|
||||||
dst: IntoDynSyncSend(dst),
|
dst: IntoDynSyncSend(dst),
|
||||||
sm: None,
|
sm: None,
|
||||||
fluent_bundle: None,
|
fluent_bundle: None,
|
||||||
|
@ -673,7 +673,7 @@ impl EmitterWriter {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
dst: Box<dyn WriteColor + Send>,
|
dst: Box<dyn WriteColor + Send>,
|
||||||
fallback_bundle: LazyFallbackBundle,
|
fallback_bundle: LazyFallbackBundle,
|
||||||
) -> EmitterWriter {
|
) -> HumanEmitter {
|
||||||
Self::create(dst, fallback_bundle)
|
Self::create(dst, fallback_bundle)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ pub use snippet::Style;
|
||||||
pub use termcolor::{Color, ColorSpec, WriteColor};
|
pub use termcolor::{Color, ColorSpec, WriteColor};
|
||||||
|
|
||||||
use crate::diagnostic_impls::{DelayedAtWithNewline, DelayedAtWithoutNewline};
|
use crate::diagnostic_impls::{DelayedAtWithNewline, DelayedAtWithoutNewline};
|
||||||
use emitter::{is_case_difference, DynEmitter, Emitter, EmitterWriter};
|
use emitter::{is_case_difference, DynEmitter, Emitter, HumanEmitter};
|
||||||
use registry::Registry;
|
use registry::Registry;
|
||||||
use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
|
use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
|
||||||
use rustc_data_structures::stable_hasher::{Hash128, StableHasher};
|
use rustc_data_structures::stable_hasher::{Hash128, StableHasher};
|
||||||
|
@ -574,7 +574,7 @@ impl DiagCtxt {
|
||||||
sm: Option<Lrc<SourceMap>>,
|
sm: Option<Lrc<SourceMap>>,
|
||||||
fallback_bundle: LazyFallbackBundle,
|
fallback_bundle: LazyFallbackBundle,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let emitter = Box::new(EmitterWriter::stderr(ColorConfig::Auto, fallback_bundle).sm(sm));
|
let emitter = Box::new(HumanEmitter::stderr(ColorConfig::Auto, fallback_bundle).sm(sm));
|
||||||
Self::with_emitter(emitter)
|
Self::with_emitter(emitter)
|
||||||
}
|
}
|
||||||
pub fn disable_warnings(mut self) -> Self {
|
pub fn disable_warnings(mut self) -> Self {
|
||||||
|
|
|
@ -7,7 +7,7 @@ use rustc_span::source_map::{FilePathMapping, SourceMap};
|
||||||
use rustc_span::{BytePos, Span};
|
use rustc_span::{BytePos, Span};
|
||||||
|
|
||||||
use rustc_data_structures::sync::Lrc;
|
use rustc_data_structures::sync::Lrc;
|
||||||
use rustc_errors::emitter::EmitterWriter;
|
use rustc_errors::emitter::HumanEmitter;
|
||||||
use rustc_errors::{DiagCtxt, MultiSpan, PResult};
|
use rustc_errors::{DiagCtxt, MultiSpan, PResult};
|
||||||
use termcolor::WriteColor;
|
use termcolor::WriteColor;
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ fn create_test_handler() -> (DiagCtxt, Lrc<SourceMap>, Arc<Mutex<Vec<u8>>>) {
|
||||||
vec![crate::DEFAULT_LOCALE_RESOURCE, rustc_parse::DEFAULT_LOCALE_RESOURCE],
|
vec![crate::DEFAULT_LOCALE_RESOURCE, rustc_parse::DEFAULT_LOCALE_RESOURCE],
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
let emitter = EmitterWriter::new(Box::new(Shared { data: output.clone() }), fallback_bundle)
|
let emitter = HumanEmitter::new(Box::new(Shared { data: output.clone() }), fallback_bundle)
|
||||||
.sm(Some(source_map.clone()))
|
.sm(Some(source_map.clone()))
|
||||||
.diagnostic_width(Some(140));
|
.diagnostic_width(Some(140));
|
||||||
let dcx = DiagCtxt::with_emitter(Box::new(emitter));
|
let dcx = DiagCtxt::with_emitter(Box::new(emitter));
|
||||||
|
|
|
@ -18,7 +18,7 @@ use rustc_data_structures::sync::{
|
||||||
AtomicU64, DynSend, DynSync, Lock, Lrc, OneThread, Ordering::SeqCst,
|
AtomicU64, DynSend, DynSync, Lock, Lrc, OneThread, Ordering::SeqCst,
|
||||||
};
|
};
|
||||||
use rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitterWriter;
|
use rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitterWriter;
|
||||||
use rustc_errors::emitter::{DynEmitter, EmitterWriter, HumanReadableErrorType};
|
use rustc_errors::emitter::{DynEmitter, HumanEmitter, HumanReadableErrorType};
|
||||||
use rustc_errors::json::JsonEmitter;
|
use rustc_errors::json::JsonEmitter;
|
||||||
use rustc_errors::registry::Registry;
|
use rustc_errors::registry::Registry;
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
|
@ -1009,7 +1009,7 @@ fn default_emitter(
|
||||||
);
|
);
|
||||||
Box::new(emitter.ui_testing(sopts.unstable_opts.ui_testing))
|
Box::new(emitter.ui_testing(sopts.unstable_opts.ui_testing))
|
||||||
} else {
|
} else {
|
||||||
let emitter = EmitterWriter::stderr(color_config, fallback_bundle)
|
let emitter = HumanEmitter::stderr(color_config, fallback_bundle)
|
||||||
.fluent_bundle(bundle)
|
.fluent_bundle(bundle)
|
||||||
.sm(Some(source_map))
|
.sm(Some(source_map))
|
||||||
.short_message(short)
|
.short_message(short)
|
||||||
|
@ -1501,7 +1501,7 @@ fn mk_emitter(output: ErrorOutputType) -> Box<DynEmitter> {
|
||||||
let emitter: Box<DynEmitter> = match output {
|
let emitter: Box<DynEmitter> = match output {
|
||||||
config::ErrorOutputType::HumanReadable(kind) => {
|
config::ErrorOutputType::HumanReadable(kind) => {
|
||||||
let (short, color_config) = kind.unzip();
|
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(
|
config::ErrorOutputType::Json { pretty, json_rendered } => Box::new(JsonEmitter::basic(
|
||||||
pretty,
|
pretty,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||||
use rustc_data_structures::sync::Lrc;
|
use rustc_data_structures::sync::Lrc;
|
||||||
use rustc_data_structures::unord::UnordSet;
|
use rustc_data_structures::unord::UnordSet;
|
||||||
use rustc_errors::emitter::{DynEmitter, EmitterWriter};
|
use rustc_errors::emitter::{DynEmitter, HumanEmitter};
|
||||||
use rustc_errors::json::JsonEmitter;
|
use rustc_errors::json::JsonEmitter;
|
||||||
use rustc_errors::TerminalUrl;
|
use rustc_errors::TerminalUrl;
|
||||||
use rustc_feature::UnstableFeatures;
|
use rustc_feature::UnstableFeatures;
|
||||||
|
@ -138,7 +138,7 @@ pub(crate) fn new_dcx(
|
||||||
ErrorOutputType::HumanReadable(kind) => {
|
ErrorOutputType::HumanReadable(kind) => {
|
||||||
let (short, color_config) = kind.unzip();
|
let (short, color_config) = kind.unzip();
|
||||||
Box::new(
|
Box::new(
|
||||||
EmitterWriter::stderr(color_config, fallback_bundle)
|
HumanEmitter::stderr(color_config, fallback_bundle)
|
||||||
.sm(source_map.map(|sm| sm as _))
|
.sm(source_map.map(|sm| sm as _))
|
||||||
.short_message(short)
|
.short_message(short)
|
||||||
.teach(unstable_opts.teach)
|
.teach(unstable_opts.teach)
|
||||||
|
|
|
@ -557,7 +557,7 @@ pub(crate) fn make_test(
|
||||||
// crate already is included.
|
// crate already is included.
|
||||||
let result = rustc_driver::catch_fatal_errors(|| {
|
let result = rustc_driver::catch_fatal_errors(|| {
|
||||||
rustc_span::create_session_if_not_set_then(edition, |_| {
|
rustc_span::create_session_if_not_set_then(edition, |_| {
|
||||||
use rustc_errors::emitter::{Emitter, EmitterWriter};
|
use rustc_errors::emitter::{Emitter, HumanEmitter};
|
||||||
use rustc_errors::DiagCtxt;
|
use rustc_errors::DiagCtxt;
|
||||||
use rustc_parse::parser::ForceCollect;
|
use rustc_parse::parser::ForceCollect;
|
||||||
use rustc_span::source_map::FilePathMapping;
|
use rustc_span::source_map::FilePathMapping;
|
||||||
|
@ -572,11 +572,11 @@ pub(crate) fn make_test(
|
||||||
rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(),
|
rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(),
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
supports_color = EmitterWriter::stderr(ColorConfig::Auto, fallback_bundle.clone())
|
supports_color = HumanEmitter::stderr(ColorConfig::Auto, fallback_bundle.clone())
|
||||||
.diagnostic_width(Some(80))
|
.diagnostic_width(Some(80))
|
||||||
.supports_color();
|
.supports_color();
|
||||||
|
|
||||||
let emitter = EmitterWriter::new(Box::new(io::sink()), fallback_bundle);
|
let emitter = HumanEmitter::new(Box::new(io::sink()), fallback_bundle);
|
||||||
|
|
||||||
// FIXME(misdreavus): pass `-Z treat-err-as-bug` to the doctest parser
|
// FIXME(misdreavus): pass `-Z treat-err-as-bug` to the doctest parser
|
||||||
let dcx = DiagCtxt::with_emitter(Box::new(emitter)).disable_warnings();
|
let dcx = DiagCtxt::with_emitter(Box::new(emitter)).disable_warnings();
|
||||||
|
@ -739,7 +739,7 @@ fn check_if_attr_is_complete(source: &str, edition: Edition) -> bool {
|
||||||
}
|
}
|
||||||
rustc_driver::catch_fatal_errors(|| {
|
rustc_driver::catch_fatal_errors(|| {
|
||||||
rustc_span::create_session_if_not_set_then(edition, |_| {
|
rustc_span::create_session_if_not_set_then(edition, |_| {
|
||||||
use rustc_errors::emitter::EmitterWriter;
|
use rustc_errors::emitter::HumanEmitter;
|
||||||
use rustc_errors::DiagCtxt;
|
use rustc_errors::DiagCtxt;
|
||||||
use rustc_span::source_map::FilePathMapping;
|
use rustc_span::source_map::FilePathMapping;
|
||||||
|
|
||||||
|
@ -752,7 +752,7 @@ fn check_if_attr_is_complete(source: &str, edition: Edition) -> bool {
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
let emitter = EmitterWriter::new(Box::new(io::sink()), fallback_bundle);
|
let emitter = HumanEmitter::new(Box::new(io::sink()), fallback_bundle);
|
||||||
|
|
||||||
let dcx = DiagCtxt::with_emitter(Box::new(emitter)).disable_warnings();
|
let dcx = DiagCtxt::with_emitter(Box::new(emitter)).disable_warnings();
|
||||||
let sess = ParseSess::with_dcx(dcx, sm);
|
let sess = ParseSess::with_dcx(dcx, sm);
|
||||||
|
|
|
@ -5,7 +5,7 @@ use crate::doc::{NEEDLESS_DOCTEST_MAIN, TEST_ATTR_IN_DOCTEST};
|
||||||
use clippy_utils::diagnostics::span_lint;
|
use clippy_utils::diagnostics::span_lint;
|
||||||
use rustc_ast::{CoroutineKind, Fn, FnRetTy, Item, ItemKind};
|
use rustc_ast::{CoroutineKind, Fn, FnRetTy, Item, ItemKind};
|
||||||
use rustc_data_structures::sync::Lrc;
|
use rustc_data_structures::sync::Lrc;
|
||||||
use rustc_errors::emitter::EmitterWriter;
|
use rustc_errors::emitter::HumanEmitter;
|
||||||
use rustc_errors::DiagCtxt;
|
use rustc_errors::DiagCtxt;
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
use rustc_parse::maybe_new_parser_from_source_str;
|
use rustc_parse::maybe_new_parser_from_source_str;
|
||||||
|
@ -44,7 +44,7 @@ pub fn check(
|
||||||
|
|
||||||
let fallback_bundle =
|
let fallback_bundle =
|
||||||
rustc_errors::fallback_fluent_bundle(rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(), false);
|
rustc_errors::fallback_fluent_bundle(rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(), false);
|
||||||
let emitter = EmitterWriter::new(Box::new(io::sink()), fallback_bundle);
|
let emitter = HumanEmitter::new(Box::new(io::sink()), fallback_bundle);
|
||||||
let dcx = DiagCtxt::with_emitter(Box::new(emitter)).disable_warnings();
|
let dcx = DiagCtxt::with_emitter(Box::new(emitter)).disable_warnings();
|
||||||
#[expect(clippy::arc_with_non_send_sync)] // `Lrc` is expected by with_dcx
|
#[expect(clippy::arc_with_non_send_sync)] // `Lrc` is expected by with_dcx
|
||||||
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
|
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
|
||||||
|
|
|
@ -2,7 +2,7 @@ use std::path::Path;
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
|
|
||||||
use rustc_data_structures::sync::{IntoDynSyncSend, Lrc};
|
use rustc_data_structures::sync::{IntoDynSyncSend, Lrc};
|
||||||
use rustc_errors::emitter::{DynEmitter, Emitter, EmitterWriter};
|
use rustc_errors::emitter::{DynEmitter, Emitter, HumanEmitter};
|
||||||
use rustc_errors::translation::Translate;
|
use rustc_errors::translation::Translate;
|
||||||
use rustc_errors::{ColorConfig, DiagCtxt, Diagnostic, Level as DiagnosticLevel};
|
use rustc_errors::{ColorConfig, DiagCtxt, Diagnostic, Level as DiagnosticLevel};
|
||||||
use rustc_session::parse::ParseSess as RawParseSess;
|
use rustc_session::parse::ParseSess as RawParseSess;
|
||||||
|
@ -139,7 +139,7 @@ fn default_dcx(
|
||||||
rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(),
|
rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(),
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
Box::new(EmitterWriter::stderr(emit_color, fallback_bundle).sm(Some(source_map.clone())))
|
Box::new(HumanEmitter::stderr(emit_color, fallback_bundle).sm(Some(source_map.clone())))
|
||||||
};
|
};
|
||||||
DiagCtxt::with_emitter(Box::new(SilentOnIgnoredFilesEmitter {
|
DiagCtxt::with_emitter(Box::new(SilentOnIgnoredFilesEmitter {
|
||||||
has_non_ignorable_parser_errors: false,
|
has_non_ignorable_parser_errors: false,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue