@@ -148,8 +148,7 @@ pub struct Parser<'a> {
148148
149149impl < ' a > Drop for Parser < ' a > {
150150 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 ) ;
153152 }
154153}
155154
@@ -1372,12 +1371,12 @@ impl<'a> Parser<'a> {
13721371
13731372crate fn make_unclosed_delims_error (
13741373 unmatched : UnmatchedBrace ,
1375- handler : & errors :: Handler ,
1374+ sess : & ParseSess ,
13761375) -> Option < DiagnosticBuilder < ' _ > > {
13771376 // `None` here means an `Eof` was found. We already emit those errors elsewhere, we add them to
13781377 // `unmatched_braces` only for error recovery in the `Parser`.
13791378 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 ! (
13811380 "incorrect close delimiter: `{}`" ,
13821381 pprust:: token_kind_to_string( & token:: CloseDelim ( found_delim) ) ,
13831382 ) ) ;
@@ -1391,8 +1390,10 @@ crate fn make_unclosed_delims_error(
13911390 Some ( err)
13921391}
13931392
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 ( ) ) ;
13951396 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 ( ) ) ;
13971398 }
13981399}
0 commit comments