blob: f3c15c4103666dfbc92606902c9d62af6d2a0fed [file] [log] [blame]
Matthew Maurer597ccd52023-06-12 16:37:41 +00001use annotate_snippets::{
2 display_list::{DisplayList, FormatOptions},
3 snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation},
4};
5
6fn main() {
7 let snippet = Snippet {
8 title: Some(Annotation {
9 label: Some("mismatched types"),
10 id: Some("E0308"),
11 annotation_type: AnnotationType::Error,
12 }),
13 footer: vec![Annotation {
14 label: Some(
15 "expected type: `snippet::Annotation`\n found type: `__&__snippet::Annotation`",
16 ),
17 id: None,
18 annotation_type: AnnotationType::Note,
19 }],
20 slices: vec![Slice {
21 source: " slices: vec![\"A\",",
22 line_start: 13,
23 origin: Some("src/multislice.rs"),
24 fold: false,
25 annotations: vec![SourceAnnotation {
26 label: "expected struct `annotate_snippets::snippet::Slice`, found reference",
27 range: (21, 24),
28 annotation_type: AnnotationType::Error,
29 }],
30 }],
31 opt: FormatOptions {
32 color: true,
33 ..Default::default()
34 },
35 };
36
37 let dl = DisplayList::from(snippet);
38 println!("{}", dl);
39}