File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -594,12 +594,18 @@ fn highlight_lines(err: &mut EmitterWriter,
594594 let display_line_infos = & lines. lines [ ..display_lines] ;
595595 let display_line_strings = & line_strings[ ..display_lines] ;
596596
597+ // Calculate the widest number to format evenly and fix #11715
598+ assert ! ( display_line_infos. len( ) > 0 ) ;
599+ let mut max_line_num = display_line_infos[ display_line_infos. len ( ) - 1 ] . line_index + 1 ;
600+ let mut digits = 0 ;
601+ while max_line_num > 0 { max_line_num /= 10 ; digits += 1 ; }
597602 // Print the offending lines
598603 for ( line_info, line) in display_line_infos. iter ( ) . zip ( display_line_strings) {
599- try!( write ! ( & mut err. dst, "{}:{} {}\n " ,
604+ try!( write ! ( & mut err. dst, "{}:{:>width$ } {}\n " ,
600605 fm. name,
601606 line_info. line_index + 1 ,
602- line) ) ;
607+ line,
608+ width=digits) ) ;
603609 }
604610
605611 // If we elided something, put an ellipsis.
You can’t perform that action at this time.
0 commit comments