@@ -689,7 +689,8 @@ impl<'a> Parser<'a> {
689
689
pub fn check_reserved_keywords ( & mut self ) {
690
690
if self . token . is_reserved_keyword ( ) {
691
691
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 ( ) ;
693
694
}
694
695
}
695
696
@@ -869,7 +870,7 @@ impl<'a> Parser<'a> {
869
870
self . parse_seq_to_before_tokens ( kets,
870
871
SeqSep :: none ( ) ,
871
872
|p| p. parse_token_tree ( ) ,
872
- |mut e| e. cancel ( ) ) ;
873
+ |_self , mut e| e. cancel ( ) ) ;
873
874
}
874
875
875
876
/// Parse a sequence, including the closing delimiter. The function
@@ -897,7 +898,10 @@ impl<'a> Parser<'a> {
897
898
-> Vec < T >
898
899
where F : FnMut ( & mut Parser < ' a > ) -> PResult < ' a , T > ,
899
900
{
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
+ } )
901
905
}
902
906
903
907
// `fe` is an error handler.
@@ -908,7 +912,7 @@ impl<'a> Parser<'a> {
908
912
mut fe : Fe )
909
913
-> Vec < T >
910
914
where F : FnMut ( & mut Parser < ' a > ) -> PResult < ' a , T > ,
911
- Fe : FnMut ( DiagnosticBuilder )
915
+ Fe : FnMut ( & mut Parser < ' a > , DiagnosticBuilder )
912
916
{
913
917
let mut first: bool = true ;
914
918
let mut v = vec ! ( ) ;
@@ -919,7 +923,7 @@ impl<'a> Parser<'a> {
919
923
first = false ;
920
924
} else {
921
925
if let Err ( e) = self . expect ( t) {
922
- fe ( e) ;
926
+ fe ( self , e) ;
923
927
break ;
924
928
}
925
929
}
@@ -933,7 +937,7 @@ impl<'a> Parser<'a> {
933
937
match f ( self ) {
934
938
Ok ( t) => v. push ( t) ,
935
939
Err ( e) => {
936
- fe ( e) ;
940
+ fe ( self , e) ;
937
941
break ;
938
942
}
939
943
}
@@ -1091,7 +1095,8 @@ impl<'a> Parser<'a> {
1091
1095
self . sess . span_diagnostic . span_warn ( sp, m)
1092
1096
}
1093
1097
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 ( ) ;
1095
1100
}
1096
1101
pub fn span_bug ( & self , sp : Span , m : & str ) -> ! {
1097
1102
self . sess . span_diagnostic . span_bug ( sp, m)
@@ -2375,6 +2380,7 @@ impl<'a> Parser<'a> {
2375
2380
}
2376
2381
Err ( mut e) => {
2377
2382
e. emit ( ) ;
2383
+ self . sess . span_diagnostic . abort_if_no_parse_recovery ( ) ;
2378
2384
self . recover_stmt ( ) ;
2379
2385
}
2380
2386
}
@@ -2385,6 +2391,7 @@ impl<'a> Parser<'a> {
2385
2391
Ok ( f) => fields. push ( f) ,
2386
2392
Err ( mut e) => {
2387
2393
e. emit ( ) ;
2394
+ self . sess . span_diagnostic . abort_if_no_parse_recovery ( ) ;
2388
2395
self . recover_stmt ( ) ;
2389
2396
break ;
2390
2397
}
@@ -2396,6 +2403,7 @@ impl<'a> Parser<'a> {
2396
2403
Ok ( ( ) ) => { }
2397
2404
Err ( mut e) => {
2398
2405
e. emit ( ) ;
2406
+ self . sess . span_diagnostic . abort_if_no_parse_recovery ( ) ;
2399
2407
self . recover_stmt ( ) ;
2400
2408
break ;
2401
2409
}
@@ -2704,8 +2712,10 @@ impl<'a> Parser<'a> {
2704
2712
pub fn check_unknown_macro_variable ( & mut self ) {
2705
2713
if self . quote_depth == 0 {
2706
2714
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
+ }
2709
2719
_ => { }
2710
2720
}
2711
2721
}
@@ -3076,6 +3086,7 @@ impl<'a> Parser<'a> {
3076
3086
"use `::<...>` instead of `<...>` if you meant to specify type arguments" ) ;
3077
3087
}
3078
3088
err. emit ( ) ;
3089
+ self . sess . span_diagnostic . abort_if_no_parse_recovery ( ) ;
3079
3090
}
3080
3091
_ => { }
3081
3092
}
@@ -3284,6 +3295,7 @@ impl<'a> Parser<'a> {
3284
3295
Err ( mut e) => {
3285
3296
// Recover by skipping to the end of the block.
3286
3297
e. emit ( ) ;
3298
+ self . sess . span_diagnostic . abort_if_no_parse_recovery ( ) ;
3287
3299
self . recover_stmt ( ) ;
3288
3300
let hi = self . span . hi ;
3289
3301
if self . token == token:: CloseDelim ( token:: Brace ) {
@@ -3652,6 +3664,7 @@ impl<'a> Parser<'a> {
3652
3664
self . bump ( ) ;
3653
3665
let ( fields, etc) = self . parse_pat_fields ( ) . unwrap_or_else ( |mut e| {
3654
3666
e. emit ( ) ;
3667
+ self . sess . span_diagnostic . abort_if_no_parse_recovery ( ) ;
3655
3668
self . recover_stmt ( ) ;
3656
3669
( vec ! [ ] , false )
3657
3670
} ) ;
@@ -3868,6 +3881,7 @@ impl<'a> Parser<'a> {
3868
3881
fn parse_stmt_ ( & mut self ) -> Option < Stmt > {
3869
3882
self . parse_stmt_without_recovery ( ) . unwrap_or_else ( |mut e| {
3870
3883
e. emit ( ) ;
3884
+ self . sess . span_diagnostic . abort_if_no_parse_recovery ( ) ;
3871
3885
self . recover_stmt_ ( SemiColonMode :: Break ) ;
3872
3886
None
3873
3887
} )
@@ -4139,6 +4153,7 @@ impl<'a> Parser<'a> {
4139
4153
self . commit_stmt ( & [ ] , & [ token:: Semi , token:: CloseDelim ( token:: Brace ) ] )
4140
4154
{
4141
4155
e. emit ( ) ;
4156
+ self . sess . span_diagnostic . abort_if_no_parse_recovery ( ) ;
4142
4157
self . recover_stmt ( ) ;
4143
4158
}
4144
4159
}
@@ -4529,6 +4544,7 @@ impl<'a> Parser<'a> {
4529
4544
Ok ( arg) => Ok ( Some ( arg) ) ,
4530
4545
Err ( mut e) => {
4531
4546
e. emit ( ) ;
4547
+ p. sess . span_diagnostic . abort_if_no_parse_recovery ( ) ;
4532
4548
p. eat_to_tokens ( & [ & token:: Comma , & token:: CloseDelim ( token:: Paren ) ] ) ;
4533
4549
Ok ( None )
4534
4550
}
@@ -4917,6 +4933,7 @@ impl<'a> Parser<'a> {
4917
4933
inside the invocation")
4918
4934
. emit ( ) ;
4919
4935
}
4936
+ self . sess . span_diagnostic . abort_if_no_parse_recovery ( ) ;
4920
4937
}
4921
4938
Visibility :: Inherited => ( ) ,
4922
4939
}
@@ -5778,6 +5795,7 @@ impl<'a> Parser<'a> {
5778
5795
self . diagnostic ( ) . struct_span_err ( last_span, "const globals cannot be mutable" )
5779
5796
. fileline_help ( last_span, "did you mean to declare a static?" )
5780
5797
. emit ( ) ;
5798
+ self . sess . span_diagnostic . abort_if_no_parse_recovery ( ) ;
5781
5799
}
5782
5800
let ( ident, item_, extra_attrs) = self . parse_item_const ( None ) ?;
5783
5801
let last_span = self . last_span ;
0 commit comments