From 5c660708038c7998fe852980864b758f27e2cbe4 Mon Sep 17 00:00:00 2001 From: hi-rustin Date: Wed, 14 Jul 2021 14:09:45 +0800 Subject: [PATCH] When a dependency does not have a version, git or path, fails directly Signed-off-by: hi-rustin --- src/cargo/util/toml/mod.rs | 7 ++----- tests/testsuite/bad_config.rs | 10 +++++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index dc0e61b7a71..1c95e50fa89 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -1707,14 +1707,11 @@ impl DetailedTomlDependency

{ kind: Option, ) -> CargoResult { if self.version.is_none() && self.path.is_none() && self.git.is_none() { - let msg = format!( + bail!( "dependency ({}) specified without \ - providing a local path, Git repository, or \ - version to use. This will be considered an \ - error in future versions", + providing a local path, Git repository, or version to use.", name_in_toml ); - cx.warnings.push(msg); } if let Some(version) = &self.version { diff --git a/tests/testsuite/bad_config.rs b/tests/testsuite/bad_config.rs index be242bff22b..c9a2f6e11c6 100644 --- a/tests/testsuite/bad_config.rs +++ b/tests/testsuite/bad_config.rs @@ -796,10 +796,14 @@ fn empty_dependencies() { Package::new("bar", "0.0.1").publish(); p.cargo("build") - .with_stderr_contains( + .with_status(101) + .with_stderr( "\ -warning: dependency (bar) specified without providing a local path, Git repository, or version \ -to use. This will be considered an error in future versions +[ERROR] failed to parse manifest at `[..]` + +Caused by: + dependency (bar) specified without providing a local path, Git repository, or version \ +to use. ", ) .run();