Skip to content

Commit

Permalink
annotate-snippets: update to 0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
klensy committed Dec 30, 2023
1 parent ddca534 commit 13b9448
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 23 deletions.
22 changes: 16 additions & 6 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,16 @@ dependencies = [
"yansi-term",
]

[[package]]
name = "annotate-snippets"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "140de53162eac850c5a6711763157ee2ceffbeb0514f6c83511728052e880b17"
dependencies = [
"anstyle",
"unicode-width",
]

[[package]]
name = "ansi_term"
version = "0.12.1"
Expand Down Expand Up @@ -3770,7 +3780,7 @@ dependencies = [
name = "rustc_errors"
version = "0.0.0"
dependencies = [
"annotate-snippets",
"annotate-snippets 0.10.0",
"derive_setters",
"rustc_ast",
"rustc_ast_pretty",
Expand Down Expand Up @@ -3831,7 +3841,7 @@ dependencies = [
name = "rustc_fluent_macro"
version = "0.0.0"
dependencies = [
"annotate-snippets",
"annotate-snippets 0.10.0",
"fluent-bundle",
"fluent-syntax",
"proc-macro2",
Expand Down Expand Up @@ -4736,7 +4746,7 @@ dependencies = [
name = "rustfmt-nightly"
version = "1.7.0"
dependencies = [
"annotate-snippets",
"annotate-snippets 0.9.1",
"anyhow",
"bytecount",
"cargo_metadata 0.15.4",
Expand Down Expand Up @@ -5726,7 +5736,7 @@ version = "0.21.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aaf4bf7c184b8dfc7a4d3b90df789b1eb992ee42811cd115f32a7a1eb781058d"
dependencies = [
"annotate-snippets",
"annotate-snippets 0.9.1",
"anyhow",
"bstr",
"cargo-platform",
Expand Down Expand Up @@ -5857,9 +5867,9 @@ checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36"

[[package]]
name = "unicode-width"
version = "0.1.10"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
dependencies = [
"compiler_builtins",
"rustc-std-workspace-core",
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_errors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"

[dependencies]
# tidy-alphabetical-start
annotate-snippets = "0.9"
annotate-snippets = "0.10"
derive_setters = "0.1.6"
rustc_ast = { path = "../rustc_ast" }
rustc_ast_pretty = { path = "../rustc_ast_pretty" }
Expand Down
11 changes: 3 additions & 8 deletions compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ use crate::{
CodeSuggestion, Diagnostic, DiagnosticId, DiagnosticMessage, Emitter, FluentBundle,
LazyFallbackBundle, Level, MultiSpan, Style, SubDiagnostic,
};
use annotate_snippets::display_list::{DisplayList, FormatOptions};
use annotate_snippets::snippet::*;
use annotate_snippets::{Annotation, AnnotationType, Renderer, Slice, Snippet, SourceAnnotation};
use rustc_data_structures::sync::Lrc;
use rustc_error_messages::FluentArgs;
use rustc_span::source_map::SourceMap;
Expand Down Expand Up @@ -192,11 +191,6 @@ impl AnnotateSnippetEmitterWriter {
annotation_type: annotation_type_for_level(*level),
}),
footer: vec![],
opt: FormatOptions {
color: true,
anonymized_line_numbers: self.ui_testing,
margin: None,
},
slices: annotated_files
.iter()
.map(|(file_name, source, line_index, annotations)| {
Expand Down Expand Up @@ -224,7 +218,8 @@ impl AnnotateSnippetEmitterWriter {
// FIXME(#59346): Figure out if we can _always_ print to stderr or not.
// `emitter.rs` has the `Destination` enum that lists various possible output
// destinations.
eprintln!("{}", DisplayList::from(snippet))
let renderer = Renderer::plain().anonymized_line_numbers(self.ui_testing);
eprintln!("{}", renderer.render(snippet))
}
// FIXME(#59346): Is it ok to return None if there's no source_map?
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_fluent_macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ proc-macro = true

[dependencies]
# tidy-alphabetical-start
annotate-snippets = "0.9"
annotate-snippets = "0.10"
fluent-bundle = "0.15.2"
fluent-syntax = "0.11"
proc-macro2 = "1"
Expand Down
10 changes: 3 additions & 7 deletions compiler/rustc_fluent_macro/src/fluent.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use annotate_snippets::{
display_list::DisplayList,
snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation},
};
use annotate_snippets::{Annotation, AnnotationType, Renderer, Slice, Snippet, SourceAnnotation};
use fluent_bundle::{FluentBundle, FluentError, FluentResource};
use fluent_syntax::{
ast::{
Expand Down Expand Up @@ -179,10 +176,9 @@ pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::Tok
range: (pos.start, pos.end - 1),
}],
}],
opt: Default::default(),
};
let dl = DisplayList::from(snippet);
eprintln!("{dl}\n");
let renderer = Renderer::plain();
eprintln!("{}\n", renderer.render(snippet));
}

return failed(&crate_name);
Expand Down

0 comments on commit 13b9448

Please sign in to comment.