Skip to content

Commit 7399c27

Browse files
committed
Better error message when getting an empty dep table
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
1 parent 7bf43f0 commit 7399c27

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/cargo/util/toml_mut/dependency.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,13 @@ impl Dependency {
279279
let src = WorkspaceSource::new();
280280
src.into()
281281
} else {
282-
anyhow::bail!("Unrecognized dependency source for `{key}`");
282+
let mut msg = format!("Unrecognized dependency source for `{key}`");
283+
if table.is_empty() {
284+
msg.push_str(
285+
", expected a table with a `version`, `git`, `path`, or `workspace` key",
286+
);
287+
}
288+
anyhow::bail!(msg);
283289
};
284290
let registry = if let Some(value) = table.get("registry") {
285291
Some(

0 commit comments

Comments
 (0)