File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
compiler/rustc_parse/src/parser Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -158,7 +158,7 @@ pub struct Parser<'a> {
158158 /// This allows us to recover when the user forget to add braces around
159159 /// multiple statements in the closure body.
160160 pub current_closure : Option < ClosureSpans > ,
161- /// Whether the parser is allowed to recover and parse invalid code successfully (and emit a diagnostic as a side effect) .
161+ /// Whether the parser is allowed to do recovery .
162162 /// This is disabled when parsing macro arguments, see #103534
163163 pub recovery : Recovery ,
164164}
@@ -506,6 +506,13 @@ impl<'a> Parser<'a> {
506506 self
507507 }
508508
509+ /// Whether the parser is allowed to recover from broken code.
510+ ///
511+ /// If this returns false, recovering broken code into valid code (especially if this recovery does lookahead)
512+ /// is not allowed. All recovery done by the parser must be gated behind this check.
513+ ///
514+ /// Technically, this only needs to restruct eager recovery by doing lookahead at more tokens.
515+ /// But making the distinction is very subtle, and simply forbidding all recovery is a lot simpler to uphold.
509516 fn may_recover ( & self ) -> bool {
510517 matches ! ( self . recovery, Recovery :: Allowed )
511518 }
You can’t perform that action at this time.
0 commit comments