crates: vendor annotate-snippets crate

This merely adds the crate to our repository. Some cosmetic changes are
made to make it work in our repo and follow our conventions, such as
changing the name to `ruff_annotate_snippets`. We retain the original
license information. We do drop some things, such as benchmarks, but
keep tests and examples.
This commit is contained in:
Andrew Gallant 2024-12-20 12:55:16 -05:00 committed by Andrew Gallant
parent 4f3209a3ec
commit 9c27c57b5b
58 changed files with 6171 additions and 8 deletions

View file

@ -0,0 +1,22 @@
use ruff_annotate_snippets::{Level, Renderer, Snippet};
fn main() {
let message =
Level::Error
.title("mismatched types")
.id("E0308")
.snippet(
Snippet::source(" slices: vec![\"A\",")
.line_start(13)
.origin("src/multislice.rs")
.annotation(Level::Error.span(21..24).label(
"expected struct `annotate_snippets::snippet::Slice`, found reference",
)),
)
.footer(Level::Note.title(
"expected type: `snippet::Annotation`\n found type: `__&__snippet::Annotation`",
));
let renderer = Renderer::styled();
anstream::println!("{}", renderer.render(message));
}