Skip to content

bump annotate-snippets to 0.10 #6018

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 7 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ rustfmt-format-diff = []
generic-simd = ["bytecount/generic-simd"]

[dependencies]
annotate-snippets = { version = "0.9", features = ["color"] }
annotate-snippets = { version = "0.10" }
anyhow = "1.0"
bytecount = "0.6.4"
cargo_metadata = "0.15.4"
Expand Down
16 changes: 7 additions & 9 deletions src/format_report_formatter.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::formatting::FormattingError;
use crate::{ErrorKind, FormatReport};
use annotate_snippets::display_list::{DisplayList, FormatOptions};
use annotate_snippets::snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation};
use annotate_snippets::{Annotation, AnnotationType, Renderer, Slice, Snippet, SourceAnnotation};
use std::fmt::{self, Display};

/// A builder for [`FormatReportFormatter`].
Expand Down Expand Up @@ -49,9 +48,10 @@ impl<'a> Display for FormatReportFormatter<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let errors_by_file = &self.report.internal.borrow().0;

let opt = FormatOptions {
color: self.enable_colors,
..Default::default()
let renderer = if self.enable_colors {
Renderer::styled()
} else {
Renderer::plain()
};

for (file, errors) in errors_by_file {
Expand Down Expand Up @@ -91,9 +91,8 @@ impl<'a> Display for FormatReportFormatter<'a> {
title,
footer: footer.into_iter().collect(),
slices: vec![slice],
opt,
};
writeln!(f, "{}\n", DisplayList::from(snippet))?;
writeln!(f, "{}\n", renderer.render(snippet))?;
}
}

Expand All @@ -110,9 +109,8 @@ impl<'a> Display for FormatReportFormatter<'a> {
}),
footer: Vec::new(),
slices: Vec::new(),
opt,
};
writeln!(f, "{}", DisplayList::from(snippet))?;
writeln!(f, "{}", renderer.render(snippet))?;
}

Ok(())
Expand Down