@@ -148,8 +148,7 @@ pub struct Parser<'a> {
148
148
149
149
impl < ' a > Drop for Parser < ' a > {
150
150
fn drop ( & mut self ) {
151
- let diag = self . diagnostic ( ) ;
152
- emit_unclosed_delims ( & mut self . unclosed_delims , diag) ;
151
+ emit_unclosed_delims ( & mut self . unclosed_delims , & self . sess ) ;
153
152
}
154
153
}
155
154
@@ -1372,12 +1371,12 @@ impl<'a> Parser<'a> {
1372
1371
1373
1372
crate fn make_unclosed_delims_error (
1374
1373
unmatched : UnmatchedBrace ,
1375
- handler : & errors :: Handler ,
1374
+ sess : & ParseSess ,
1376
1375
) -> Option < DiagnosticBuilder < ' _ > > {
1377
1376
// `None` here means an `Eof` was found. We already emit those errors elsewhere, we add them to
1378
1377
// `unmatched_braces` only for error recovery in the `Parser`.
1379
1378
let found_delim = unmatched. found_delim ?;
1380
- let mut err = handler . struct_span_err ( unmatched. found_span , & format ! (
1379
+ let mut err = sess . span_diagnostic . struct_span_err ( unmatched. found_span , & format ! (
1381
1380
"incorrect close delimiter: `{}`" ,
1382
1381
pprust:: token_kind_to_string( & token:: CloseDelim ( found_delim) ) ,
1383
1382
) ) ;
@@ -1391,8 +1390,10 @@ crate fn make_unclosed_delims_error(
1391
1390
Some ( err)
1392
1391
}
1393
1392
1394
- pub fn emit_unclosed_delims ( unclosed_delims : & mut Vec < UnmatchedBrace > , handler : & errors:: Handler ) {
1393
+ pub fn emit_unclosed_delims ( unclosed_delims : & mut Vec < UnmatchedBrace > , sess : & ParseSess ) {
1394
+ * sess. reached_eof . borrow_mut ( ) |= unclosed_delims. iter ( )
1395
+ . any ( |unmatched_delim| unmatched_delim. found_delim . is_none ( ) ) ;
1395
1396
for unmatched in unclosed_delims. drain ( ..) {
1396
- make_unclosed_delims_error ( unmatched, handler ) . map ( |mut e| e. emit ( ) ) ;
1397
+ make_unclosed_delims_error ( unmatched, sess ) . map ( |mut e| e. emit ( ) ) ;
1397
1398
}
1398
1399
}
0 commit comments