Skip to content

Commit

Permalink
Better error message when getting an empty dep table
Browse files Browse the repository at this point in the history
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
  • Loading branch information
Rustin170506 committed Apr 19, 2023
1 parent 7bf43f0 commit 7399c27
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/cargo/util/toml_mut/dependency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,13 @@ impl Dependency {
let src = WorkspaceSource::new();
src.into()
} else {
anyhow::bail!("Unrecognized dependency source for `{key}`");
let mut msg = format!("Unrecognized dependency source for `{key}`");
if table.is_empty() {
msg.push_str(
", expected a table with a `version`, `git`, `path`, or `workspace` key",
);
}
anyhow::bail!(msg);
};
let registry = if let Some(value) = table.get("registry") {
Some(
Expand Down

0 comments on commit 7399c27

Please sign in to comment.