-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit 2ccd950
committed
Auto merge of #11565 - Muscraft:rework-toml-dependency, r=weihanglo
refactor(toml): Move `TomlWorkspaceDependency` out of `TomlDependency`
**This should not be merged until after #11409**
In #11523 it was noted that you could use `{}.workspace = true` in `[patch.{}]`, but it would cause a panic. This panic was caused by an oversight on my part when implementing [workspace inheritance](https://github.com/rust-lang/rfcs/blob/master/text/2906-cargo-workspace-deduplicate.md). Before this PR any field that had the type `TomlDependency` could specify `{}.workspace = true` and `cargo` would allow it to be a `TomlWorkspaceDependency`. While it could be `TomlWorkspaceDependency` it would never be resolved since only:
> Dependencies in the `[dependencies]`, `[dev-dependencies]`, [`build-dependencies]`, and `[target."...".dependencies]` sections will support the ability to reference the `[workspace.dependencies]` definition of dependencies.[^1]
This PR makes it so that only those fields can pull from `[workspace.dependencies]`, while still sharing `TomlDependency` everywhere it is needed. It does this by making `MaybeWorkspace` generic over both `Defined` and `Workspace`, then moving `TomlWorkspaceDependency` out of `TomlDependency` and into a `MaybeWorkspace` that the correct fields can use.
[^1]: [rfc2906-new-dependency-directives](https://github.com/rust-lang/rfcs/blob/master/text/2906-cargo-workspace-deduplicate.md#new-dependency-directives)
Closes: #11523File tree
Expand file treeCollapse file tree
2 files changed
+287
-269
lines changedOpen diff view settings
Filter options
- src/cargo/util/toml
- tests/testsuite
Expand file treeCollapse file tree
2 files changed
+287
-269
lines changedOpen diff view settings
0 commit comments