+
+fn find_workspace_dep(toml_key: &str, root_manifest: &Path) -> CargoResult<Dependency> {
+ let manifest = LocalManifest::try_new(root_manifest)?;
+ let manifest = manifest
+ .data
+ .as_item()
+ .as_table_like()
+ .context("could not make `manifest.data` into a table")?;
+ let workspace = manifest
+ .get("workspace")
+ .context("could not find `workspace`")?
+ .as_table_like()
+ .context("could not make `manifest.data.workspace` into a table")?;
+ let dependencies = workspace
+ .get("dependencies")
+ .context("could not find `dependencies` table in `workspace`")?
+ .as_table_like()
+ .context("could not make `dependencies` into a table")?;
+ let dep_item = dependencies.get(toml_key).context(format!(
+ "could not find {} in `workspace.dependencies`",
+ toml_key
+ ))?;
+ Dependency::from_toml(root_manifest.parent().unwrap(), toml_key, dep_item)
+}