Fix panic on ignored target dependency.

This commit is contained in:
Eric Huss 2023-01-04 18:44:51 -08:00
parent c446c2001a
commit fab135885c
2 changed files with 25 additions and 12 deletions

View file

@ -1861,8 +1861,7 @@ impl TomlManifest {
None,
&workspace_config,
&inherit_cell,
)
.unwrap();
)?;
if platform.build_dependencies.is_some() && platform.build_dependencies2.is_some() {
warn_on_deprecated("build-dependencies", name, "platform target", cx.warnings);
}
@ -1876,8 +1875,7 @@ impl TomlManifest {
Some(DepKind::Build),
&workspace_config,
&inherit_cell,
)
.unwrap();
)?;
if platform.dev_dependencies.is_some() && platform.dev_dependencies2.is_some() {
warn_on_deprecated("dev-dependencies", name, "platform target", cx.warnings);
}
@ -1891,8 +1889,7 @@ impl TomlManifest {
Some(DepKind::Development),
&workspace_config,
&inherit_cell,
)
.unwrap();
)?;
target.insert(
name.clone(),
TomlPlatform {

View file

@ -1141,16 +1141,32 @@ fn ignored_git_revision() {
.file("src/lib.rs", "")
.build();
foo.cargo("build -v")
.with_status(101)
.with_stderr(
"\
let err_msg = "\
error: failed to parse manifest at `[..]`
Caused by:
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();
}