Skip to content

Commit 732cc52

Browse files
committed
Auto merge of #7294 - SnejUgal:fix-inconsistent-coloring, r=alexcrichton
Fix `error:`/`warning:` coloring inconsistency with rustc When `rustc` prints an error, the word `error` is red, but the colon after it is white (and the same goes for `warn`, `note` and other messages). `cargo`, however, colors the colon as well, and it [looks inconsistent](https://user-images.githubusercontent.com/10610844/63640674-45040f00-c6cd-11e9-9ee9-6f6f44a51f83.png) when `rustc`'s output is followed by `cargo`'s side-by-side. If `cargo` prints the colon in white, the output [looks more accurate](https://user-images.githubusercontent.com/10610844/63640792-f2c3ed80-c6ce-11e9-9b6e-ba209a4f9788.png).
2 parents 475a23e + dd653eb commit 732cc52

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/cargo/core/shell.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,14 @@ impl Shell {
210210
if self.needs_clear {
211211
self.err_erase_line();
212212
}
213-
self.err.print(&"error:", Some(&message), Red, false)
213+
self.err.print(&"error", Some(&message), Red, false)
214214
}
215215

216216
/// Prints an amber 'warning' message.
217217
pub fn warn<T: fmt::Display>(&mut self, message: T) -> CargoResult<()> {
218218
match self.verbosity {
219219
Verbosity::Quiet => Ok(()),
220-
_ => self.print(&"warning:", Some(&message), Yellow, false),
220+
_ => self.print(&"warning", Some(&message), Yellow, false),
221221
}
222222
}
223223

@@ -318,6 +318,8 @@ impl ShellOut {
318318
write!(stream, "{:>12}", status)?;
319319
} else {
320320
write!(stream, "{}", status)?;
321+
stream.set_color(ColorSpec::new().set_bold(true))?;
322+
write!(stream, ":")?;
321323
}
322324
stream.reset()?;
323325
match message {
@@ -329,7 +331,7 @@ impl ShellOut {
329331
if justified {
330332
write!(w, "{:>12}", status)?;
331333
} else {
332-
write!(w, "{}", status)?;
334+
write!(w, "{}:", status)?;
333335
}
334336
match message {
335337
Some(message) => writeln!(w, " {}", message)?,

0 commit comments

Comments
 (0)