This repository has been archived by the owner on Dec 13, 2021. It is now read-only.
Update to codespan and codespan-reporting 0.6 #160
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a fairly big change due to the different representation of
Span
incodespan
0.4.Previously all files were represented in a contiguous 32bit space as if they were concatenate in to a single file. This is also how the Rust compiler and Arret's ancient bespoke system used to work. Now, there is a separate
FileId
that identifies the file while theSpan
is an offset within the file.This makes the
codespan
API cleaner but presents a couple of disadvantages:In some cases we don't have a
FileId
. This comes up a lot in tests and also in the REPL when we want to parse for syntax highlighting. In these cases we never report diagnostics so we don't need aFileId
. Previously we would just create our ownSpan
s that were offset from 0 and hope we didn't accidentally diagnose with them.We could create a
codespan::Files
every time we parse but this adds overhead, especially becausecodespan
isn't thread safe so it requires locking.We use
Option<FileId>
in our customSpan
type to get around the cases where we don't want to commit to a full file.This increases the size of our
Span
type from 8 bytes to 12 bytes (start + end +Option<FileId>
).On the plus side this brings us back onboard with
codepan
which should help with LSP support. There also seems to be better rendering of diagnostics across multiple files.