mirror of
https://github.com/rust-lang/cargo
synced 2024-08-25 10:35:53 +00:00
fix: more error context for missing dep of workspace member
This commit is contained in:
parent
832fff8dd1
commit
9c0d865389
|
@ -725,14 +725,15 @@ impl<'cfg> Workspace<'cfg> {
|
|||
self.member_ids.insert(pkg.package_id());
|
||||
pkg.dependencies()
|
||||
.iter()
|
||||
.map(|d| d.source_id())
|
||||
.filter(|d| d.is_path())
|
||||
.filter_map(|d| d.url().to_file_path().ok())
|
||||
.map(|p| p.join("Cargo.toml"))
|
||||
.map(|d| (d.source_id(), d.package_name()))
|
||||
.filter(|(s, _)| s.is_path())
|
||||
.filter_map(|(s, n)| s.url().to_file_path().ok().map(|p| (p, n)))
|
||||
.map(|(p, n)| (p.join("Cargo.toml"), n))
|
||||
.collect::<Vec<_>>()
|
||||
};
|
||||
for candidate in candidates {
|
||||
self.find_path_deps(&candidate, root_manifest, true)
|
||||
for (path, name) in candidates {
|
||||
self.find_path_deps(&path, root_manifest, true)
|
||||
.with_context(|| format!("failed to load manifest for dependency `{}`", name))
|
||||
.map_err(|err| ManifestError::new(err, manifest_path.clone()))?;
|
||||
}
|
||||
Ok(())
|
||||
|
|
|
@ -2324,6 +2324,55 @@ Caused by:
|
|||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn member_dep_missing() {
|
||||
// Make sure errors are not suppressed with -q.
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[project]
|
||||
name = "foo"
|
||||
version = "0.1.0"
|
||||
|
||||
[workspace]
|
||||
members = ["bar"]
|
||||
"#,
|
||||
)
|
||||
.file("src/main.rs", "fn main() {}")
|
||||
.file(
|
||||
"bar/Cargo.toml",
|
||||
r#"
|
||||
[project]
|
||||
name = "bar"
|
||||
version = "0.1.0"
|
||||
|
||||
[dependencies]
|
||||
baz = { path = "baz" }
|
||||
"#,
|
||||
)
|
||||
.file("bar/src/main.rs", "fn main() {}")
|
||||
.build();
|
||||
|
||||
p.cargo("build -q")
|
||||
.with_status(101)
|
||||
.with_stderr(
|
||||
"\
|
||||
[ERROR] failed to load manifest for workspace member `[..]/bar`
|
||||
|
||||
Caused by:
|
||||
failed to load manifest for dependency `baz`
|
||||
|
||||
Caused by:
|
||||
failed to read `[..]foo/bar/baz/Cargo.toml`
|
||||
|
||||
Caused by:
|
||||
[..]
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn simple_primary_package_env_var() {
|
||||
let is_primary_package = r#"
|
||||
|
|
Loading…
Reference in a new issue