@@ -231,36 +231,42 @@ fn push_actual_errors(
231
231
// We expect to replace these with something more structured anyhow.
232
232
let mut message_lines = diagnostic. message . lines ( ) ;
233
233
let kind = ErrorKind :: from_str ( & diagnostic. level ) . ok ( ) ;
234
- if let Some ( first_line) = message_lines. next ( ) {
235
- let ignore = |s| {
236
- static RE : OnceLock < Regex > = OnceLock :: new ( ) ;
237
- RE . get_or_init ( || {
238
- Regex :: new ( r"aborting due to \d+ previous errors?|\d+ warnings? emitted" ) . unwrap ( )
239
- } )
240
- . is_match ( s )
241
- } ;
242
-
243
- if primary_spans . is_empty ( ) && ! ignore ( first_line) {
244
- errors . push ( Error { line_num : None , kind , msg : with_code ( None , first_line ) } ) ;
245
- } else {
246
- for span in primary_spans {
247
- errors. push ( Error {
248
- line_num : Some ( span. line_start ) ,
249
- kind,
250
- msg : with_code ( Some ( span) , first_line) ,
251
- } ) ;
252
- }
234
+ let first_line = message_lines. next ( ) . unwrap_or ( & diagnostic . message ) ;
235
+ if primary_spans . is_empty ( ) {
236
+ static RE : OnceLock < Regex > = OnceLock :: new ( ) ;
237
+ let re_init =
238
+ || Regex :: new ( r"aborting due to \d+ previous errors?|\d+ warnings? emitted" ) . unwrap ( ) ;
239
+ errors . push ( Error {
240
+ line_num : None ,
241
+ kind ,
242
+ msg : with_code ( None , first_line ) ,
243
+ require_annotation : ! RE . get_or_init ( re_init ) . is_match ( first_line) ,
244
+ } ) ;
245
+ } else {
246
+ for span in primary_spans {
247
+ errors. push ( Error {
248
+ line_num : Some ( span. line_start ) ,
249
+ kind,
250
+ msg : with_code ( Some ( span) , first_line) ,
251
+ require_annotation : true ,
252
+ } ) ;
253
253
}
254
254
}
255
255
for next_line in message_lines {
256
256
if primary_spans. is_empty ( ) {
257
- errors. push ( Error { line_num : None , kind : None , msg : with_code ( None , next_line) } ) ;
257
+ errors. push ( Error {
258
+ line_num : None ,
259
+ kind,
260
+ msg : with_code ( None , next_line) ,
261
+ require_annotation : false ,
262
+ } ) ;
258
263
} else {
259
264
for span in primary_spans {
260
265
errors. push ( Error {
261
266
line_num : Some ( span. line_start ) ,
262
- kind : None ,
267
+ kind,
263
268
msg : with_code ( Some ( span) , next_line) ,
269
+ require_annotation : false ,
264
270
} ) ;
265
271
}
266
272
}
@@ -274,6 +280,7 @@ fn push_actual_errors(
274
280
line_num : Some ( span. line_start + index) ,
275
281
kind : Some ( ErrorKind :: Suggestion ) ,
276
282
msg : line. to_string ( ) ,
283
+ require_annotation : true ,
277
284
} ) ;
278
285
}
279
286
}
@@ -292,6 +299,7 @@ fn push_actual_errors(
292
299
line_num : Some ( span. line_start ) ,
293
300
kind : Some ( ErrorKind :: Note ) ,
294
301
msg : span. label . clone ( ) . unwrap ( ) ,
302
+ require_annotation : true ,
295
303
} ) ;
296
304
}
297
305
@@ -311,6 +319,7 @@ fn push_backtrace(
311
319
line_num : Some ( expansion. span . line_start ) ,
312
320
kind : Some ( ErrorKind :: Note ) ,
313
321
msg : format ! ( "in this expansion of {}" , expansion. macro_decl_name) ,
322
+ require_annotation : true ,
314
323
} ) ;
315
324
}
316
325
0 commit comments