From 2f4e243d87eaa4c102812a67aef7a2fb16dd3d64 Mon Sep 17 00:00:00 2001 From: Waridley Date: Fri, 15 Dec 2023 21:03:20 -0600 Subject: [PATCH] Support workspace deps in the root crate of a workspace --- src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index e4e0043..3ecb7bc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -269,9 +269,9 @@ fn read_cargo_toml( let workspace_dependencies = if manifest_path != workspace_manifest_path { let workspace_manifest = open_cargo_toml(workspace_manifest_path)?; - extract_workspace_dependencies(workspace_manifest)? + extract_workspace_dependencies(&workspace_manifest)? } else { - Default::default() + extract_workspace_dependencies(&manifest)? }; let crate_names = extract_crate_names(&manifest, workspace_dependencies)?; @@ -289,7 +289,7 @@ fn read_cargo_toml( /// Returns a hash map that maps from dep name to the package name. Dep name /// and package name can be the same if there doesn't exist any rename. fn extract_workspace_dependencies( - workspace_toml: Document, + workspace_toml: &Document, ) -> Result, Error> { Ok(workspace_dep_tables(&workspace_toml) .into_iter() @@ -352,7 +352,7 @@ fn extract_crate_names( let workspace = dep_value.get("workspace").and_then(|w| w.as_bool()).unwrap_or_default(); let pkg_name = workspace - .then(|| workspace_dependencies.get(pkg_name).map(|p| p.as_ref())) + .then(|| workspace_dependencies.get(dep_name).map(|p| p.as_ref())) .flatten() .unwrap_or(pkg_name);