@@ -126,23 +126,29 @@ pub(super) fn report_suspicious_mismatch_block(
126
126
}
127
127
}
128
128
129
- pub ( crate ) fn make_unclosed_delims_error (
130
- unmatched : UnmatchedDelim ,
131
- psess : & ParseSess ,
132
- ) -> Option < Diag < ' _ > > {
133
- // `None` here means an `Eof` was found. We already emit those errors elsewhere, we add them to
134
- // `unmatched_delims` only for error recovery in the `Parser`.
135
- let found_delim = unmatched. found_delim ?;
136
- let mut spans = vec ! [ unmatched. found_span] ;
137
- if let Some ( sp) = unmatched. unclosed_span {
138
- spans. push ( sp) ;
139
- } ;
140
- let err = psess. dcx ( ) . create_err ( MismatchedClosingDelimiter {
141
- spans,
142
- delimiter : pprust:: token_kind_to_string ( & found_delim. as_close_token_kind ( ) ) . to_string ( ) ,
143
- unmatched : unmatched. found_span ,
144
- opening_candidate : unmatched. candidate_span ,
145
- unclosed : unmatched. unclosed_span ,
146
- } ) ;
147
- Some ( err)
129
+ pub ( crate ) fn make_errors_for_mismatched_closing_delims < ' psess > (
130
+ unmatcheds : & [ UnmatchedDelim ] ,
131
+ psess : & ' psess ParseSess ,
132
+ ) -> Vec < Diag < ' psess > > {
133
+ unmatcheds
134
+ . iter ( )
135
+ . filter_map ( |unmatched| {
136
+ // `None` here means an `Eof` was found. We already emit those errors elsewhere, we add them to
137
+ // `unmatched_delims` only for error recovery in the `Parser`.
138
+ let found_delim = unmatched. found_delim ?;
139
+ let mut spans = vec ! [ unmatched. found_span] ;
140
+ if let Some ( sp) = unmatched. unclosed_span {
141
+ spans. push ( sp) ;
142
+ } ;
143
+ let err = psess. dcx ( ) . create_err ( MismatchedClosingDelimiter {
144
+ spans,
145
+ delimiter : pprust:: token_kind_to_string ( & found_delim. as_close_token_kind ( ) )
146
+ . to_string ( ) ,
147
+ unmatched : unmatched. found_span ,
148
+ opening_candidate : unmatched. candidate_span ,
149
+ unclosed : unmatched. unclosed_span ,
150
+ } ) ;
151
+ Some ( err)
152
+ } )
153
+ . collect ( )
148
154
}
0 commit comments