@@ -689,7 +689,8 @@ impl<'a> Parser<'a> {
689689 pub fn check_reserved_keywords ( & mut self ) {
690690 if self . token . is_reserved_keyword ( ) {
691691 let token_str = self . this_token_to_string ( ) ;
692- self . fatal ( & format ! ( "`{}` is a reserved keyword" , token_str) ) . emit ( )
692+ self . fatal ( & format ! ( "`{}` is a reserved keyword" , token_str) ) . emit ( ) ;
693+ self . sess . span_diagnostic . abort_if_no_parse_recovery ( ) ;
693694 }
694695 }
695696
@@ -869,7 +870,7 @@ impl<'a> Parser<'a> {
869870 self . parse_seq_to_before_tokens ( kets,
870871 SeqSep :: none ( ) ,
871872 |p| p. parse_token_tree ( ) ,
872- |mut e| e. cancel ( ) ) ;
873+ |_self , mut e| e. cancel ( ) ) ;
873874 }
874875
875876 /// Parse a sequence, including the closing delimiter. The function
@@ -897,7 +898,10 @@ impl<'a> Parser<'a> {
897898 -> Vec < T >
898899 where F : FnMut ( & mut Parser < ' a > ) -> PResult < ' a , T > ,
899900 {
900- self . parse_seq_to_before_tokens ( & [ ket] , sep, f, |mut e| e. emit ( ) )
901+ self . parse_seq_to_before_tokens ( & [ ket] , sep, f, |s, mut e| {
902+ e. emit ( ) ;
903+ s. sess . span_diagnostic . abort_if_no_parse_recovery ( ) ;
904+ } )
901905 }
902906
903907 // `fe` is an error handler.
@@ -908,7 +912,7 @@ impl<'a> Parser<'a> {
908912 mut fe : Fe )
909913 -> Vec < T >
910914 where F : FnMut ( & mut Parser < ' a > ) -> PResult < ' a , T > ,
911- Fe : FnMut ( DiagnosticBuilder )
915+ Fe : FnMut ( & mut Parser < ' a > , DiagnosticBuilder )
912916 {
913917 let mut first: bool = true ;
914918 let mut v = vec ! ( ) ;
@@ -919,7 +923,7 @@ impl<'a> Parser<'a> {
919923 first = false ;
920924 } else {
921925 if let Err ( e) = self . expect ( t) {
922- fe ( e) ;
926+ fe ( self , e) ;
923927 break ;
924928 }
925929 }
@@ -933,7 +937,7 @@ impl<'a> Parser<'a> {
933937 match f ( self ) {
934938 Ok ( t) => v. push ( t) ,
935939 Err ( e) => {
936- fe ( e) ;
940+ fe ( self , e) ;
937941 break ;
938942 }
939943 }
@@ -1091,7 +1095,8 @@ impl<'a> Parser<'a> {
10911095 self . sess . span_diagnostic . span_warn ( sp, m)
10921096 }
10931097 pub fn span_err ( & self , sp : Span , m : & str ) {
1094- self . sess . span_diagnostic . span_err ( sp, m)
1098+ self . sess . span_diagnostic . span_err ( sp, m) ;
1099+ self . sess . span_diagnostic . abort_if_no_parse_recovery ( ) ;
10951100 }
10961101 pub fn span_bug ( & self , sp : Span , m : & str ) -> ! {
10971102 self . sess . span_diagnostic . span_bug ( sp, m)
@@ -2375,6 +2380,7 @@ impl<'a> Parser<'a> {
23752380 }
23762381 Err ( mut e) => {
23772382 e. emit ( ) ;
2383+ self . sess . span_diagnostic . abort_if_no_parse_recovery ( ) ;
23782384 self . recover_stmt ( ) ;
23792385 }
23802386 }
@@ -2385,6 +2391,7 @@ impl<'a> Parser<'a> {
23852391 Ok ( f) => fields. push ( f) ,
23862392 Err ( mut e) => {
23872393 e. emit ( ) ;
2394+ self . sess . span_diagnostic . abort_if_no_parse_recovery ( ) ;
23882395 self . recover_stmt ( ) ;
23892396 break ;
23902397 }
@@ -2396,6 +2403,7 @@ impl<'a> Parser<'a> {
23962403 Ok ( ( ) ) => { }
23972404 Err ( mut e) => {
23982405 e. emit ( ) ;
2406+ self . sess . span_diagnostic . abort_if_no_parse_recovery ( ) ;
23992407 self . recover_stmt ( ) ;
24002408 break ;
24012409 }
@@ -2704,8 +2712,10 @@ impl<'a> Parser<'a> {
27042712 pub fn check_unknown_macro_variable ( & mut self ) {
27052713 if self . quote_depth == 0 {
27062714 match self . token {
2707- token:: SubstNt ( name, _) =>
2708- self . fatal ( & format ! ( "unknown macro variable `{}`" , name) ) . emit ( ) ,
2715+ token:: SubstNt ( name, _) => {
2716+ self . fatal ( & format ! ( "unknown macro variable `{}`" , name) ) . emit ( ) ;
2717+ self . sess . span_diagnostic . abort_if_no_parse_recovery ( ) ;
2718+ }
27092719 _ => { }
27102720 }
27112721 }
@@ -3076,6 +3086,7 @@ impl<'a> Parser<'a> {
30763086 "use `::<...>` instead of `<...>` if you meant to specify type arguments" ) ;
30773087 }
30783088 err. emit ( ) ;
3089+ self . sess . span_diagnostic . abort_if_no_parse_recovery ( ) ;
30793090 }
30803091 _ => { }
30813092 }
@@ -3284,6 +3295,7 @@ impl<'a> Parser<'a> {
32843295 Err ( mut e) => {
32853296 // Recover by skipping to the end of the block.
32863297 e. emit ( ) ;
3298+ self . sess . span_diagnostic . abort_if_no_parse_recovery ( ) ;
32873299 self . recover_stmt ( ) ;
32883300 let hi = self . span . hi ;
32893301 if self . token == token:: CloseDelim ( token:: Brace ) {
@@ -3652,6 +3664,7 @@ impl<'a> Parser<'a> {
36523664 self . bump ( ) ;
36533665 let ( fields, etc) = self . parse_pat_fields ( ) . unwrap_or_else ( |mut e| {
36543666 e. emit ( ) ;
3667+ self . sess . span_diagnostic . abort_if_no_parse_recovery ( ) ;
36553668 self . recover_stmt ( ) ;
36563669 ( vec ! [ ] , false )
36573670 } ) ;
@@ -3868,6 +3881,7 @@ impl<'a> Parser<'a> {
38683881 fn parse_stmt_ ( & mut self ) -> Option < Stmt > {
38693882 self . parse_stmt_without_recovery ( ) . unwrap_or_else ( |mut e| {
38703883 e. emit ( ) ;
3884+ self . sess . span_diagnostic . abort_if_no_parse_recovery ( ) ;
38713885 self . recover_stmt_ ( SemiColonMode :: Break ) ;
38723886 None
38733887 } )
@@ -4139,6 +4153,7 @@ impl<'a> Parser<'a> {
41394153 self . commit_stmt ( & [ ] , & [ token:: Semi , token:: CloseDelim ( token:: Brace ) ] )
41404154 {
41414155 e. emit ( ) ;
4156+ self . sess . span_diagnostic . abort_if_no_parse_recovery ( ) ;
41424157 self . recover_stmt ( ) ;
41434158 }
41444159 }
@@ -4529,6 +4544,7 @@ impl<'a> Parser<'a> {
45294544 Ok ( arg) => Ok ( Some ( arg) ) ,
45304545 Err ( mut e) => {
45314546 e. emit ( ) ;
4547+ p. sess . span_diagnostic . abort_if_no_parse_recovery ( ) ;
45324548 p. eat_to_tokens ( & [ & token:: Comma , & token:: CloseDelim ( token:: Paren ) ] ) ;
45334549 Ok ( None )
45344550 }
@@ -4917,6 +4933,7 @@ impl<'a> Parser<'a> {
49174933 inside the invocation")
49184934 . emit ( ) ;
49194935 }
4936+ self . sess . span_diagnostic . abort_if_no_parse_recovery ( ) ;
49204937 }
49214938 Visibility :: Inherited => ( ) ,
49224939 }
@@ -5778,6 +5795,7 @@ impl<'a> Parser<'a> {
57785795 self . diagnostic ( ) . struct_span_err ( last_span, "const globals cannot be mutable" )
57795796 . fileline_help ( last_span, "did you mean to declare a static?" )
57805797 . emit ( ) ;
5798+ self . sess . span_diagnostic . abort_if_no_parse_recovery ( ) ;
57815799 }
57825800 let ( ident, item_, extra_attrs) = self . parse_item_const ( None ) ?;
57835801 let last_span = self . last_span ;
0 commit comments