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 @@ -588,12 +588,18 @@ fn highlight_lines(err: &mut EmitterWriter,
588
588
let display_line_infos = & lines. lines [ ..display_lines] ;
589
589
let display_line_strings = & line_strings[ ..display_lines] ;
590
590
591
+ // Calculate the widest number to format evenly and fix #11715
592
+ assert ! ( display_line_infos. len > 0 ) ;
593
+ let mut max_line_num = display_line_infos[ display_line_infos. len ( ) - 1 ] . line_index + 1 ;
594
+ let mut digits = 0 ;
595
+ while max_line_num > 0 { max_line_num /= 10 ; digits += 1 ; }
591
596
// Print the offending lines
592
597
for ( line_info, line) in display_line_infos. iter ( ) . zip ( display_line_strings. iter ( ) ) {
593
- try!( write ! ( & mut err. dst, "{}:{} {}\n " ,
598
+ try!( write ! ( & mut err. dst, "{}:{:>width$ } {}\n " ,
594
599
fm. name,
595
600
line_info. line_index + 1 ,
596
- line) ) ;
601
+ line,
602
+ width=digits) ) ;
597
603
}
598
604
599
605
// If we elided something, put an ellipsis.
You can’t perform that action at this time.
0 commit comments