From 2fe834f3acf3acc8a0225ec80ed8619a6cbc8e85 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Fri, 30 Oct 2020 20:27:39 +0000 Subject: Update annotate-snippets dependency --- Cargo.lock | 7 +++++-- dhall/Cargo.toml | 2 +- dhall/src/error/builder.rs | 25 +++++++++++++------------ 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a15b061..5e438f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -30,9 +30,12 @@ dependencies = [ [[package]] name = "annotate-snippets" -version = "0.7.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aba2d96b8c8b5e656ad7ffb0d09f57772f10a1db74c8d23fca0ec695b38a4047" +checksum = "5c96c3d1062ea7101741480185a6a1275eab01cbe8b20e378d1311bc056d2e08" +dependencies = [ + "unicode-width", +] [[package]] name = "ansi_term" diff --git a/dhall/Cargo.toml b/dhall/Cargo.toml index c8d0fc4..7923009 100644 --- a/dhall/Cargo.toml +++ b/dhall/Cargo.toml @@ -20,7 +20,7 @@ harness = false path = "tests/spec.rs" [dependencies] -annotate-snippets = "0.7.0" +annotate-snippets = "0.9.0" hex = "0.4.2" itertools = "0.9.0" lazy_static = "1.4.0" diff --git a/dhall/src/error/builder.rs b/dhall/src/error/builder.rs index 3ee65fb..b659230 100644 --- a/dhall/src/error/builder.rs +++ b/dhall/src/error/builder.rs @@ -29,9 +29,9 @@ struct FreeAnnotation { } impl SpannedAnnotation { - fn into_annotation(self) -> SourceAnnotation { + fn to_annotation(&self) -> SourceAnnotation<'_> { SourceAnnotation { - label: self.message, + label: &self.message, annotation_type: self.annotation_type, range: self.span.as_char_range(), } @@ -39,9 +39,9 @@ impl SpannedAnnotation { } impl FreeAnnotation { - fn into_annotation(self) -> Annotation { + fn to_annotation(&self) -> Annotation<'_> { Annotation { - label: Some(self.message), + label: Some(&self.message), id: None, annotation_type: self.annotation_type, } @@ -124,31 +124,32 @@ impl ErrorBuilder { self.consumed = true; drop(self); // Get rid of the self reference so we don't use it by mistake. + let input; let slices = if this.annotations.is_empty() { Vec::new() } else { - let input = this.annotations[0].span.to_input(); + input = this.annotations[0].span.to_input(); let annotations = this .annotations - .into_iter() - .map(|annot| annot.into_annotation()) + .iter() + .map(|annot| annot.to_annotation()) .collect(); vec![Slice { - source: input, + source: &input, line_start: 1, // TODO - origin: Some("".to_string()), + origin: Some(""), fold: true, annotations, }] }; let footer = this .footer - .into_iter() - .map(|annot| annot.into_annotation()) + .iter() + .map(|annot| annot.to_annotation()) .collect(); let snippet = Snippet { - title: Some(this.title.into_annotation()), + title: Some(this.title.to_annotation()), slices, footer, opt: Default::default(), -- cgit v1.2.3