Skip to content

Commit

Permalink
fix(toml): Improve error on missing package and workspace
Browse files Browse the repository at this point in the history
That the error was confused was brought up in #13904
  • Loading branch information
epage committed Jul 17, 2024
1 parent a2d45dc commit 0ccafca
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
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

0 comments on commit 0ccafca

Please sign in to comment.