Skip to content

Commit 13b9448

Browse files
committed
annotate-snippets: update to 0.10
1 parent ddca534 commit 13b9448

File tree

5 files changed

+24
-23
lines changed

5 files changed

+24
-23
lines changed

Cargo.lock

+16-6
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,16 @@ dependencies = [
119119
"yansi-term",
120120
]
121121

122+
[[package]]
123+
name = "annotate-snippets"
124+
version = "0.10.0"
125+
source = "registry+https://github.com/rust-lang/crates.io-index"
126+
checksum = "140de53162eac850c5a6711763157ee2ceffbeb0514f6c83511728052e880b17"
127+
dependencies = [
128+
"anstyle",
129+
"unicode-width",
130+
]
131+
122132
[[package]]
123133
name = "ansi_term"
124134
version = "0.12.1"
@@ -3770,7 +3780,7 @@ dependencies = [
37703780
name = "rustc_errors"
37713781
version = "0.0.0"
37723782
dependencies = [
3773-
"annotate-snippets",
3783+
"annotate-snippets 0.10.0",
37743784
"derive_setters",
37753785
"rustc_ast",
37763786
"rustc_ast_pretty",
@@ -3831,7 +3841,7 @@ dependencies = [
38313841
name = "rustc_fluent_macro"
38323842
version = "0.0.0"
38333843
dependencies = [
3834-
"annotate-snippets",
3844+
"annotate-snippets 0.10.0",
38353845
"fluent-bundle",
38363846
"fluent-syntax",
38373847
"proc-macro2",
@@ -4736,7 +4746,7 @@ dependencies = [
47364746
name = "rustfmt-nightly"
47374747
version = "1.7.0"
47384748
dependencies = [
4739-
"annotate-snippets",
4749+
"annotate-snippets 0.9.1",
47404750
"anyhow",
47414751
"bytecount",
47424752
"cargo_metadata 0.15.4",
@@ -5726,7 +5736,7 @@ version = "0.21.2"
57265736
source = "registry+https://github.com/rust-lang/crates.io-index"
57275737
checksum = "aaf4bf7c184b8dfc7a4d3b90df789b1eb992ee42811cd115f32a7a1eb781058d"
57285738
dependencies = [
5729-
"annotate-snippets",
5739+
"annotate-snippets 0.9.1",
57305740
"anyhow",
57315741
"bstr",
57325742
"cargo-platform",
@@ -5857,9 +5867,9 @@ checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36"
58575867

58585868
[[package]]
58595869
name = "unicode-width"
5860-
version = "0.1.10"
5870+
version = "0.1.11"
58615871
source = "registry+https://github.com/rust-lang/crates.io-index"
5862-
checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
5872+
checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
58635873
dependencies = [
58645874
"compiler_builtins",
58655875
"rustc-std-workspace-core",

compiler/rustc_errors/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ edition = "2021"
55

66
[dependencies]
77
# tidy-alphabetical-start
8-
annotate-snippets = "0.9"
8+
annotate-snippets = "0.10"
99
derive_setters = "0.1.6"
1010
rustc_ast = { path = "../rustc_ast" }
1111
rustc_ast_pretty = { path = "../rustc_ast_pretty" }

compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ use crate::{
1212
CodeSuggestion, Diagnostic, DiagnosticId, DiagnosticMessage, Emitter, FluentBundle,
1313
LazyFallbackBundle, Level, MultiSpan, Style, SubDiagnostic,
1414
};
15-
use annotate_snippets::display_list::{DisplayList, FormatOptions};
16-
use annotate_snippets::snippet::*;
15+
use annotate_snippets::{Annotation, AnnotationType, Renderer, Slice, Snippet, SourceAnnotation};
1716
use rustc_data_structures::sync::Lrc;
1817
use rustc_error_messages::FluentArgs;
1918
use rustc_span::source_map::SourceMap;
@@ -192,11 +191,6 @@ impl AnnotateSnippetEmitterWriter {
192191
annotation_type: annotation_type_for_level(*level),
193192
}),
194193
footer: vec![],
195-
opt: FormatOptions {
196-
color: true,
197-
anonymized_line_numbers: self.ui_testing,
198-
margin: None,
199-
},
200194
slices: annotated_files
201195
.iter()
202196
.map(|(file_name, source, line_index, annotations)| {
@@ -224,7 +218,8 @@ impl AnnotateSnippetEmitterWriter {
224218
// FIXME(#59346): Figure out if we can _always_ print to stderr or not.
225219
// `emitter.rs` has the `Destination` enum that lists various possible output
226220
// destinations.
227-
eprintln!("{}", DisplayList::from(snippet))
221+
let renderer = Renderer::plain().anonymized_line_numbers(self.ui_testing);
222+
eprintln!("{}", renderer.render(snippet))
228223
}
229224
// FIXME(#59346): Is it ok to return None if there's no source_map?
230225
}

compiler/rustc_fluent_macro/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ proc-macro = true
88

99
[dependencies]
1010
# tidy-alphabetical-start
11-
annotate-snippets = "0.9"
11+
annotate-snippets = "0.10"
1212
fluent-bundle = "0.15.2"
1313
fluent-syntax = "0.11"
1414
proc-macro2 = "1"

compiler/rustc_fluent_macro/src/fluent.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
use annotate_snippets::{
2-
display_list::DisplayList,
3-
snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation},
4-
};
1+
use annotate_snippets::{Annotation, AnnotationType, Renderer, Slice, Snippet, SourceAnnotation};
52
use fluent_bundle::{FluentBundle, FluentError, FluentResource};
63
use fluent_syntax::{
74
ast::{
@@ -179,10 +176,9 @@ pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::Tok
179176
range: (pos.start, pos.end - 1),
180177
}],
181178
}],
182-
opt: Default::default(),
183179
};
184-
let dl = DisplayList::from(snippet);
185-
eprintln!("{dl}\n");
180+
let renderer = Renderer::plain();
181+
eprintln!("{}\n", renderer.render(snippet));
186182
}
187183

188184
return failed(&crate_name);

0 commit comments

Comments
 (0)