All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
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.Diagnostic::with_labels
and Diagnostic::with_notes
now 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_start
is now a String instead of a single char
.There is now a code of conduct and a contributing guide.
Some versions were skipped to sync up with the codespan-lsp
crate. The release process has been changed so this should not happen again.
PartialEq
and Eq
implementations for the diagnostic::{Diagnostic, Label, Severity}
types.codespan_reporting::file::Error
. This type also replaces the custom error type for codespan-lsp
.unwrap
s outside of tests and examples have been removed.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 \t
characters in source snippets with the same number of spaces.
For example, when rendering with a tab width of 3
we 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 │ ^^^^^
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.
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
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.
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 '(' │
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.
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`
Render overlapping multiline marks on the same lines of source code.
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`
codespan_reporting::diagnostic::Diagnostic
now implements Debug
.Single-line labels are now rendered together, under the same source line.
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 │
codespan_reporting::files
module was added as a way to decouple codespan_reporting
from codespan
.codespan_reporting::files::Files
allows users to implement custom file databases that work with codespan_reporting
. This should make it easier to integrate with libraries like Salsa, and also makes it less invasive to use codespan_reporting
on existing projects.codespan_reporting::files::SimpleFile
is a simple implementation of codespan_reporting::files::Files
where only a single file is needed.codespan_reporting::files::SimpleFiles
is a simple implementation of codespan_reporting::files::Files
where multiple files are needed.codespan_reporting::diagnostic
module has been greatly revamped, making the builder API format more nicely with rustfmt, and allowing for multiple primary labels.codespan_reporting::term::emit
was improved, with the following changes:codespan_reporting::term::emit
now takes writers as a trait object (rather than using static dispatch) in order to reduce coda bloat and improve compile times.codespan_reporting::term::Chars
were tweaked for consistency.codespan_reporting
no longer depends on codespan
. Note that codespan
can still be used with codespan_reporting
, as codespan::Files
now implements codespan_reporting::files::Files
.