Skip to content

Commit

Permalink
Auto merge of #14261 - epage:error, r=weihanglo
Browse files Browse the repository at this point in the history
fix(toml): Improve error on missing package and workspace

That the error was confused was brought up in #13904
  • Loading branch information
bors committed Jul 17, 2024
2 parents b33a9b2 + 0ccafca commit 913d4b8
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 913d4b8

Please sign in to comment.