@@ -434,34 +434,31 @@ pub trait Emitter {
434434 span : & mut MultiSpan ,
435435 children : & mut Vec < SubDiagnostic > ,
436436 ) {
437+ let source_map = if let Some ( ref sm) = source_map {
438+ sm
439+ } else {
440+ return ;
441+ } ;
437442 debug ! ( "fix_multispans_in_extern_macros: before: span={:?} children={:?}" , span, children) ;
438- for span in iter:: once ( & mut * span) . chain ( children. iter_mut ( ) . map ( |child| & mut child. span ) ) {
439- self . fix_multispan_in_extern_macros ( source_map, span) ;
443+ self . fix_multispan_in_extern_macros ( source_map, span) ;
444+ for child in children. iter_mut ( ) {
445+ self . fix_multispan_in_extern_macros ( source_map, & mut child. span ) ;
440446 }
441447 debug ! ( "fix_multispans_in_extern_macros: after: span={:?} children={:?}" , span, children) ;
442448 }
443449
444450 // This "fixes" MultiSpans that contain `Span`s pointing to locations inside of external macros.
445451 // Since these locations are often difficult to read,
446452 // we move these spans from the external macros to their corresponding use site.
447- fn fix_multispan_in_extern_macros (
448- & self ,
449- source_map : & Option < Lrc < SourceMap > > ,
450- span : & mut MultiSpan ,
451- ) {
452- let sm = match source_map {
453- Some ( ref sm) => sm,
454- None => return ,
455- } ;
456-
453+ fn fix_multispan_in_extern_macros ( & self , source_map : & Lrc < SourceMap > , span : & mut MultiSpan ) {
457454 // First, find all the spans in external macros and point instead at their use site.
458455 let replacements: Vec < ( Span , Span ) > = span
459456 . primary_spans ( )
460457 . iter ( )
461458 . copied ( )
462459 . chain ( span. span_labels ( ) . iter ( ) . map ( |sp_label| sp_label. span ) )
463460 . filter_map ( |sp| {
464- if !sp. is_dummy ( ) && sm . is_imported ( sp) {
461+ if !sp. is_dummy ( ) && source_map . is_imported ( sp) {
465462 let maybe_callsite = sp. source_callsite ( ) ;
466463 if sp != maybe_callsite {
467464 return Some ( ( sp, maybe_callsite) ) ;
@@ -1232,7 +1229,6 @@ impl EmitterWriter {
12321229 is_secondary : bool ,
12331230 ) -> io:: Result < ( ) > {
12341231 let mut buffer = StyledBuffer :: new ( ) ;
1235- let header_style = if is_secondary { Style :: HeaderMsg } else { Style :: MainHeaderMsg } ;
12361232
12371233 if !msp. has_primary_spans ( ) && !msp. has_span_labels ( ) && is_secondary && !self . short_message
12381234 {
@@ -1257,6 +1253,7 @@ impl EmitterWriter {
12571253 buffer. append ( 0 , & code, Style :: Level ( * level) ) ;
12581254 buffer. append ( 0 , "]" , Style :: Level ( * level) ) ;
12591255 }
1256+ let header_style = if is_secondary { Style :: HeaderMsg } else { Style :: MainHeaderMsg } ;
12601257 if * level != Level :: FailureNote {
12611258 buffer. append ( 0 , ": " , header_style) ;
12621259 }
@@ -1470,9 +1467,7 @@ impl EmitterWriter {
14701467 let mut to_add = FxHashMap :: default ( ) ;
14711468
14721469 for ( depth, style) in depths {
1473- if multilines. get ( & depth) . is_some ( ) {
1474- multilines. remove ( & depth) ;
1475- } else {
1470+ if multilines. remove ( & depth) . is_none ( ) {
14761471 to_add. insert ( depth, style) ;
14771472 }
14781473 }
@@ -1726,14 +1721,13 @@ impl EmitterWriter {
17261721 if !self . short_message {
17271722 draw_col_separator_no_space ( & mut buffer, 0 , max_line_num_len + 1 ) ;
17281723 }
1729- match emit_to_destination (
1724+ if let Err ( e ) = emit_to_destination (
17301725 & buffer. render ( ) ,
17311726 level,
17321727 & mut self . dst ,
17331728 self . short_message ,
17341729 ) {
1735- Ok ( ( ) ) => ( ) ,
1736- Err ( e) => panic ! ( "failed to emit error: {}" , e) ,
1730+ panic ! ( "failed to emit error: {}" , e)
17371731 }
17381732 }
17391733 if !self . short_message {
0 commit comments