multiline/
multiline.rs

1use ariadne::{Report, ReportKind, Label, Source, Color, ColorGenerator, Fmt};
2
3fn main() {
4    let mut colors = ColorGenerator::new();
5
6    // Generate & choose some colours for each of our elements
7    let a = colors.next();
8    let b = colors.next();
9    let out = Color::Fixed(81);
10    let out2= colors.next();
11
12    Report::build(ReportKind::Error, "sample.tao", 12)
13        .with_code(3)
14        .with_message(format!("Incompatible types"))
15        .with_label(Label::new(("sample.tao", 32..33))
16            .with_message(format!("This is of type {}", "Nat".fg(a)))
17            .with_color(a))
18        .with_label(Label::new(("sample.tao", 42..45))
19            .with_message(format!("This is of type {}", "Str".fg(b)))
20            .with_color(b))
21        .with_label(Label::new(("sample.tao", 11..48))
22            .with_message(format!(
23                "The values are outputs of this {} expression",
24                "match".fg(out),
25            ))
26            .with_color(out))
27        .with_label(Label::new(("sample.tao", 0..48))
28            .with_message(format!(
29                "The {} has a problem",
30                "definition".fg(out2),
31            ))
32            .with_color(out2))
33        .with_label(Label::new(("sample.tao", 50..76))
34            .with_message(format!(
35                "Usage of {} here",
36                "definition".fg(out2),
37            ))
38            .with_color(out2))
39        .with_note(format!("Outputs of {} expressions must coerce to the same type", "match".fg(out)))
40        .finish()
41        .print(("sample.tao", Source::from(include_str!("sample.tao"))))
42        .unwrap();
43}