-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Style changes to compiler messages #29989
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -293,8 +293,8 @@ impl fmt::Display for Level { | |
|
||
match *self { | ||
Bug => "error: internal compiler error".fmt(f), | ||
Fatal | Error => "error".fmt(f), | ||
Warning => "warning".fmt(f), | ||
Fatal | Error => "\n error".fmt(f), | ||
Warning => "\n warning".fmt(f), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've put this here only for a preview. If we're gonna avoid the file path (in a similar fashion) for the other messages too, then we can put it directly into the function. But, if we're going for relative paths, then this won't look nice, and this should be reverted back. So, what's the plan? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I really like the relative paths because printing the full path leaks paths that don't exist, ie, to the buildbot that the stdlib was built on. This is annoying both because it is a nonexistant path, but because it includes "slave", which is really awkward. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed! I'm happy about relative paths :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One slight issue with relative paths is that when cargo spits out errors for multiple deps it's confusing which dep is being talked about. Though I'm not sure if this will still be an issue. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like absolute paths when building locally - I know I can always copy and paste and it will work - with relative paths I have to be in the right place, which with a complex build system doesn't always happen. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Also, I think the |
||
Note => "note".fmt(f), | ||
Help => "help".fmt(f), | ||
} | ||
|
@@ -550,32 +550,17 @@ impl EmitterWriter { | |
// Display only the first MAX_LINES lines. | ||
let all_lines = lines.lines.len(); | ||
let display_lines = cmp::min(all_lines, MAX_LINES); | ||
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; | ||
} | ||
|
||
assert!(display_line_strings.len() > 0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since our idea is to drop displaying file paths for the latter part of the span, we'd be reverting the patches made for #11715 and some of its sub-issues. Is that okay? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'll be preserving the old behavior via a command line flag, so this stays in the old-behavior method? |
||
// Print the offending lines | ||
for (line_info, line) in display_line_infos.iter().zip(display_line_strings) { | ||
try!(write!(&mut self.dst, "{}:{:>width$} {}\n", | ||
fm.name, | ||
line_info.line_index + 1, | ||
line, | ||
width=digits)); | ||
for line in display_line_strings { | ||
try!(write!(&mut self.dst, " {}\n", line)); | ||
} | ||
|
||
// If we elided something, put an ellipsis. | ||
if display_lines < all_lines { | ||
let last_line_index = display_line_infos.last().unwrap().line_index; | ||
let s = format!("{}:{} ", fm.name, last_line_index + 1); | ||
try!(write!(&mut self.dst, "{0:1$}...\n", "", s.len())); | ||
try!(write!(&mut self.dst, " ...\n")); | ||
} | ||
|
||
// FIXME (#3260) | ||
|
@@ -591,7 +576,7 @@ impl EmitterWriter { | |
let mut s = String::new(); | ||
// Skip is the number of characters we need to skip because they are | ||
// part of the 'filename:line ' part of the previous line. | ||
let skip = fm.name.chars().count() + digits + 3; | ||
let skip = digits + 4; | ||
for _ in 0..skip { | ||
s.push(' '); | ||
} | ||
|
@@ -608,7 +593,7 @@ impl EmitterWriter { | |
// position. | ||
match ch { | ||
'\t' => { | ||
col += 8 - col%8; | ||
col += 8 - col % 8; | ||
s.push('\t'); | ||
}, | ||
_ => { | ||
|
@@ -622,7 +607,7 @@ impl EmitterWriter { | |
let mut s = String::from("^"); | ||
let count = match lastc { | ||
// Most terminals have a tab stop every eight columns by default | ||
'\t' => 8 - col%8, | ||
'\t' => 8 - col % 8, | ||
_ => 1, | ||
}; | ||
col += count; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The space is added only to separate the span from the file name (for visibility).
The colon has been replaced with an arrow, because we already use it to separate the line number from the character number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the first space shouldn't be there. Many editors let you say
open foo.rs:1:2
on the command line and will open focused on that line. It's easier to copy-paste if there is no space.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not use
->
since we use it for function types/signatures. I'd useto
or...
or keep the: