Skip to content

Commit

Permalink
Indent code past the widest line number
Browse files Browse the repository at this point in the history
  • Loading branch information
tbelaire authored and Nick Hamann committed May 29, 2015
1 parent 2d447e4 commit 110f08a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/libsyntax/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,12 +594,18 @@ fn highlight_lines(err: &mut EmitterWriter,
let display_line_infos = &lines.lines[..display_lines];
let display_line_strings = &line_strings[..display_lines];

// Calculate the widest number to format evenly and fix #11715
assert!(display_line_infos.len > 0);
let mut max_line_num = display_line_infos[display_line_infos.len() - 1].line_index + 1;
let mut digits = 0;
while max_line_num > 0 { max_line_num /= 10; digits += 1; }
// Print the offending lines
for (line_info, line) in display_line_infos.iter().zip(display_line_strings.iter()) {
try!(write!(&mut err.dst, "{}:{} {}\n",
try!(write!(&mut err.dst, "{}:{:>width$} {}\n",
fm.name,
line_info.line_index + 1,
line));
line,
width=digits));
}

// If we elided something, put an ellipsis.
Expand Down

0 comments on commit 110f08a

Please sign in to comment.