Skip to content

Emit fewer errors after parse errors #48724

Closed
@estebank

Description

@estebank

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTC-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions