File tree 1 file changed +11
-0
lines changed
1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -254,6 +254,7 @@ pub struct Parser<'a> {
254
254
/// the previous token or None (only stashed sometimes).
255
255
pub last_token : Option < Box < token:: Token > > ,
256
256
last_token_interpolated : bool ,
257
+ last_token_eof : bool ,
257
258
pub buffer : [ TokenAndSpan ; 4 ] ,
258
259
pub buffer_start : isize ,
259
260
pub buffer_end : isize ,
@@ -366,6 +367,7 @@ impl<'a> Parser<'a> {
366
367
last_span : span,
367
368
last_token : None ,
368
369
last_token_interpolated : false ,
370
+ last_token_eof : false ,
369
371
buffer : [
370
372
placeholder. clone ( ) ,
371
373
placeholder. clone ( ) ,
@@ -998,6 +1000,15 @@ impl<'a> Parser<'a> {
998
1000
999
1001
/// Advance the parser by one token
1000
1002
pub fn bump ( & mut self ) {
1003
+ if self . last_token_eof {
1004
+ // Bumping after EOF is a bad sign, usually an infinite loop.
1005
+ self . bug ( "attempted to bump the parser past EOF (may be stuck in a loop)" ) ;
1006
+ }
1007
+
1008
+ if self . token == token:: Eof {
1009
+ self . last_token_eof = true ;
1010
+ }
1011
+
1001
1012
self . last_span = self . span ;
1002
1013
// Stash token for error recovery (sometimes; clone is not necessarily cheap).
1003
1014
self . last_token = if self . token . is_ident ( ) ||
You can’t perform that action at this time.
0 commit comments