@@ -231,36 +231,42 @@ fn push_actual_errors(
231231 // We expect to replace these with something more structured anyhow.
232232 let mut message_lines = diagnostic. message . lines ( ) ;
233233 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+ } ) ;
253253 }
254254 }
255255 for next_line in message_lines {
256256 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+ } ) ;
258263 } else {
259264 for span in primary_spans {
260265 errors. push ( Error {
261266 line_num : Some ( span. line_start ) ,
262- kind : None ,
267+ kind,
263268 msg : with_code ( Some ( span) , next_line) ,
269+ require_annotation : false ,
264270 } ) ;
265271 }
266272 }
@@ -274,6 +280,7 @@ fn push_actual_errors(
274280 line_num : Some ( span. line_start + index) ,
275281 kind : Some ( ErrorKind :: Suggestion ) ,
276282 msg : line. to_string ( ) ,
283+ require_annotation : true ,
277284 } ) ;
278285 }
279286 }
@@ -292,6 +299,7 @@ fn push_actual_errors(
292299 line_num : Some ( span. line_start ) ,
293300 kind : Some ( ErrorKind :: Note ) ,
294301 msg : span. label . clone ( ) . unwrap ( ) ,
302+ require_annotation : true ,
295303 } ) ;
296304 }
297305
@@ -311,6 +319,7 @@ fn push_backtrace(
311319 line_num : Some ( expansion. span . line_start ) ,
312320 kind : Some ( ErrorKind :: Note ) ,
313321 msg : format ! ( "in this expansion of {}" , expansion. macro_decl_name) ,
322+ require_annotation : true ,
314323 } ) ;
315324 }
316325
0 commit comments