Skip to content

Commit 430effa

Browse files
committed
Auto merge of #12484 - adrianEffe:fix/error-count, r=weihanglo
Fixes error count display is different when there's only one error left ### What does this PR try to resolve? When there's only 1 error left, the number 1 appears in the output so that it scans the same as the output when there's more than 1 error, so: ``` error: could not compile `crate` (lib test) due to 1 previous error ``` instead of the current: ``` error: could not compile `crate` (lib test) due to a previous error ``` Fixes #12390 rustc related PR [#114759](rust-lang/rust#114759)
2 parents 07f1208 + 3e297a6 commit 430effa

File tree

8 files changed

+9
-9
lines changed

8 files changed

+9
-9
lines changed

src/cargo/core/compiler/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ fn rustc(cx: &mut Context<'_, '_>, unit: &Unit, exec: &Arc<dyn Executor>) -> Car
422422
};
423423
let errors = match output_options.errors_seen {
424424
0 => String::new(),
425-
1 => " due to previous error".to_string(),
425+
1 => " due to 1 previous error".to_string(),
426426
count => format!(" due to {} previous errors", count),
427427
};
428428
let name = descriptive_pkg_name(&name, &target, &mode);

tests/testsuite/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ fn cargo_compile_with_invalid_code() {
760760
p.cargo("build")
761761
.with_status(101)
762762
.with_stderr_contains(
763-
"[ERROR] could not compile `foo` (bin \"foo\") due to previous error\n",
763+
"[ERROR] could not compile `foo` (bin \"foo\") due to 1 previous error\n",
764764
)
765765
.run();
766766
assert!(p.root().join("Cargo.lock").is_file());

tests/testsuite/build_script.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1716,7 +1716,7 @@ fn build_deps_not_for_normal() {
17161716
.with_stderr_contains("[..]can't find crate for `aaaaa`[..]")
17171717
.with_stderr_contains(
17181718
"\
1719-
[ERROR] could not compile `foo` (lib) due to previous error
1719+
[ERROR] could not compile `foo` (lib) due to 1 previous error
17201720
17211721
Caused by:
17221722
process didn't exit successfully: [..]

tests/testsuite/check.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ fn short_message_format() {
804804
.with_stderr_contains(
805805
"\
806806
src/lib.rs:1:27: error[E0308]: mismatched types
807-
error: could not compile `foo` (lib) due to previous error
807+
error: could not compile `foo` (lib) due to 1 previous error
808808
",
809809
)
810810
.run();
@@ -1250,7 +1250,7 @@ fn check_fixable_error_no_fix() {
12501250
[CHECKING] foo v0.0.1 ([..])
12511251
{}\
12521252
[WARNING] `foo` (lib) generated 1 warning
1253-
[ERROR] could not compile `foo` (lib) due to previous error; 1 warning emitted
1253+
[ERROR] could not compile `foo` (lib) due to 1 previous error; 1 warning emitted
12541254
",
12551255
rustc_message
12561256
);

tests/testsuite/fix.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn do_not_fix_broken_builds() {
2929
p.cargo("fix --allow-no-vcs")
3030
.env("__CARGO_FIX_YOLO", "1")
3131
.with_status(101)
32-
.with_stderr_contains("[ERROR] could not compile `foo` (lib) due to previous error")
32+
.with_stderr_contains("[ERROR] could not compile `foo` (lib) due to 1 previous error")
3333
.run();
3434
assert!(p.read_file("src/lib.rs").contains("let mut x = 3;"));
3535
}

tests/testsuite/install.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,7 @@ fn compile_failure() {
10101010
.with_status(101)
10111011
.with_stderr_contains(
10121012
"\
1013-
[ERROR] could not compile `foo` (bin \"foo\") due to previous error
1013+
[ERROR] could not compile `foo` (bin \"foo\") due to 1 previous error
10141014
[ERROR] failed to compile `foo v0.0.1 ([..])`, intermediate artifacts can be \
10151015
found at `[..]target`.\nTo reuse those artifacts with a future compilation, \
10161016
set the environment variable `CARGO_TARGET_DIR` to that path.

tests/testsuite/messages.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ fn deduplicate_errors() {
136136
.with_stderr(&format!(
137137
"\
138138
[COMPILING] foo v0.0.1 [..]
139-
{}error: could not compile `foo` (lib) due to previous error
139+
{}error: could not compile `foo` (lib) due to 1 previous error
140140
",
141141
rustc_message
142142
))

tests/testsuite/replace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1399,7 +1399,7 @@ fn override_respects_spec_metadata() {
13991399
[..]
14001400
[..]
14011401
[..]
1402-
error: could not compile `foo` (lib) due to previous error
1402+
error: could not compile `foo` (lib) due to 1 previous error
14031403
",
14041404
)
14051405
.with_status(101)

0 commit comments

Comments
 (0)