-
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
Emit fewer errors after parse errors #48724
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-parser
Area: The parsing of Rust source code to an AST
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
Comments
estebank
added
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
A-diagnostics
Area: Messages for errors, warnings, and lints
A-parser
Area: The parsing of Rust source code to an AST
labels
Mar 4, 2018
Centril
added a commit
to Centril/rust
that referenced
this issue
Jan 14, 2019
Modify some parser diagnostics to continue evaluating beyond the parser Continue evaluating further errors after parser errors on: - trailing type argument attribute - lifetime in incorrect location - incorrect binary literal - missing `for` in `impl Trait for Foo` - type argument in `where` clause - incorrect float literal - incorrect `..` in pattern - associated types - incorrect discriminator value variant error and others. All of these were found by making `continue-parse-after-error` `true` by default to identify errors that would need few changes. There are now only a handful of errors that have any change with `continue-parse-after-error` enabled. These changes make it so `rust` _won't_ stop evaluation after finishing parsing, enabling type checking errors to be displayed on the existing code without having to fix the parse errors. Each commit has an individual diagnostic change with their corresponding tests. CC rust-lang#48724.
Centril
added a commit
to Centril/rust
that referenced
this issue
Jan 14, 2019
Modify some parser diagnostics to continue evaluating beyond the parser Continue evaluating further errors after parser errors on: - trailing type argument attribute - lifetime in incorrect location - incorrect binary literal - missing `for` in `impl Trait for Foo` - type argument in `where` clause - incorrect float literal - incorrect `..` in pattern - associated types - incorrect discriminator value variant error and others. All of these were found by making `continue-parse-after-error` `true` by default to identify errors that would need few changes. There are now only a handful of errors that have any change with `continue-parse-after-error` enabled. These changes make it so `rust` _won't_ stop evaluation after finishing parsing, enabling type checking errors to be displayed on the existing code without having to fix the parse errors. Each commit has an individual diagnostic change with their corresponding tests. CC rust-lang#48724.
Closing as non actionable. We're already on track to do this but a lot of independent improvements are needed. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-parser
Area: The parsing of Rust source code to an AST
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
In cases of parse errors, many times we continue checking the code generating errors that would be fixed if the syntax was corrected. We should be more proactive in detecting elements that were "recovered" during parsing, in the same spirit as #46732.
It is particularly bad when encountering unenclosed delimiters. On this, the parser should try some really conservative local recovery (simple substitutions) and unless the rest of the code successfully compiles, the parser should discard the rest of the code until it finds a closing curly brace at the beggining of the line or EOF. This assumes that the likelihood of the following code being correct and usable is high. This type of recovery might still fail during typeck as, for example, methods might be missing. If this is the case, the
impl
block in the AST should be marked as "recovered" and during typeck avoid emitting errors related to it.The text was updated successfully, but these errors were encountered: