review comments

This commit is contained in:
Esteban Küber 2024-08-08 14:43:27 +00:00
parent ae696f847d
commit 95c1c34fff
5 changed files with 12 additions and 6 deletions

View File

@ -48,6 +48,12 @@ pub enum HumanReadableErrorType {
Short,
}
impl HumanReadableErrorType {
pub fn short(&self) -> bool {
*self == HumanReadableErrorType::Short
}
}
#[derive(Clone, Copy, Debug)]
struct Margin {
/// The available whitespace in the left that can be consumed when centering.

View File

@ -176,7 +176,7 @@ fn source_map(&self) -> Option<&Lrc<SourceMap>> {
}
fn should_show_explain(&self) -> bool {
!matches!(self.json_rendered, HumanReadableErrorType::Short)
!self.json_rendered.short()
}
}
@ -356,7 +356,7 @@ fn reset(&mut self) -> io::Result<()> {
let buf = BufWriter::default();
let mut dst: Destination = Box::new(buf.clone());
let short = matches!(je.json_rendered, HumanReadableErrorType::Short);
let short = je.json_rendered.short();
match je.color_config {
ColorConfig::Always | ColorConfig::Auto => dst = Box::new(termcolor::Ansi::new(dst)),
ColorConfig::Never => {}

View File

@ -951,7 +951,7 @@ fn default_emitter(
};
match sopts.error_format {
config::ErrorOutputType::HumanReadable(kind, color_config) => {
let short = matches!(kind, HumanReadableErrorType::Short);
let short = kind.short();
if let HumanReadableErrorType::AnnotateSnippet = kind {
let emitter = AnnotateSnippetEmitter::new(
@ -1427,7 +1427,7 @@ fn mk_emitter(output: ErrorOutputType) -> Box<DynEmitter> {
fallback_fluent_bundle(vec![rustc_errors::DEFAULT_LOCALE_RESOURCE], false);
let emitter: Box<DynEmitter> = match output {
config::ErrorOutputType::HumanReadable(kind, color_config) => {
let short = matches!(kind, HumanReadableErrorType::Short);
let short = kind.short();
Box::new(
HumanEmitter::new(stderr_destination(color_config), fallback_bundle)
.short_message(short),

View File

@ -139,7 +139,7 @@ pub(crate) fn new_dcx(
);
let emitter: Box<DynEmitter> = match error_format {
ErrorOutputType::HumanReadable(kind, color_config) => {
let short = matches!(kind, HumanReadableErrorType::Short);
let short = kind.short();
Box::new(
HumanEmitter::new(stderr_destination(color_config), fallback_bundle)
.sm(source_map.map(|sm| sm as _))

View File

@ -423,7 +423,7 @@ fn run_test(
}
});
if let ErrorOutputType::HumanReadable(kind, color_config) = rustdoc_options.error_format {
let short = matches!(kind, HumanReadableErrorType::Short);
let short = kind.short();
if short {
compiler.arg("--error-format").arg("short");