@@ -34,9 +34,12 @@ pub(super) fn same_indentation_level(sm: &SourceMap, open_sp: Span, close_sp: Sp
3434
3535// When we get a `)` or `]` for `{`, we should emit help message here
3636// it's more friendly compared to report `unmatched error` in later phase
37- fn report_missing_open_delim ( err : & mut Diag < ' _ > , unmatched_delims : & [ UnmatchedDelim ] ) -> bool {
37+ fn report_missing_open_delim (
38+ err : & mut Diag < ' _ > ,
39+ unmatched_delims : & mut Vec < UnmatchedDelim > ,
40+ ) -> bool {
3841 let mut reported_missing_open = false ;
39- for unmatch_brace in unmatched_delims. iter ( ) {
42+ unmatched_delims. retain ( |unmatch_brace| {
4043 if let Some ( delim) = unmatch_brace. found_delim
4144 && matches ! ( delim, Delimiter :: Parenthesis | Delimiter :: Bracket )
4245 {
@@ -50,18 +53,21 @@ fn report_missing_open_delim(err: &mut Diag<'_>, unmatched_delims: &[UnmatchedDe
5053 format ! ( "missing open `{missed_open}` for this delimiter" ) ,
5154 ) ;
5255 reported_missing_open = true ;
56+ false
57+ } else {
58+ true
5359 }
54- }
60+ } ) ;
5561 reported_missing_open
5662}
5763
5864pub ( super ) fn report_suspicious_mismatch_block (
5965 err : & mut Diag < ' _ > ,
60- diag_info : & TokenTreeDiagInfo ,
66+ diag_info : & mut TokenTreeDiagInfo ,
6167 sm : & SourceMap ,
6268 delim : Delimiter ,
6369) {
64- if report_missing_open_delim ( err, & diag_info. unmatched_delims ) {
70+ if report_missing_open_delim ( err, & mut diag_info. unmatched_delims ) {
6571 return ;
6672 }
6773
0 commit comments