Skip to content

Commit 83a7983

Browse files
committed
Auto merge of #10685 - Muscraft:cargo-add-workspace-source, r=epage
fix bugs with `workspace` key and `update_toml` ### Motivations and Context When working on an external subcommand to help with the switch to workspace inheritance, I found issues with the output `Cargo.toml` it was creating. When a `cargo_add::Dependency` would change its source to a `WorkspsaceSource`, `workspace = true` would not show up. This lead me to discover that the `default-features` key was not being removed when the `workspace` key was set. This fixes those issues but brought up questions about how to deal with removing keys and clearing conflicting fields in a `Dependency`. After talking with `@epage,` it was decided that this was the minimal set of changes to make while the changes to fix the other issues is workshopped. ### Changes - add `default-features` to the list of keys to remove when the source is a `WorkspaceSource` - insert a `workspace` key when the source is a `WorkspaceSource`
2 parents 7524ccd + ffc1053 commit 83a7983

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/cargo/ops/cargo_add/dependency.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,9 @@ impl Dependency {
539539
}
540540
}
541541
Some(Source::Workspace(_)) => {
542+
table.insert("workspace", toml_edit::value(true));
542543
table.set_dotted(true);
544+
key.fmt();
543545
for key in [
544546
"version",
545547
"registry",
@@ -550,6 +552,7 @@ impl Dependency {
550552
"tag",
551553
"rev",
552554
"package",
555+
"default-features",
553556
] {
554557
table.remove(key);
555558
}

0 commit comments

Comments
 (0)