mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-25 11:14:46 +00:00
Fixing issue https://github.com/rust-lang/cargo/issues/10834:
- Adding display of which target failed to compile - Consistent messages for warnings/errors. - Fixing assertions on related tests.
This commit is contained in:
parent
12dbca319e
commit
db457d950f
@ -134,6 +134,7 @@ pub use self::job_state::JobState;
|
||||
use super::context::OutputFile;
|
||||
use super::timings::Timings;
|
||||
use super::{BuildContext, BuildPlan, CompileMode, Context, Unit};
|
||||
use crate::core::compiler::descriptive_pkg_name;
|
||||
use crate::core::compiler::future_incompat::{
|
||||
self, FutureBreakageItem, FutureIncompatReportPackage,
|
||||
};
|
||||
@ -1000,15 +1001,8 @@ impl<'cfg> DrainState<'cfg> {
|
||||
None | Some(_) => return,
|
||||
};
|
||||
let unit = &self.active[&id];
|
||||
let mut message = format!("`{}` ({}", unit.pkg.name(), unit.target.description_named());
|
||||
if unit.mode.is_rustc_test() && !(unit.target.is_test() || unit.target.is_bench()) {
|
||||
message.push_str(" test");
|
||||
} else if unit.mode.is_doc_test() {
|
||||
message.push_str(" doctest");
|
||||
} else if unit.mode.is_doc() {
|
||||
message.push_str(" doc");
|
||||
}
|
||||
message.push_str(") generated ");
|
||||
let mut message = descriptive_pkg_name(&unit.pkg.name(), &unit.target, &unit.mode);
|
||||
message.push_str(" generated ");
|
||||
match count.total {
|
||||
1 => message.push_str("1 warning"),
|
||||
n => drop(write!(message, "{} warnings", n)),
|
||||
|
@ -467,7 +467,8 @@ fn rustc(cx: &mut Context<'_, '_>, unit: &Unit, exec: &Arc<dyn Executor>) -> Car
|
||||
1 => " due to previous error".to_string(),
|
||||
count => format!(" due to {} previous errors", count),
|
||||
};
|
||||
format!("could not compile `{}`{}{}", name, errors, warnings)
|
||||
let name = descriptive_pkg_name(&name, &target, &mode);
|
||||
format!("could not compile {name}{errors}{warnings}")
|
||||
});
|
||||
|
||||
if let Err(e) = result {
|
||||
@ -1776,3 +1777,19 @@ fn replay_output_cache(
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
/// Provides a package name with descriptive target information,
|
||||
/// e.g., '`foo` (bin "bar" test)', '`foo` (lib doctest)'.
|
||||
fn descriptive_pkg_name(name: &str, target: &Target, mode: &CompileMode) -> String {
|
||||
let desc_name = target.description_named();
|
||||
let mode = if mode.is_rustc_test() && !(target.is_test() || target.is_bench()) {
|
||||
" test"
|
||||
} else if mode.is_doc_test() {
|
||||
" doctest"
|
||||
} else if mode.is_doc() {
|
||||
" doc"
|
||||
} else {
|
||||
""
|
||||
};
|
||||
format!("`{name}` ({desc_name}{mode})")
|
||||
}
|
||||
|
@ -639,7 +639,9 @@ fn cargo_compile_with_invalid_code() {
|
||||
|
||||
p.cargo("build")
|
||||
.with_status(101)
|
||||
.with_stderr_contains("[ERROR] could not compile `foo` due to previous error\n")
|
||||
.with_stderr_contains(
|
||||
"[ERROR] could not compile `foo` (bin \"foo\") due to previous error\n",
|
||||
)
|
||||
.run();
|
||||
assert!(p.root().join("Cargo.lock").is_file());
|
||||
}
|
||||
@ -5699,7 +5701,7 @@ fn signal_display() {
|
||||
"\
|
||||
[COMPILING] pm [..]
|
||||
[COMPILING] foo [..]
|
||||
[ERROR] could not compile `foo`
|
||||
[ERROR] could not compile `foo` [..]
|
||||
|
||||
Caused by:
|
||||
process didn't exit successfully: `rustc [..]` (signal: 6, SIGABRT: process abort signal)
|
||||
|
@ -1678,7 +1678,7 @@ fn build_deps_not_for_normal() {
|
||||
.with_stderr_contains("[..]can't find crate for `aaaaa`[..]")
|
||||
.with_stderr_contains(
|
||||
"\
|
||||
[ERROR] could not compile `foo` due to previous error
|
||||
[ERROR] could not compile `foo` (lib) due to previous error
|
||||
|
||||
Caused by:
|
||||
process didn't exit successfully: [..]
|
||||
|
@ -804,7 +804,7 @@ fn short_message_format() {
|
||||
.with_stderr_contains(
|
||||
"\
|
||||
src/lib.rs:1:27: error[E0308]: mismatched types
|
||||
error: could not compile `foo` due to previous error
|
||||
error: could not compile `foo` (lib) due to previous error
|
||||
",
|
||||
)
|
||||
.run();
|
||||
@ -1251,7 +1251,7 @@ fn check_fixable_error_no_fix() {
|
||||
[CHECKING] foo v0.0.1 ([..])
|
||||
{}\
|
||||
[WARNING] `foo` (lib) generated 1 warning
|
||||
[ERROR] could not compile `foo` due to previous error; 1 warning emitted
|
||||
[ERROR] could not compile `foo` (lib) due to previous error; 1 warning emitted
|
||||
",
|
||||
rustc_message
|
||||
);
|
||||
|
@ -29,7 +29,7 @@ fn do_not_fix_broken_builds() {
|
||||
p.cargo("fix --allow-no-vcs")
|
||||
.env("__CARGO_FIX_YOLO", "1")
|
||||
.with_status(101)
|
||||
.with_stderr_contains("[ERROR] could not compile `foo` due to previous error")
|
||||
.with_stderr_contains("[ERROR] could not compile `foo` (lib) due to previous error")
|
||||
.run();
|
||||
assert!(p.read_file("src/lib.rs").contains("let mut x = 3;"));
|
||||
}
|
||||
|
@ -881,7 +881,7 @@ fn compile_failure() {
|
||||
.with_status(101)
|
||||
.with_stderr_contains(
|
||||
"\
|
||||
[ERROR] could not compile `foo` due to previous error
|
||||
[ERROR] could not compile `foo` (bin \"foo\") due to previous error
|
||||
[ERROR] failed to compile `foo v0.0.1 ([..])`, intermediate artifacts can be \
|
||||
found at `[..]target`
|
||||
",
|
||||
|
@ -136,7 +136,7 @@ fn deduplicate_errors() {
|
||||
.with_stderr(&format!(
|
||||
"\
|
||||
[COMPILING] foo v0.0.1 [..]
|
||||
{}error: could not compile `foo` due to previous error
|
||||
{}error: could not compile `foo` (lib) due to previous error
|
||||
",
|
||||
rustc_message
|
||||
))
|
||||
|
Loading…
x
Reference in New Issue
Block a user