File tree 1 file changed +8
-1
lines changed
compiler/rustc_parse/src/parser
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> {
158
158
/// This allows us to recover when the user forget to add braces around
159
159
/// multiple statements in the closure body.
160
160
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 .
162
162
/// This is disabled when parsing macro arguments, see #103534
163
163
pub recovery : Recovery ,
164
164
}
@@ -506,6 +506,13 @@ impl<'a> Parser<'a> {
506
506
self
507
507
}
508
508
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.
509
516
fn may_recover ( & self ) -> bool {
510
517
matches ! ( self . recovery, Recovery :: Allowed )
511
518
}
You can’t perform that action at this time.
0 commit comments