mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
review comments
This commit is contained in:
parent
ae696f847d
commit
95c1c34fff
@ -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.
|
||||
|
@ -176,7 +176,7 @@ impl Emitter for JsonEmitter {
|
||||
}
|
||||
|
||||
fn should_show_explain(&self) -> bool {
|
||||
!matches!(self.json_rendered, HumanReadableErrorType::Short)
|
||||
!self.json_rendered.short()
|
||||
}
|
||||
}
|
||||
|
||||
@ -356,7 +356,7 @@ impl Diagnostic {
|
||||
|
||||
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 => {}
|
||||
|
@ -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),
|
||||
|
@ -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 _))
|
||||
|
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user