Skip to content

Commit df076b2

Browse files
committed
librustc_errors: Rename AnnotateRs -> AnnotateSnippet
The proper name of the library is `annotate-snippet`, not `annotate-rs`, this commit should get rid of any confusing `AnnotateRs` names. 1. Renames `annotate_rs_emitter.rs` to `annotate_snippet_emitter_writer.rs` so that the difference between the `Emitter` trait and the implementers is more clear. 2. Renames `AnnotateRsEmitterWriter` to `AnnotateSnippetEmitterWriter` 3. Renames `HumanReadableErrorType::AnnotateRs` to `HumanReadableErrorType::AnnotateSnippet`
1 parent 47f4975 commit df076b2

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

src/librustc/session/config.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2003,7 +2003,7 @@ pub fn build_session_options_and_crate_config(
20032003
None |
20042004
Some("human") => ErrorOutputType::HumanReadable(HumanReadableErrorType::Default(color)),
20052005
Some("human-annotate-rs") => {
2006-
ErrorOutputType::HumanReadable(HumanReadableErrorType::AnnotateRs(color))
2006+
ErrorOutputType::HumanReadable(HumanReadableErrorType::AnnotateSnippet(color))
20072007
},
20082008
Some("json") => ErrorOutputType::Json { pretty: false, json_rendered },
20092009
Some("pretty-json") => ErrorOutputType::Json { pretty: true, json_rendered },
@@ -2041,7 +2041,7 @@ pub fn build_session_options_and_crate_config(
20412041
"--error-format=pretty-json is unstable",
20422042
);
20432043
}
2044-
if let ErrorOutputType::HumanReadable(HumanReadableErrorType::AnnotateRs(_)) =
2044+
if let ErrorOutputType::HumanReadable(HumanReadableErrorType::AnnotateSnippet(_)) =
20452045
error_format {
20462046
early_error(
20472047
ErrorOutputType::Json { pretty: false, json_rendered },

src/librustc/session/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use rustc_data_structures::sync::{
2424
use errors::{DiagnosticBuilder, DiagnosticId, Applicability};
2525
use errors::emitter::{Emitter, EmitterWriter};
2626
use errors::emitter::HumanReadableErrorType;
27-
use errors::annotate_rs_emitter::{AnnotateRsEmitterWriter};
27+
use errors::annotate_snippet_emitter_writer::{AnnotateSnippetEmitterWriter};
2828
use syntax::ast::{self, NodeId};
2929
use syntax::edition::Edition;
3030
use syntax::feature_gate::{self, AttributeType};
@@ -1034,8 +1034,8 @@ fn default_emitter(
10341034
(config::ErrorOutputType::HumanReadable(kind), dst) => {
10351035
let (short, color_config) = kind.unzip();
10361036

1037-
if let HumanReadableErrorType::AnnotateRs(_) = kind {
1038-
let emitter = AnnotateRsEmitterWriter::new(
1037+
if let HumanReadableErrorType::AnnotateSnippet(_) = kind {
1038+
let emitter = AnnotateSnippetEmitterWriter::new(
10391039
Some(source_map.clone()),
10401040
short,
10411041
);

src/librustc_errors/annotate_rs_emitter.rs renamed to src/librustc_errors/annotate_snippet_emitter_writer.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
/// Emit diagnostics using the `annotate-snippets` library
2-
///
3-
/// This is the equivalent of `./emitter.rs` but making use of the
4-
/// [`annotate-snippets`][annotate_snippets] library instead of building the output ourselves.
5-
///
6-
/// [annotate_snippets]: https://docs.rs/crate/annotate-snippets/
1+
//! Emit diagnostics using the `annotate-snippets` library
2+
//!
3+
//! This is the equivalent of `./emitter.rs` but making use of the
4+
//! [`annotate-snippets`][annotate_snippets] library instead of building the output ourselves.
5+
//!
6+
//! [annotate_snippets]: https://docs.rs/crate/annotate-snippets/
77
88
use syntax_pos::{SourceFile, MultiSpan, Loc};
99
use crate::{
@@ -18,16 +18,16 @@ use annotate_snippets::display_list::DisplayList;
1818
use annotate_snippets::formatter::DisplayListFormatter;
1919

2020

21-
/// Generates diagnostics using annotate-rs
22-
pub struct AnnotateRsEmitterWriter {
21+
/// Generates diagnostics using annotate-snippet
22+
pub struct AnnotateSnippetEmitterWriter {
2323
source_map: Option<Lrc<SourceMapperDyn>>,
2424
/// If true, hides the longer explanation text
2525
short_message: bool,
2626
/// If true, will normalize line numbers with LL to prevent noise in UI test diffs.
2727
ui_testing: bool,
2828
}
2929

30-
impl Emitter for AnnotateRsEmitterWriter {
30+
impl Emitter for AnnotateSnippetEmitterWriter {
3131
/// The entry point for the diagnostics generation
3232
fn emit_diagnostic(&mut self, db: &DiagnosticBuilder<'_>) {
3333
let primary_span = db.span.clone();
@@ -158,7 +158,7 @@ impl<'a> DiagnosticConverter<'a> {
158158
}
159159
}
160160

161-
impl AnnotateRsEmitterWriter {
161+
impl AnnotateSnippetEmitterWriter {
162162
pub fn new(
163163
source_map: Option<Lrc<SourceMapperDyn>>,
164164
short_message: bool

src/librustc_errors/emitter.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use termcolor::{WriteColor, Color, Buffer};
2424
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
2525
pub enum HumanReadableErrorType {
2626
Default(ColorConfig),
27-
AnnotateRs(ColorConfig),
27+
AnnotateSnippet(ColorConfig),
2828
Short(ColorConfig),
2929
}
3030

@@ -34,7 +34,7 @@ impl HumanReadableErrorType {
3434
match self {
3535
HumanReadableErrorType::Default(cc) => (false, cc),
3636
HumanReadableErrorType::Short(cc) => (true, cc),
37-
HumanReadableErrorType::AnnotateRs(cc) => (false, cc),
37+
HumanReadableErrorType::AnnotateSnippet(cc) => (false, cc),
3838
}
3939
}
4040
pub fn new_emitter(

src/librustc_errors/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use termcolor::{ColorSpec, Color};
3333
mod diagnostic;
3434
mod diagnostic_builder;
3535
pub mod emitter;
36-
pub mod annotate_rs_emitter;
36+
pub mod annotate_snippet_emitter_writer;
3737
mod snippet;
3838
pub mod registry;
3939
mod styled_buffer;

0 commit comments

Comments
 (0)