Skip to content

Commit bdb0ce8

Browse files
committed
Don't suppress error messages with -q
If we're printing an error, make sure we always print it regardless of verbosity settings!
1 parent bee0487 commit bdb0ce8

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

src/cargo/core/shell.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,10 @@ impl Shell {
207207

208208
/// Prints a red 'error' message.
209209
pub fn error<T: fmt::Display>(&mut self, message: T) -> CargoResult<()> {
210-
self.print(&"error:", Some(&message), Red, false)
210+
if self.needs_clear {
211+
self.err_erase_line();
212+
}
213+
self.err.print(&"error:", Some(&message), Red, false)
211214
}
212215

213216
/// Prints an amber 'warning' message.

tests/testsuite/workspaces.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2137,3 +2137,39 @@ fn ws_warn_path() {
21372137
.with_stderr_contains("[WARNING] [..]/foo/a/Cargo.toml: the cargo feature `edition`[..]")
21382138
.run();
21392139
}
2140+
2141+
#[cargo_test]
2142+
fn invalid_missing() {
2143+
// Warnings include path to manifest.
2144+
let p = project()
2145+
.file(
2146+
"Cargo.toml",
2147+
r#"
2148+
[package]
2149+
name = "foo"
2150+
version = "0.1.0"
2151+
2152+
[dependencies]
2153+
x = { path = 'x' }
2154+
"#,
2155+
)
2156+
.file("src/lib.rs", "")
2157+
.build();
2158+
2159+
p.cargo("build -q")
2160+
.with_status(101)
2161+
.with_stderr(
2162+
"\
2163+
error: [..]
2164+
2165+
Caused by:
2166+
[..]
2167+
2168+
Caused by:
2169+
[..]
2170+
2171+
Caused by:
2172+
[..]",
2173+
)
2174+
.run();
2175+
}

0 commit comments

Comments
 (0)