Skip to content

Commit 1a0c155

Browse files
committed
review comments
1 parent ae696f8 commit 1a0c155

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

compiler/rustc_errors/src/emitter.rs

+6
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ pub enum HumanReadableErrorType {
4848
Short,
4949
}
5050

51+
impl HumanReadableErrorType {
52+
fn short(&self) -> bool {
53+
self == HumanReadableErrorType::Short
54+
}
55+
}
56+
5157
#[derive(Clone, Copy, Debug)]
5258
struct Margin {
5359
/// The available whitespace in the left that can be consumed when centering.

compiler/rustc_session/src/session.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ fn default_emitter(
951951
};
952952
match sopts.error_format {
953953
config::ErrorOutputType::HumanReadable(kind, color_config) => {
954-
let short = matches!(kind, HumanReadableErrorType::Short);
954+
let short = kind.short();
955955

956956
if let HumanReadableErrorType::AnnotateSnippet = kind {
957957
let emitter = AnnotateSnippetEmitter::new(
@@ -1427,7 +1427,7 @@ fn mk_emitter(output: ErrorOutputType) -> Box<DynEmitter> {
14271427
fallback_fluent_bundle(vec![rustc_errors::DEFAULT_LOCALE_RESOURCE], false);
14281428
let emitter: Box<DynEmitter> = match output {
14291429
config::ErrorOutputType::HumanReadable(kind, color_config) => {
1430-
let short = matches!(kind, HumanReadableErrorType::Short);
1430+
let short = kind.short();
14311431
Box::new(
14321432
HumanEmitter::new(stderr_destination(color_config), fallback_bundle)
14331433
.short_message(short),

src/librustdoc/core.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ pub(crate) fn new_dcx(
139139
);
140140
let emitter: Box<DynEmitter> = match error_format {
141141
ErrorOutputType::HumanReadable(kind, color_config) => {
142-
let short = matches!(kind, HumanReadableErrorType::Short);
142+
let short = kind.short();
143143
Box::new(
144144
HumanEmitter::new(stderr_destination(color_config), fallback_bundle)
145145
.sm(source_map.map(|sm| sm as _))

src/librustdoc/doctest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ fn run_test(
423423
}
424424
});
425425
if let ErrorOutputType::HumanReadable(kind, color_config) = rustdoc_options.error_format {
426-
let short = matches!(kind, HumanReadableErrorType::Short);
426+
let short = kind.short();
427427

428428
if short {
429429
compiler.arg("--error-format").arg("short");

0 commit comments

Comments
 (0)