diff options
Diffstat (limited to 'compiler/rustc_fluent_macro')
| -rw-r--r-- | compiler/rustc_fluent_macro/Cargo.toml | 2 | ||||
| -rw-r--r-- | compiler/rustc_fluent_macro/src/fluent.rs | 30 |
2 files changed, 10 insertions, 22 deletions
diff --git a/compiler/rustc_fluent_macro/Cargo.toml b/compiler/rustc_fluent_macro/Cargo.toml index c5a53ae8313..eeceaa4691a 100644 --- a/compiler/rustc_fluent_macro/Cargo.toml +++ b/compiler/rustc_fluent_macro/Cargo.toml @@ -8,7 +8,7 @@ proc-macro = true [dependencies] # tidy-alphabetical-start -annotate-snippets = "0.10" +annotate-snippets = "0.11" fluent-bundle = "0.15.2" fluent-syntax = "0.11" proc-macro2 = "1" diff --git a/compiler/rustc_fluent_macro/src/fluent.rs b/compiler/rustc_fluent_macro/src/fluent.rs index 23795a96b92..ca8bace28f3 100644 --- a/compiler/rustc_fluent_macro/src/fluent.rs +++ b/compiler/rustc_fluent_macro/src/fluent.rs @@ -2,7 +2,7 @@ use std::collections::{HashMap, HashSet}; use std::fs::read_to_string; use std::path::{Path, PathBuf}; -use annotate_snippets::{Annotation, AnnotationType, Renderer, Slice, Snippet, SourceAnnotation}; +use annotate_snippets::{Renderer, Snippet}; use fluent_bundle::{FluentBundle, FluentError, FluentResource}; use fluent_syntax::ast::{ Attribute, Entry, Expression, Identifier, InlineExpression, Message, Pattern, PatternElement, @@ -154,27 +154,15 @@ pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::Tok .unwrap() .0; - let snippet = Snippet { - title: Some(Annotation { - label: Some(&err), - id: None, - annotation_type: AnnotationType::Error, - }), - footer: vec![], - slices: vec![Slice { - source: this.source(), - line_start, - origin: Some(&relative_ftl_path), - fold: true, - annotations: vec![SourceAnnotation { - label: "", - annotation_type: AnnotationType::Error, - range: (pos.start, pos.end - 1), - }], - }], - }; + let message = annotate_snippets::Level::Error.title(&err).snippet( + Snippet::source(this.source()) + .line_start(line_start) + .origin(&relative_ftl_path) + .fold(true) + .annotation(annotate_snippets::Level::Error.span(pos.start..pos.end - 1)), + ); let renderer = Renderer::plain(); - eprintln!("{}\n", renderer.render(snippet)); + eprintln!("{}\n", renderer.render(message)); } return failed(&crate_name); |
