@@ -181,8 +181,6 @@ fn push_actual_errors(
181
181
. filter ( |( _, span) | Path :: new ( & span. file_name ) == Path :: new ( & file_name) )
182
182
. collect ( ) ;
183
183
184
- let spans_in_this_file: Vec < _ > = spans_info_in_this_file. iter ( ) . map ( |( _, span) | span) . collect ( ) ;
185
-
186
184
let primary_spans: Vec < _ > = spans_info_in_this_file
187
185
. iter ( )
188
186
. filter ( |( is_primary, _) | * is_primary)
@@ -280,7 +278,9 @@ fn push_actual_errors(
280
278
line_num : Some ( span. line_start + index) ,
281
279
kind : ErrorKind :: Suggestion ,
282
280
msg : line. to_string ( ) ,
283
- require_annotation : true ,
281
+ // Empty suggestions (suggestions to remove something) are common
282
+ // and annotating them in source is not useful.
283
+ require_annotation : !line. is_empty ( ) ,
284
284
} ) ;
285
285
}
286
286
}
@@ -294,13 +294,16 @@ fn push_actual_errors(
294
294
}
295
295
296
296
// Add notes for any labels that appear in the message.
297
- for span in spans_in_this_file. iter ( ) . filter ( |span| span. label . is_some ( ) ) {
298
- errors. push ( Error {
299
- line_num : Some ( span. line_start ) ,
300
- kind : ErrorKind :: Note ,
301
- msg : span. label . clone ( ) . unwrap ( ) ,
302
- require_annotation : true ,
303
- } ) ;
297
+ for ( _, span) in spans_info_in_this_file {
298
+ if let Some ( label) = & span. label {
299
+ errors. push ( Error {
300
+ line_num : Some ( span. line_start ) ,
301
+ kind : ErrorKind :: Note ,
302
+ msg : label. clone ( ) ,
303
+ // Empty labels (only underlining spans) are common and do not need annotations.
304
+ require_annotation : !label. is_empty ( ) ,
305
+ } ) ;
306
+ }
304
307
}
305
308
306
309
// Flatten out the children.
0 commit comments