Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Aug 8, 2024
1 parent ae696f8 commit 1a0c155
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions compiler/rustc_errors/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ pub enum HumanReadableErrorType {
Short,
}

impl HumanReadableErrorType {
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.
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_session/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 _))
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/doctest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 1a0c155

Please sign in to comment.