mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-27 07:03:45 +00:00
Don't apologise if its not our fault in warnings
This commit is contained in:
parent
e4a6f96d70
commit
9ab1587a98
30
src/lib.rs
30
src/lib.rs
@ -125,13 +125,13 @@ impl fmt::Display for ErrorKind {
|
||||
match *self {
|
||||
ErrorKind::LineOverflow => {
|
||||
write!(fmt, "line exceeded maximum length")
|
||||
},
|
||||
}
|
||||
ErrorKind::TrailingWhitespace => {
|
||||
write!(fmt, "left behind trailing whitespace")
|
||||
},
|
||||
}
|
||||
ErrorKind::BadIssue(issue) => {
|
||||
write!(fmt, "found {}", issue)
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -142,6 +142,24 @@ struct FormattingError {
|
||||
kind: ErrorKind,
|
||||
}
|
||||
|
||||
impl FormattingError {
|
||||
fn msg_prefix(&self) -> &str {
|
||||
match self.kind {
|
||||
ErrorKind::LineOverflow |
|
||||
ErrorKind::TrailingWhitespace => "Rustfmt failed at",
|
||||
ErrorKind::BadIssue(_) => "WARNING:",
|
||||
}
|
||||
}
|
||||
|
||||
fn msg_suffix(&self) -> &str {
|
||||
match self.kind {
|
||||
ErrorKind::LineOverflow |
|
||||
ErrorKind::TrailingWhitespace => "(sorry)",
|
||||
ErrorKind::BadIssue(_) => "",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct FormatReport {
|
||||
// Maps stringified file paths to their associated formatting errors
|
||||
file_error_map: HashMap<String, Vec<FormattingError>>,
|
||||
@ -153,10 +171,12 @@ impl fmt::Display for FormatReport {
|
||||
for (file, errors) in self.file_error_map.iter() {
|
||||
for error in errors {
|
||||
try!(write!(fmt,
|
||||
"Rustfmt failed at {}:{}: {} (sorry)\n",
|
||||
"{} {}:{}: {} {}\n",
|
||||
error.msg_prefix(),
|
||||
file,
|
||||
error.line,
|
||||
error.kind));
|
||||
error.kind,
|
||||
error.msg_suffix()));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
Loading…
Reference in New Issue
Block a user