mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
Auto merge of #11541 - ehuss:fix-dep-unwrap, r=epage
Fix panic on target dependency errors. Errors while processing a target dependency would cause a panic due to some calls to `unwrap` in the TOML processing code. Those unwraps should not be there, and it should just propagate the errors upwards just like is done for normal dependencies. Fixes #11540
This commit is contained in:
commit
247b22f225
@ -1861,8 +1861,7 @@ impl TomlManifest {
|
|||||||
None,
|
None,
|
||||||
&workspace_config,
|
&workspace_config,
|
||||||
&inherit_cell,
|
&inherit_cell,
|
||||||
)
|
)?;
|
||||||
.unwrap();
|
|
||||||
if platform.build_dependencies.is_some() && platform.build_dependencies2.is_some() {
|
if platform.build_dependencies.is_some() && platform.build_dependencies2.is_some() {
|
||||||
warn_on_deprecated("build-dependencies", name, "platform target", cx.warnings);
|
warn_on_deprecated("build-dependencies", name, "platform target", cx.warnings);
|
||||||
}
|
}
|
||||||
@ -1876,8 +1875,7 @@ impl TomlManifest {
|
|||||||
Some(DepKind::Build),
|
Some(DepKind::Build),
|
||||||
&workspace_config,
|
&workspace_config,
|
||||||
&inherit_cell,
|
&inherit_cell,
|
||||||
)
|
)?;
|
||||||
.unwrap();
|
|
||||||
if platform.dev_dependencies.is_some() && platform.dev_dependencies2.is_some() {
|
if platform.dev_dependencies.is_some() && platform.dev_dependencies2.is_some() {
|
||||||
warn_on_deprecated("dev-dependencies", name, "platform target", cx.warnings);
|
warn_on_deprecated("dev-dependencies", name, "platform target", cx.warnings);
|
||||||
}
|
}
|
||||||
@ -1891,8 +1889,7 @@ impl TomlManifest {
|
|||||||
Some(DepKind::Development),
|
Some(DepKind::Development),
|
||||||
&workspace_config,
|
&workspace_config,
|
||||||
&inherit_cell,
|
&inherit_cell,
|
||||||
)
|
)?;
|
||||||
.unwrap();
|
|
||||||
target.insert(
|
target.insert(
|
||||||
name.clone(),
|
name.clone(),
|
||||||
TomlPlatform {
|
TomlPlatform {
|
||||||
|
@ -1141,16 +1141,32 @@ fn ignored_git_revision() {
|
|||||||
.file("src/lib.rs", "")
|
.file("src/lib.rs", "")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
foo.cargo("build -v")
|
let err_msg = "\
|
||||||
.with_status(101)
|
|
||||||
.with_stderr(
|
|
||||||
"\
|
|
||||||
error: failed to parse manifest at `[..]`
|
error: failed to parse manifest at `[..]`
|
||||||
|
|
||||||
Caused by:
|
Caused by:
|
||||||
key `branch` is ignored for dependency (bar).
|
key `branch` is ignored for dependency (bar).
|
||||||
",
|
";
|
||||||
)
|
foo.cargo("build -v")
|
||||||
|
.with_status(101)
|
||||||
|
.with_stderr(err_msg)
|
||||||
|
.run();
|
||||||
|
|
||||||
|
// #11540, check that [target] dependencies fail the same way.
|
||||||
|
foo.change_file(
|
||||||
|
"Cargo.toml",
|
||||||
|
r#"
|
||||||
|
[package]
|
||||||
|
name = "foo"
|
||||||
|
version = "0.0.0"
|
||||||
|
|
||||||
|
[target.some-target.dependencies]
|
||||||
|
bar = { path = "bar", branch = "spam" }
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
foo.cargo("build")
|
||||||
|
.with_status(101)
|
||||||
|
.with_stderr(err_msg)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user