diff options
author | Nadrieril | 2020-10-30 21:19:00 +0000 |
---|---|---|
committer | GitHub | 2020-10-30 21:19:00 +0000 |
commit | 25289551885f49bc676c2f71d0ef3a619d3e0b8a (patch) | |
tree | ecd5f44554804bb809d0604aeb4b0ef15dec8425 /dhall/src/error | |
parent | b5094f23d22a0dd1a6a11c62ce1ed2dd57870789 (diff) | |
parent | 00105872144c41a958e17436b08cafab575922c8 (diff) |
Merge pull request #190 from Nadrieril/update-deps
Diffstat (limited to '')
-rw-r--r-- | dhall/src/error/builder.rs | 25 |
1 files changed, 13 insertions, 12 deletions
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("<current file>".to_string()), + origin: Some("<current file>"), 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(), |