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`
This commit is contained in:
parent
47f4975cd7
commit
df076b2d5e
5 changed files with 18 additions and 18 deletions
|
@ -2003,7 +2003,7 @@ pub fn build_session_options_and_crate_config(
|
||||||
None |
|
None |
|
||||||
Some("human") => ErrorOutputType::HumanReadable(HumanReadableErrorType::Default(color)),
|
Some("human") => ErrorOutputType::HumanReadable(HumanReadableErrorType::Default(color)),
|
||||||
Some("human-annotate-rs") => {
|
Some("human-annotate-rs") => {
|
||||||
ErrorOutputType::HumanReadable(HumanReadableErrorType::AnnotateRs(color))
|
ErrorOutputType::HumanReadable(HumanReadableErrorType::AnnotateSnippet(color))
|
||||||
},
|
},
|
||||||
Some("json") => ErrorOutputType::Json { pretty: false, json_rendered },
|
Some("json") => ErrorOutputType::Json { pretty: false, json_rendered },
|
||||||
Some("pretty-json") => ErrorOutputType::Json { pretty: true, json_rendered },
|
Some("pretty-json") => ErrorOutputType::Json { pretty: true, json_rendered },
|
||||||
|
@ -2041,7 +2041,7 @@ pub fn build_session_options_and_crate_config(
|
||||||
"--error-format=pretty-json is unstable",
|
"--error-format=pretty-json is unstable",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if let ErrorOutputType::HumanReadable(HumanReadableErrorType::AnnotateRs(_)) =
|
if let ErrorOutputType::HumanReadable(HumanReadableErrorType::AnnotateSnippet(_)) =
|
||||||
error_format {
|
error_format {
|
||||||
early_error(
|
early_error(
|
||||||
ErrorOutputType::Json { pretty: false, json_rendered },
|
ErrorOutputType::Json { pretty: false, json_rendered },
|
||||||
|
|
|
@ -24,7 +24,7 @@ use rustc_data_structures::sync::{
|
||||||
use errors::{DiagnosticBuilder, DiagnosticId, Applicability};
|
use errors::{DiagnosticBuilder, DiagnosticId, Applicability};
|
||||||
use errors::emitter::{Emitter, EmitterWriter};
|
use errors::emitter::{Emitter, EmitterWriter};
|
||||||
use errors::emitter::HumanReadableErrorType;
|
use errors::emitter::HumanReadableErrorType;
|
||||||
use errors::annotate_rs_emitter::{AnnotateRsEmitterWriter};
|
use errors::annotate_snippet_emitter_writer::{AnnotateSnippetEmitterWriter};
|
||||||
use syntax::ast::{self, NodeId};
|
use syntax::ast::{self, NodeId};
|
||||||
use syntax::edition::Edition;
|
use syntax::edition::Edition;
|
||||||
use syntax::feature_gate::{self, AttributeType};
|
use syntax::feature_gate::{self, AttributeType};
|
||||||
|
@ -1034,8 +1034,8 @@ fn default_emitter(
|
||||||
(config::ErrorOutputType::HumanReadable(kind), dst) => {
|
(config::ErrorOutputType::HumanReadable(kind), dst) => {
|
||||||
let (short, color_config) = kind.unzip();
|
let (short, color_config) = kind.unzip();
|
||||||
|
|
||||||
if let HumanReadableErrorType::AnnotateRs(_) = kind {
|
if let HumanReadableErrorType::AnnotateSnippet(_) = kind {
|
||||||
let emitter = AnnotateRsEmitterWriter::new(
|
let emitter = AnnotateSnippetEmitterWriter::new(
|
||||||
Some(source_map.clone()),
|
Some(source_map.clone()),
|
||||||
short,
|
short,
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
/// Emit diagnostics using the `annotate-snippets` library
|
//! Emit diagnostics using the `annotate-snippets` library
|
||||||
///
|
//!
|
||||||
/// This is the equivalent of `./emitter.rs` but making use of the
|
//! This is the equivalent of `./emitter.rs` but making use of the
|
||||||
/// [`annotate-snippets`][annotate_snippets] library instead of building the output ourselves.
|
//! [`annotate-snippets`][annotate_snippets] library instead of building the output ourselves.
|
||||||
///
|
//!
|
||||||
/// [annotate_snippets]: https://docs.rs/crate/annotate-snippets/
|
//! [annotate_snippets]: https://docs.rs/crate/annotate-snippets/
|
||||||
|
|
||||||
use syntax_pos::{SourceFile, MultiSpan, Loc};
|
use syntax_pos::{SourceFile, MultiSpan, Loc};
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -18,8 +18,8 @@ use annotate_snippets::display_list::DisplayList;
|
||||||
use annotate_snippets::formatter::DisplayListFormatter;
|
use annotate_snippets::formatter::DisplayListFormatter;
|
||||||
|
|
||||||
|
|
||||||
/// Generates diagnostics using annotate-rs
|
/// Generates diagnostics using annotate-snippet
|
||||||
pub struct AnnotateRsEmitterWriter {
|
pub struct AnnotateSnippetEmitterWriter {
|
||||||
source_map: Option<Lrc<SourceMapperDyn>>,
|
source_map: Option<Lrc<SourceMapperDyn>>,
|
||||||
/// If true, hides the longer explanation text
|
/// If true, hides the longer explanation text
|
||||||
short_message: bool,
|
short_message: bool,
|
||||||
|
@ -27,7 +27,7 @@ pub struct AnnotateRsEmitterWriter {
|
||||||
ui_testing: bool,
|
ui_testing: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Emitter for AnnotateRsEmitterWriter {
|
impl Emitter for AnnotateSnippetEmitterWriter {
|
||||||
/// The entry point for the diagnostics generation
|
/// The entry point for the diagnostics generation
|
||||||
fn emit_diagnostic(&mut self, db: &DiagnosticBuilder<'_>) {
|
fn emit_diagnostic(&mut self, db: &DiagnosticBuilder<'_>) {
|
||||||
let primary_span = db.span.clone();
|
let primary_span = db.span.clone();
|
||||||
|
@ -158,7 +158,7 @@ impl<'a> DiagnosticConverter<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AnnotateRsEmitterWriter {
|
impl AnnotateSnippetEmitterWriter {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
source_map: Option<Lrc<SourceMapperDyn>>,
|
source_map: Option<Lrc<SourceMapperDyn>>,
|
||||||
short_message: bool
|
short_message: bool
|
|
@ -24,7 +24,7 @@ use termcolor::{WriteColor, Color, Buffer};
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||||
pub enum HumanReadableErrorType {
|
pub enum HumanReadableErrorType {
|
||||||
Default(ColorConfig),
|
Default(ColorConfig),
|
||||||
AnnotateRs(ColorConfig),
|
AnnotateSnippet(ColorConfig),
|
||||||
Short(ColorConfig),
|
Short(ColorConfig),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ impl HumanReadableErrorType {
|
||||||
match self {
|
match self {
|
||||||
HumanReadableErrorType::Default(cc) => (false, cc),
|
HumanReadableErrorType::Default(cc) => (false, cc),
|
||||||
HumanReadableErrorType::Short(cc) => (true, cc),
|
HumanReadableErrorType::Short(cc) => (true, cc),
|
||||||
HumanReadableErrorType::AnnotateRs(cc) => (false, cc),
|
HumanReadableErrorType::AnnotateSnippet(cc) => (false, cc),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn new_emitter(
|
pub fn new_emitter(
|
||||||
|
|
|
@ -33,7 +33,7 @@ use termcolor::{ColorSpec, Color};
|
||||||
mod diagnostic;
|
mod diagnostic;
|
||||||
mod diagnostic_builder;
|
mod diagnostic_builder;
|
||||||
pub mod emitter;
|
pub mod emitter;
|
||||||
pub mod annotate_rs_emitter;
|
pub mod annotate_snippet_emitter_writer;
|
||||||
mod snippet;
|
mod snippet;
|
||||||
pub mod registry;
|
pub mod registry;
|
||||||
mod styled_buffer;
|
mod styled_buffer;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue