diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index 020b08d2ac5..ce08e8c3021 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -1672,14 +1672,11 @@ fn detailed_dep_to_dependency( kind: Option, ) -> CargoResult { if orig.version.is_none() && orig.path.is_none() && orig.git.is_none() { - let msg = format!( - "dependency ({}) specified without \ + anyhow::bail!( + "dependency ({name_in_toml}) specified without \ providing a local path, Git repository, version, or \ - workspace dependency to use. This will be considered an \ - error in future versions", - name_in_toml + workspace dependency to use" ); - manifest_ctx.warnings.push(msg); } if let Some(version) = &orig.version { diff --git a/tests/testsuite/bad_config.rs b/tests/testsuite/bad_config.rs index f2e8a1d9768..cbd216491e7 100644 --- a/tests/testsuite/bad_config.rs +++ b/tests/testsuite/bad_config.rs @@ -792,10 +792,13 @@ fn empty_dependencies() { Package::new("bar", "0.0.1").publish(); p.cargo("check") - .with_stderr_contains( + .with_status(101) + .with_stderr( "\ -warning: dependency (bar) specified without providing a local path, Git repository, version, \ -or workspace dependency to use. This will be considered an error in future versions +[ERROR] failed to parse manifest at `[CWD]/Cargo.toml` + +Caused by: + dependency (bar) specified without providing a local path, Git repository, version, or workspace dependency to use ", ) .run(); diff --git a/tests/testsuite/cargo_add/empty_dep_table/in/Cargo.toml b/tests/testsuite/cargo_add/empty_dep_table/in/Cargo.toml deleted file mode 100644 index f6ecdafb72e..00000000000 --- a/tests/testsuite/cargo_add/empty_dep_table/in/Cargo.toml +++ /dev/null @@ -1,9 +0,0 @@ -[workspace] - -[package] -name = "cargo-list-test-fixture" -version = "0.0.0" -edition = "2015" - -[dependencies] -your-face = { } diff --git a/tests/testsuite/cargo_add/empty_dep_table/in/src/lib.rs b/tests/testsuite/cargo_add/empty_dep_table/in/src/lib.rs deleted file mode 100644 index 8b137891791..00000000000 --- a/tests/testsuite/cargo_add/empty_dep_table/in/src/lib.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/tests/testsuite/cargo_add/empty_dep_table/mod.rs b/tests/testsuite/cargo_add/empty_dep_table/mod.rs deleted file mode 100644 index 3f4fff3dc44..00000000000 --- a/tests/testsuite/cargo_add/empty_dep_table/mod.rs +++ /dev/null @@ -1,32 +0,0 @@ -use cargo_test_support::compare::assert_ui; -use cargo_test_support::current_dir; -use cargo_test_support::file; -use cargo_test_support::prelude::*; -use cargo_test_support::str; -use cargo_test_support::Project; - -#[cargo_test] -fn case() { - cargo_test_support::registry::init(); - cargo_test_support::registry::Package::new("your-face", "99999.0.0+my-package") - .feature("nose", &[]) - .feature("mouth", &[]) - .feature("eyes", &[]) - .feature("ears", &[]) - .publish(); - - let project = Project::from_template(current_dir!().join("in")); - let project_root = project.root(); - let cwd = &project_root; - - snapbox::cmd::Command::cargo_ui() - .arg("add") - .arg_line("your-face --features eyes") - .current_dir(cwd) - .assert() - .code(101) - .stdout_matches(str![""]) - .stderr_matches(file!["stderr.term.svg"]); - - assert_ui().subset_matches(current_dir!().join("out"), &project_root); -} diff --git a/tests/testsuite/cargo_add/empty_dep_table/out/Cargo.toml b/tests/testsuite/cargo_add/empty_dep_table/out/Cargo.toml deleted file mode 100644 index f6ecdafb72e..00000000000 --- a/tests/testsuite/cargo_add/empty_dep_table/out/Cargo.toml +++ /dev/null @@ -1,9 +0,0 @@ -[workspace] - -[package] -name = "cargo-list-test-fixture" -version = "0.0.0" -edition = "2015" - -[dependencies] -your-face = { } diff --git a/tests/testsuite/cargo_add/empty_dep_table/stderr.term.svg b/tests/testsuite/cargo_add/empty_dep_table/stderr.term.svg deleted file mode 100644 index 6b077ea4366..00000000000 --- a/tests/testsuite/cargo_add/empty_dep_table/stderr.term.svg +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - error: unrecognized dependency source for `your-face`, expected a local path, Git repository, version, or workspace dependency to be specified - - - - - - diff --git a/tests/testsuite/cargo_add/mod.rs b/tests/testsuite/cargo_add/mod.rs index 4cfd1e0b4af..62feb8422c8 100644 --- a/tests/testsuite/cargo_add/mod.rs +++ b/tests/testsuite/cargo_add/mod.rs @@ -20,7 +20,6 @@ mod dev_build_conflict; mod dev_prefer_existing_version; mod dry_run; mod empty_dep_name; -mod empty_dep_table; mod features; mod features_activated_over_limit; mod features_deactivated_over_limit; diff --git a/tests/testsuite/inheritable_workspace_fields.rs b/tests/testsuite/inheritable_workspace_fields.rs index 035690a69a0..b733000a856 100644 --- a/tests/testsuite/inheritable_workspace_fields.rs +++ b/tests/testsuite/inheritable_workspace_fields.rs @@ -1300,14 +1300,10 @@ fn error_workspace_dependency_looked_for_workspace_itself() { .with_status(101) .with_stderr( "\ -[WARNING] [CWD]/Cargo.toml: unused manifest key: workspace.dependencies.dep.workspace -[WARNING] [CWD]/Cargo.toml: dependency (dep) specified without providing a local path, Git repository, version, \ -or workspace dependency to use. \ -This will be considered an error in future versions -[UPDATING] `dummy-registry` index -[ERROR] no matching package named `dep` found -location searched: registry `crates-io` -required by package `bar v1.2.3 ([CWD])` +[ERROR] failed to parse manifest at `[CWD]/Cargo.toml` + +Caused by: + dependency (dep) specified without providing a local path, Git repository, version, or workspace dependency to use ", ) .run(); @@ -1627,15 +1623,10 @@ fn cannot_inherit_in_patch() { .with_status(101) .with_stderr( "\ -[WARNING] [CWD]/Cargo.toml: unused manifest key: patch.crates-io.bar.workspace -[WARNING] [CWD]/Cargo.toml: dependency (bar) specified without providing a local path, Git repository, version, \ -or workspace dependency to use. \ -This will be considered an error in future versions -[UPDATING] `dummy-registry` index -[ERROR] failed to resolve patches for `https://github.com/rust-lang/crates.io-index` +[ERROR] failed to parse manifest at `[CWD]/Cargo.toml` Caused by: - patch for `bar` in `https://github.com/rust-lang/crates.io-index` points to the same source, but patches must point to different sources + dependency (bar) specified without providing a local path, Git repository, version, or workspace dependency to use ", ) .run();