Skip to content

Commit 913d4b8

Browse files
committed
Auto merge of #14261 - epage:error, r=weihanglo
fix(toml): Improve error on missing package and workspace That the error was confused was brought up in #13904
2 parents b33a9b2 + 0ccafca commit 913d4b8

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/cargo/util/toml/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ pub fn read_manifest(
106106
&mut errors,
107107
)
108108
.map(EitherManifest::Real)
109-
} else {
109+
} else if resolved_toml.workspace.is_some() {
110110
to_virtual_manifest(
111111
contents,
112112
document,
@@ -121,6 +121,8 @@ pub fn read_manifest(
121121
&mut errors,
122122
)
123123
.map(EitherManifest::Virtual)
124+
} else {
125+
anyhow::bail!("manifest is missing either a `[package]` or a `[workspace]`")
124126
}
125127
})()
126128
.map_err(|err| {

tests/testsuite/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ fn cargo_compile_with_invalid_manifest() {
398398
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
399399
400400
Caused by:
401-
virtual manifests must be configured with [workspace]
401+
manifest is missing either a `[package]` or a `[workspace]`
402402
403403
"#]])
404404
.run();

tests/testsuite/metadata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1876,7 +1876,7 @@ fn cargo_metadata_with_invalid_manifest() {
18761876
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
18771877
18781878
Caused by:
1879-
virtual manifests must be configured with [workspace]
1879+
manifest is missing either a `[package]` or a `[workspace]`
18801880
18811881
"#]])
18821882
.run();

0 commit comments

Comments
 (0)