diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index 5bd6f79fe48..e29a7ea6651 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -106,7 +106,7 @@ pub fn read_manifest( &mut errors, ) .map(EitherManifest::Real) - } else { + } else if resolved_toml.workspace.is_some() { to_virtual_manifest( contents, document, @@ -121,6 +121,8 @@ pub fn read_manifest( &mut errors, ) .map(EitherManifest::Virtual) + } else { + anyhow::bail!("manifest is missing either a `[package]` or a `[workspace]`") } })() .map_err(|err| { diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index 49eb60db0c2..6ac9b30de8a 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -398,7 +398,7 @@ fn cargo_compile_with_invalid_manifest() { [ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` Caused by: - virtual manifests must be configured with [workspace] + manifest is missing either a `[package]` or a `[workspace]` "#]]) .run(); diff --git a/tests/testsuite/metadata.rs b/tests/testsuite/metadata.rs index 315dcb427eb..3a53a1b9a18 100644 --- a/tests/testsuite/metadata.rs +++ b/tests/testsuite/metadata.rs @@ -1876,7 +1876,7 @@ fn cargo_metadata_with_invalid_manifest() { [ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` Caused by: - virtual manifests must be configured with [workspace] + manifest is missing either a `[package]` or a `[workspace]` "#]]) .run();