Skip to content

Commit

Permalink
Add resolver to rewritten Cargo.toml if workspace sets it
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Apr 22, 2023
1 parent 27fbe97 commit 7fdc3d5
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/source_distribution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ fn rewrite_cargo_toml(
manifest_path.display()
))?;

let workspace_deps = workspace_manifest
.get("workspace")
let workspace = workspace_manifest.get("workspace");
let workspace_deps = workspace
.and_then(|x| x.get("dependencies"))
.and_then(|x| x.as_table_like());

Expand Down Expand Up @@ -94,8 +94,7 @@ fn rewrite_cargo_toml(

// Update workspace inherited metadata
if let Some(package) = document.get_mut("package").and_then(|x| x.as_table_mut()) {
let workspace_package = workspace_manifest
.get("workspace")
let workspace_package = workspace
.and_then(|x| x.get("package"))
.and_then(|x| x.as_table_like());
for key in WORKSPACE_INHERITABLE_FIELDS.iter().copied() {
Expand All @@ -111,6 +110,12 @@ fn rewrite_cargo_toml(
}
}
}

// Update resolver if workspace set one
if let Some(resolver) = workspace.and_then(|x| x.get("resolver")) {
package["resolver"] = resolver.clone();
rewritten = true;
}
}

if root_crate {
Expand Down

0 comments on commit 7fdc3d5

Please sign in to comment.