-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update rustdoc's syntax checker to work with error-recovering lexer #63284
Comments
cc #56885 |
hm, #56885 makes me think that there are two ways to approach this:
I don't know what would be better (someone with more broad compiler knowledge needs to decide this), but I like |
An alternative would be to have the lexer and parser have a "strict" mode where they bail early when encountering any error, that way the caller can handle the |
@estebank That sounds like it would complicate |
A separate/custom emitter is definitely the way to go here, we should not complicate parsing code anymore than it already is. |
use silent emitter for rustdoc highlighting pass Partially addresses rust-lang#63284.
use silent emitter for rustdoc highlighting pass Partially addresses rust-lang#63284.
Should this be closed? |
Rustdoc processes code inside of
```
blocks in two ways:First, the code is checked for lexer errors
Second, lexer-based syntax highlighting is done
The checking for lexer errors works by intercepting fatal errors from the lexer. However, since this was originally implemented, the lexer moved from fatal erroring to error-recovery (#63017 in particular tries to remove the last bit of fatal erroring). That means that the current approach intercepts only a fraction of lexer errors, while most of the errors are reported twice (once duing the check, once during highlighing). Here's an example:
I think that, to fix this, we should configure the parsing session with a custom
Emitter
. For code-checking pass, the emmitter should downgrade all diagnostics to warnings and set a flag if there were any diagnostics. For syntax-highlighting pass, we should use a "/dev/null
" emitter which just doesn't emit anything.cc @euclio, @GuillaumeGomez
The text was updated successfully, but these errors were encountered: