Several improvements to the Rust lexer #1711
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.
Each improvement is its own commit, and I tried to comment the code fairly well for anything too complex.
Also, it should basically all have tests (perhaps not exhaustive ones where trivial, e.g. I didn't ), except for the keyword additions which seem too simple to be worth testing.
I don't think this breaks highlighting of anything, e.g. I was careful to left the weird pre-Rust-1.0 stuff as I found it, and I'm very confident that the post-1.0 stuff is only more valid than before (I made these changes while consulting https://doc.rust-lang.org/reference/tokens.html, and for some reason, I've written lexers for Rust before).
I also tried to err on the side of accepting invalid code so long as it doesn't cause anything else to parse incorrectly.
P.S. I see that this project supports back to Ruby 2.0, but I tried to test for it, and couldn't follow the dev guide (bundler doesn't work that far back), so I'm somewhat relying on CI to tell me if anything is messed up. (Sorry, I haven't regularly written Ruby in years)