codespan-reporting
Beautiful diagnostic reporting for text-based programming languages
0.13.1
132M downloads/mo
#684 most downloaded on crates.io
brendanzab/codespan
What this package is like to depend on
Last release 10 months ago
22 Oct 2025
Ships unpredictably
gaps range from 2 weeks to 4.1 years
Some releases are documented
notes for 12 of 25 stable releases
Nothing withdrawn
no release was ever pulled
8 years old
25 releases · first in 2018
2 releases in the last 12 months
see the full history below
Release timeline
25 releases · Apr 2018 to Oct 2025Releases
latest 25-
0.13.122 Oct 2025Release notes
Open source →Version 0.13.1 fixes a few issues present in version 0.13.0.
- Allow writing to
&mut dyn WriteStyle#402 - Fix an issue with
str::from_utf8not being available on rust 1.67 #405 - Fix release action #408
- Fix regression in the API
with_note#409
Thanks to contributors and those who raised issues. Keep them coming!
- Allow writing to
-
0.13.015 Oct 2025Release notes
Open source →Release 0.13.0 adds a new rendering decoration system for reporting. It also includes a bug fix.
New features
In #387 @urisinger changed diagnostic emitting to be based on a new writer trait
WriteStyle. This addition allows more flexibility in the output of emitting diagnostics. For example the default terminal ANSI style can be swapped out for SVG tag generation (see example). The change includesstd::term::config::styles::StylesWriterandstd::term::config::styles::Stylesfor customisation of colours and other decoration during emit.This feature is backwards compatible with original
termcolorwriters.Bug fixes and user changes
The 0.12.0 version of codespan included
![no_std]support thanks to PR #374. Unfortunately, there were a few issues with it that were not caught by CI and went under the radar such as tests not passing under--no-default-features#399.Another issue included complications with
std::io::Writevscore::fmt::Write. This meant thatStringwould work under--no-default-featuresbut break with--feature std.PR #400 adds checks for tests across feature configurations and adds different
emitfunctions for different types of writers used. This includes aemit_to_stringfunction that should work across feature configuration.There still needs to be improvements in this area but I have not landed on anything simple.
WIP: It also adds a check to dependants of the library to check whether changes are compatible.
If you find any issues or have a feature suggestion, leave them in the issues.
Full Changelog: release/codespan-0.12.0...release/codespan-0.13.0
-
0.12.022 Mar 2025Release notes
Open source →This release is version 0.12.0 of the codespan crate. A library the provides "Beautiful diagnostic reporting for text-based programming languages".
This release contains a few bug fixes and small changes, there are no new features of breaking changes.
New maintainer
I (@kaleidawave) have been graciously added as a maintainer to this repository and have been gifted permission to publish updates to
codespan-reporting(and other crates in the repository) on crates.io by the original maintainer.I hope that I can keep this project up to date and make sure that additions (such as seen below) can in the future be released under a shorter time frame.
If you have any feature requests or changes for this project/crate, then don't hesitate to ping me.
What's Changed
Auto-generated by GitHub
- Change
.with_message()method to take more generic message type by @oOBoomberOo in #217 - Update lsp-types requirement from >=0.84, <0.89 to >=0.84, <0.90 by @dependabot-preview in #325
- Upgrade to GitHub-native Dependabot by @dependabot-preview in #327
- Add Naga to README by @kvark in #328
- Add 'mos' to the list of projects by @sagacity in #329
- Change multiline rendering with breaks to work properly by @mbartlett21 in #330
- use log10 to calculate the number of digits by @Johann150 in #332
- Add option for including context before and after a label by @elkowar in #331
- Fix typo in ci.yml by @Sematre in #338
- Update lsp-types requirement from >=0.84, <0.90 to >=0.84, <0.92 by @dependabot in #339
- Update peg requirement from 0.6 to 0.7 by @dependabot-preview in #326
- Fix Actions badges by @atouchet in #349
- Implement with_label & with_note by @InfiniteCoder01 in #363
- include LICENSE file in published crates by @decathorpe in #355
- examples: replace structopt with pico-args by @tamird in #357
- unicode-width: allow 0.2 to be selected by @nagisa in #369
- Allow ?Sized implementations of
Filesforterm::emit. by @ennis in #354 - Added generic iterator methods by @yankana in #341
- Add
no_stdSupport by @bushrat011899 in #374 - Add Spade to list of README projects by @ethanuppal in #368
- Add strict clippy lints and any changes after "auto-fix" by @kaleidawave in #373
Full Changelog: v0.11.1...release/codespan-0.12.0
- Change
-
0.11.125 Feb 2021Release notes
Open source →Added
- Add
Chars::{box_drawing, ascii}functions, the latter supporting a rustc-style of output that only uses ASCII characters (not above U+007F) for use cases that do not allow for box drawing characters, e.g. terminals that do not support them.
Changed
Diagnostic::with_labelsandDiagnostic::with_notesnow append additional labels rather tan overwriting them, meaning that the documentation and behaviour match more closely. The behaviour will only differ if you call the same builder methods multiple times. If you call every builder method once only, nothing should change.config::Chars::snippet_startis now a String instead of a singlechar.
- Add
-
0.11.029 Nov 2020Release notes
Open source →There is now a code of conduct and a contributing guide.
Some versions were skipped to sync up with the
codespan-lspcrate. The release process has been changed so this should not happen again.Added
- If a label spans over multiple lines, not all lines are rendered. The number of lines rendered at beginning and end is configurable separately.
- There is now a custom error type.
- There now is a medium rendering mode that is like the short rendering mode but also shows notes from the diagnostic.
PartialEqandEqimplementations for thediagnostic::{Diagnostic, Label, Severity}types.
Changed
- All errors now use the error type
codespan_reporting::file::Error. This type also replaces the custom error type forcodespan-lsp.
Fixed
- Empty error codes are not rendered.
- The locus ("location of the diagnostic") is now computed so it is always at the first primary label, or at the first secondary label if no primary labels are available.
- All
unwraps outside of tests and examples have been removed. - Some internal improvements, including various code style improvements by using Clippy.
- Improved documentation, also mentioning how the ordering of labels is handled.
-
0.9.524 Jun 2020Release notes
Open source →Changed
-
Sections of source code that are marked with primary labels are now rendered using the primary highlight color.
-
Tab stops are now rendered properly.
We used to just render
\tcharacters in source snippets with the same number of spaces.<details> <summary>Example</summary>
For example, when rendering with a tab width of
3we would print:warning: tab test ┌─ tab_columns:1:2 │ 1 │ hello │ ^^^^^ 2 │ ∙ hello │ ^^^^^ 3 │ ∙∙ hello │ ^^^^^ 4 │ ∙∙∙ hello │ ^^^^^ 5 │ ∙∙∙∙ hello │ ^^^^^ 6 │ ∙∙∙∙∙ hello │ ^^^^^ 7 │ ∙∙∙∙∙∙ hello │ ^^^^^Now we properly take into account the column of the tab character:
warning: tab test ┌─ tab_columns:1:2 │ 1 │ hello │ ^^^^^ 2 │ ∙ hello │ ^^^^^ 3 │ ∙∙ hello │ ^^^^^ 4 │ ∙∙∙ hello │ ^^^^^ 5 │ ∙∙∙∙ hello │ ^^^^^ 6 │ ∙∙∙∙∙ hello │ ^^^^^ 7 │ ∙∙∙∙∙∙ hello │ ^^^^^</details>
-
-
0.9.418 May 2020Release notes
Open source →Changed
-
We have made the caret rendering easier to read when there are multiple labels on the same line. We also avoid printing trailing borders on the final source source snippet if no notes are present.
<details> <summary>Example</summary>
Instead of this:
┌─ one_line.rs:3:5 │ 3 │ v.push(v.pop().unwrap()); │ - first borrow later used by call │ ---- first mutable borrow occurs here │ ^ second mutable borrow occurs here │…we now render the following:
┌─ one_line.rs:3:5 │ 3 │ v.push(v.pop().unwrap()); │ - ---- ^ second mutable borrow occurs here │ │ │ │ │ first mutable borrow occurs here │ first borrow later used by call</details>
Fixed
- Diagnostic rendering no longer panics if label ranges are between UTF-8 character boundaries.
-
-
0.9.329 Apr 2020Release notes
Open source →Changed
-
Some panics were fixed when invalid unicode boundaries are supplied.
-
Labels that marked the same span were originally rendered in reverse order. This was a mistake! We've now fixed this.
<details> <summary>Example</summary>
For example, this diagnostic:
┌─ same_range:1:7 │ 1 │ ::S { } │ - Expected '(' │ ^ Unexpected '{' │…will now be rendered as:
┌─ same_range:1:7 │ 1 │ ::S { } │ ^ Unexpected '{' │ - Expected '(' │</details>
-
We've reduced the prominence of the 'locus' on source snippets by simplifying the border and reducing the spacing around it. This is to help focus attention on the underlined source snippet and error messages, rather than the location, which should be a secondary focus.
<details> <summary>Example</summary>
For example we originally rendered this:
error: unknown builtin: `NATRAL` ┌── Data/Nat.fun:7:13 ─── │ 7 │ {-# BUILTIN NATRAL Nat #-} │ ^^^^^^ unknown builtin │ = there is a builtin with a similar name: `NATURAL`…and now we render this:
error: unknown builtin: `NATRAL` ┌─ Data/Nat.fun:7:13 │ 7 │ {-# BUILTIN NATRAL Nat #-} │ ^^^^^^ unknown builtin │ = there is a builtin with a similar name: `NATURAL`</details>
-
-
0.9.229 Mar 2020Release notes
Open source →Changed
-
Render overlapping multiline marks on the same lines of source code.
<details> <summary>Example</summary>
For example:
error[E0308]: match arms have incompatible types ┌── codespan/src/file.rs:1:9 ─── │ 1 │ ╭ match line_index.compare(self.last_line_index()) { 2 │ │ Ordering::Less => Ok(self.line_starts()[line_index.to_usize()]), 3 │ │ Ordering::Equal => Ok(self.source_span().end()), 4 │ │ Ordering::Greater => LineIndexOutOfBoundsError { 5 │ │ given: line_index, 6 │ │ max: self.last_line_index(), 7 │ │ }, 8 │ │ } │ ╰─────────' `match` arms have incompatible types · 2 │ Ordering::Less => Ok(self.line_starts()[line_index.to_usize()]), │ --------------------------------------------- this is found to be of type `Result<ByteIndex, LineIndexOutOfBoundsError>` 3 │ Ordering::Equal => Ok(self.source_span().end()), │ ---------------------------- this is found to be of type `Result<ByteIndex, LineIndexOutOfBoundsError>` 4 │ Ordering::Greater => LineIndexOutOfBoundsError { │ ╭──────────────────────────────────^ 5 │ │ given: line_index, 6 │ │ max: self.last_line_index(), 7 │ │ }, │ ╰─────────────^ expected enum `Result`, found struct `LineIndexOutOfBoundsError` │ = expected type `Result<ByteIndex, LineIndexOutOfBoundsError>` found type `LineIndexOutOfBoundsError`…is now rendered as:
error[E0308]: match arms have incompatible types ┌── codespan/src/file.rs:1:9 ─── │ 1 │ ╭ match line_index.compare(self.last_line_index()) { 2 │ │ Ordering::Less => Ok(self.line_starts()[line_index.to_usize()]), │ │ --------------------------------------------- this is found to be of type `Result<ByteIndex, LineIndexOutOfBoundsError>` 3 │ │ Ordering::Equal => Ok(self.source_span().end()), │ │ ---------------------------- this is found to be of type `Result<ByteIndex, LineIndexOutOfBoundsError>` 4 │ │ Ordering::Greater => LineIndexOutOfBoundsError { │ ╭─│──────────────────────────────────^ 5 │ │ │ given: line_index, 6 │ │ │ max: self.last_line_index(), 7 │ │ │ }, │ ╰─│─────────────^ expected enum `Result`, found struct `LineIndexOutOfBoundsError` 8 │ │ } │ ╰─────────' `match` arms have incompatible types │ = expected type `Result<ByteIndex, LineIndexOutOfBoundsError>` found type `LineIndexOutOfBoundsError`</details>
-
-
0.9.122 Mar 2020Release notes
Open source →Added
codespan_reporting::diagnostic::Diagnosticnow implementsDebug.
Changed
-
Single-line labels are now rendered together, under the same source line.
<details> <summary>Example</summary>
For example:
┌── one_line.rs:3:5 ─── │ 3 │ v.push(v.pop().unwrap()); │ - first borrow later used by call · 3 │ v.push(v.pop().unwrap()); │ ---- first mutable borrow occurs here · 3 │ v.push(v.pop().unwrap()); │ ^ second mutable borrow occurs here │…is now rendered as:
┌── one_line.rs:3:5 ─── │ 3 │ v.push(v.pop().unwrap()); │ - first borrow later used by call │ ---- first mutable borrow occurs here │ ^ second mutable borrow occurs here │</details>
-
0.9.015 Mar 2020Release notes
Open source →Added
- The
codespan_reporting::filesmodule was added as a way to decouplecodespan_reportingfromcodespan.codespan_reporting::files::Filesallows users to implement custom file databases that work withcodespan_reporting. This should make it easier to integrate with libraries like Salsa, and also makes it less invasive to usecodespan_reportingon existing projects.codespan_reporting::files::SimpleFileis a simple implementation ofcodespan_reporting::files::Fileswhere only a single file is needed.codespan_reporting::files::SimpleFilesis a simple implementation ofcodespan_reporting::files::Fileswhere multiple files are needed.
Changed
- The
codespan_reporting::diagnosticmodule has been greatly revamped, making the builder API format more nicely with rustfmt, and allowing for multiple primary labels. - The output of
codespan_reporting::term::emitwas improved, with the following changes:- labels on consecutive lines no longer render breaks between them
- source lines are rendered when there is only one line between labels
- the inner gutter of code snippets is now aligned consistently
- the outer gutter of consecutive code snippets are now aligned consistently
codespan_reporting::term::emitnow takes writers as a trait object (rather than using static dispatch) in order to reduce coda bloat and improve compile times.- The field names in
codespan_reporting::term::Charswere tweaked for consistency.
Removed
codespan_reportingno longer depends oncodespan. Note thatcodespancan still be used withcodespan_reporting, ascodespan::Filesnow implementscodespan_reporting::files::Files.
- The
-
0.8.024 Feb 2020Nothing published for this version
-
0.7.006 Jan 2020Nothing published for this version
-
0.6.018 Dec 2019Nothing published for this version
-
0.5.002 Oct 2019Nothing published for this version
-
0.4.125 Aug 2019Nothing published for this version
-
0.4.022 Aug 2019Nothing published for this version
-
0.3.030 Apr 2019Nothing published for this version
-
0.2.126 Feb 2019Nothing published for this version
-
0.2.011 Oct 2018Release notes
Open source → -
0.1.420 Aug 2018Nothing published for this version
-
0.1.318 Apr 2018Nothing published for this version
-
0.1.216 Apr 2018Nothing published for this version
-
0.1.116 Apr 2018Nothing published for this version
-
0.1.016 Apr 2018Nothing published for this version