Skip to content

Commit

Permalink
Support workspace deps in the root crate of a workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
Waridley committed Dec 16, 2023
1 parent 555274d commit 2f4e243
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand All @@ -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<BTreeMap<String, String>, Error> {
Ok(workspace_dep_tables(&workspace_toml)
.into_iter()
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 2f4e243

Please sign in to comment.