File tree 1 file changed +8
-2
lines changed 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,
594
594
let display_line_infos = & lines. lines [ ..display_lines] ;
595
595
let display_line_strings = & line_strings[ ..display_lines] ;
596
596
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 ; }
597
602
// Print the offending lines
598
603
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 " ,
600
605
fm. name,
601
606
line_info. line_index + 1 ,
602
- line) ) ;
607
+ line,
608
+ width=digits) ) ;
603
609
}
604
610
605
611
// If we elided something, put an ellipsis.
You can’t perform that action at this time.
0 commit comments