Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(toml): Improve error on missing package and workspace #14261

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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| {
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down