@@ -764,11 +764,7 @@ impl EmitterWriter {
764
764
annotations_position. push ( ( p, annotation) ) ;
765
765
for ( j, next) in annotations. iter ( ) . enumerate ( ) {
766
766
if j > i {
767
- let l = if let Some ( ref label) = next. label {
768
- label. len ( ) + 2
769
- } else {
770
- 0
771
- } ;
767
+ let l = next. label . map_or ( 0 , |label| label. len ( ) + 2 ) ;
772
768
if ( overlaps ( next, annotation, l) // Do not allow two labels to be in the same
773
769
// line if they overlap including padding, to
774
770
// avoid situations like:
@@ -1311,13 +1307,12 @@ impl EmitterWriter {
1311
1307
for line in & annotated_file. lines {
1312
1308
max_line_len = max ( max_line_len, annotated_file. file
1313
1309
. get_line ( line. line_index - 1 )
1314
- . map ( |s| s. len ( ) )
1315
- . unwrap_or ( 0 ) ) ;
1310
+ . map_or ( 0 , |s| s. len ( ) ) ;
1316
1311
for ann in & line. annotations {
1317
1312
span_right_margin = max ( span_right_margin, ann. start_col ) ;
1318
1313
span_right_margin = max ( span_right_margin, ann. end_col ) ;
1319
1314
// FIXME: account for labels not in the same line
1320
- let label_right = ann. label . as_ref ( ) . map ( |l| l. len ( ) + 1 ) . unwrap_or ( 0 ) ;
1315
+ let label_right = ann. label . as_ref ( ) . map_or ( 0 , |l| l. len ( ) + 1 ) ;
1321
1316
label_right_margin = max ( label_right_margin, ann. end_col + label_right) ;
1322
1317
}
1323
1318
}
0 commit comments