A fancy diagnostics & error reporting library https://crates.io/crates/ariadne
Find a file
Joshua Barretto 8d505e4e4e
All checks were successful
Rust / check (push) Successful in 53s
Rust / test (push) Successful in 58s
Rust / semver (push) Successful in 45s
Merge pull request 'feat: Make multiline label collapsing configurable per label' (#190) from TurtleArmy/ariadne:main into main
Reviewed-on: #190
Reviewed-by: Joshua Barretto <zesterer@noreply.codeberg.org>
2026-03-31 21:00:26 +02:00
.github Speed up CI 2026-03-17 15:46:36 +01:00
examples clippy fixes 2026-03-26 23:21:50 +00:00
misc Simplify README, minimise SVG and use absolute path 2026-03-23 23:12:18 +00:00
src test: Add more lines to multiline label tests 2026-03-31 21:00:26 +02:00
.gitignore Ignore temp files generated by cargo insta 2026-03-16 05:25:46 +01:00
Cargo.toml Place new style features behind unstable flag 2026-03-26 18:10:44 +00:00
CHANGELOG.md Updated changelog, bumped version 2025-10-28 17:20:18 +00:00
CONTRIBUTING.md Added CONTRIBUTING.md 2026-03-17 12:48:13 +00:00
LICENSE Create LICENSE (#38) 2022-07-04 21:58:07 +01:00
README.md Better default size for example image 2026-03-23 23:19:38 +00:00

Ariadne

crates.io crates.io License actions-badge

A fancy compiler diagnostics crate.

Example

Ariadne supports arbitrary multi-line spans

Source code
use ariadne::{Color, ColorGenerator, Fmt, Label, Report, ReportKind, Source};

// Generate & choose some colours for each of our elements
let mut colors = ColorGenerator::new();
let a = colors.next();
let b = colors.next();
let out = Color::Blue;

Report::build(ReportKind::Error, ("sample.tao", 12..12))
    .with_message(format!("Incompatible types"))
    .with_label(Label::new(("sample.tao", 32..33))
        .with_message(format!("This is of type {}", "Nat".fg(a)))
        .with_color(a))
    .with_label(Label::new(("sample.tao", 52..55))
        .with_message(format!("This is of type {}", "Str".fg(b)))
        .with_color(b))
    .with_label(Label::new(("sample.tao", 11..58))
        .with_message(format!("The values are outputs of this {} expression", "match".fg(out)))
        .with_color(out))
    .with_note(format!("Outputs of {} expressions must coerce to the same type", "match".fg(out)))
    .finish()
    .eprint(("sample.tao", Source::from(include_str!("sample.tao"))))
    .unwrap();

See examples/ for more examples.

About

ariadne is a sister project of chumsky. Neither are dependent on one-another, but I'm working on both simultaneously and like to think that their features complement each other. If you're thinking of using ariadne to process your compiler's output, why not try using chumsky to process its input?

Features

  • Inline and multi-line labels capable of handling arbitrary configurations of spans
  • Multi-file errors
  • Generic across custom spans and file caches
  • A choice of character sets to ensure compatibility
  • Coloured labels & highlighting with 8-bit and 24-bit color support (thanks to yansi)
  • Label priority and ordering
  • Compact mode for smaller diagnostics
  • Correct handling of variable-width characters such as tabs
  • A ColorGenerator type that generates distinct colours for visual elements.
  • A plethora of other options (tab width, label attach points, underlines, etc.)
  • Built-in ordering/overlap heuristics that come up with the best way to avoid overlapping & label crossover

Cargo Features

  • "concolor" enables integration with the concolor crate for global color output control across your application
  • "auto-color" enables concolor's "auto" feature for automatic color control

concolor's features should be defined by the top-level binary crate, but without any features enabled concolor does nothing. If ariadne is your only dependency using concolor then "auto-color" provides a convenience to enable concolor's automatic color support detection, i.e. this:

[dependencies]
ariadne = { version = "...", features = ["auto-color"] }

is equivalent to this:

[dependencies]
ariadne = { version = "...", features = ["concolor"] }
concolor = { version = "...", features = ["auto"] }

Planned Features

  • Improved layout planning & space usage
  • Non-ANSI terminal support
  • More accessibility options (screenreader-friendly mode, textured highlighting as an alternative to color, etc.)
  • More color options
  • Better support for layout restrictions (maximum terminal width, for example)

Stability

The API (should) follow semver. However, this does not apply to the layout of final error messages. Minor tweaks to the internal layout heuristics can often result in the exact format of error messages changing with labels moving slightly. If you experience a change in layout that you believe to be a regression (either the change is incorrect, or makes your diagnostics harder to read) then please open an issue.

Ariadne currently has a Minimum Supported Rust Version (MSRV) of 1.85.0.

Credit

Thanks to:

  • @brendanzab for their beautiful codespan crate that inspired me to try pushing the envelope of error diagnostics.

  • @estebank for showing innumerable people just how good compiler diagnostics can be through their work on Rust.

Provenance

This software is proudly and fondly written, maintained, used - and most crucially - understood by real human beings. While we can't personally attest to the provenance of every line of code ever contributed, the vast majority of the codebase has certainly been developed without the aid of large language models and other stochastic 'intelligence'.

While the license may not guarantee warranty 'of any kind', you can at least use this software in the comforting knowledge that its veracity and coherence is vouched for by sentient intelligence with skin in the game and a reputation to uphold.

Contribution guidelines