Repository navigation
Render error listings with a line index - #593
Merged
Merged
Conversation
This ports the changes to error.rs from Mull, along with the line_index.rs it now depends on, so both files match Mull's apart from its quick fixes: - Each error's listing finds its lines with an index of the source's lines instead of scanning the source from its start, so reporting many errors no longer takes time proportional to the number of errors times the size of the source. - Formatting a list of errors appends each one to the output instead of rebuilding it, which was quadratic in the number of errors. - A listing no longer panics when a range ends within a line's indentation, excludes indentation from every line's highlight, and no longer ends with a row of only spaces when its last line has nothing highlighted. Each phase which reports errors builds an index of the source's lines once and passes it along when constructing errors.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 ports the changes to
error.rsfrom Mull, along with theline_index.rsit now depends on. Both files now match Mull's byte for byte, except for Mull's quick fixes (theFixtype, thefixfield and accessor, and the corresponding constructor argument).LineIndexinstead of scanning the source from its start, so reporting many errors no longer takes time proportional to the number of errors times the size of the source.Error::new's source context is now(&str, &LineIndex, SourceRange).format_errorsappends each error to the output instead of rebuilding it, which was quadratic in the number of errors.Each phase which reports errors builds a
LineIndexonce at its entry point and passes it along when constructing errors, so the many tests that call these phases don't change.The only visible change in the output is that an error at the end of a file is followed by an empty line rather than a line of spaces.
Status: Ready
Fixes: N/A