]> git.proxmox.com Git - rustc.git/blob - vendor/annotate-snippets/examples/footer.rs
New upstream version 1.37.0+dfsg1
[rustc.git] / vendor / annotate-snippets / examples / footer.rs
1 extern crate annotate_snippets;
2
3 use annotate_snippets::display_list::DisplayList;
4 use annotate_snippets::formatter::DisplayListFormatter;
5 use annotate_snippets::snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation};
6
7 fn main() {
8 let snippet = Snippet {
9 title: Some(Annotation {
10 label: Some("mismatched types".to_string()),
11 id: Some("E0308".to_string()),
12 annotation_type: AnnotationType::Error,
13 }),
14 footer: vec![Annotation {
15 label: Some(
16 "expected type: `snippet::Annotation`\n found type: `__&__snippet::Annotation`"
17 .to_string(),
18 ),
19 id: None,
20 annotation_type: AnnotationType::Note,
21 }],
22 slices: vec![Slice {
23 source: " slices: vec![\"A\",".to_string(),
24 line_start: 13,
25 origin: Some("src/multislice.rs".to_string()),
26 fold: false,
27 annotations: vec![SourceAnnotation {
28 label: "expected struct `annotate_snippets::snippet::Slice`, found reference"
29 .to_string(),
30 range: (21, 24),
31 annotation_type: AnnotationType::Error,
32 }],
33 }],
34 };
35
36 let dl = DisplayList::from(snippet);
37 let dlf = DisplayListFormatter::new(true);
38 println!("{}", dlf.format(&dl));
39 }