refactor(toml): Move TomlWorkspaceDependency out of TomlDependency#11565
refactor(toml): Move TomlWorkspaceDependency out of TomlDependency#11565bors merged 1 commit intorust-lang:masterfrom
TomlWorkspaceDependency out of TomlDependency#11565Conversation
|
r? @weihanglo (rustbot has picked a reviewer for you, use r? to override) |
|
☔ The latest upstream changes (presumably #11409) made this pull request unmergeable. Please resolve the merge conflicts. |
weihanglo
left a comment
There was a problem hiding this comment.
Looks good! Could you do a rebase, and also add more comments on new items?
| pub trait WorkspaceInherit { | ||
| fn inherit_toml_table(&self) -> &str; | ||
| fn workspace(&self) -> bool; |
There was a problem hiding this comment.
Could we have docs for this trait and methods?
|
|
||
| [workspace] | ||
| members = ["bar"] | ||
| members = [] |
There was a problem hiding this comment.
Why does it require a member "bar" before but not after?
There was a problem hiding this comment.
It used to fail before we would hit the below error below. It looks like it was an oversight on my part. It's removed so we can see the unused manifest key warning.
error: failed to parse manifest at `{}/cargo/target/tmp/cit/t4/foo/Cargo.toml`
Caused by:
cannot configure both `package.workspace` and `[workspace]`, only one can be specified
| .with_status(101) | ||
| .with_stderr( | ||
| "\ | ||
| [WARNING] [CWD]/Cargo.toml: dependency (bar) specified without providing a local path, Git repository, or version to use. This will be considered an error in future versions |
There was a problem hiding this comment.
These messages are a bit unclear, unfortunately. As a user, I usually fix a compilation failure starting from errors. However, the error is useless than unused manifest key warning. I don't know how to improve. Just point it out.
There was a problem hiding this comment.
I don't like this either, and I am hoping my next set of changes can help improve this. I am unsure how else to make it better
|
|
||
| #[derive(Deserialize, Serialize, Clone, Debug)] | ||
| #[serde(rename_all = "kebab-case")] | ||
| pub struct TomlWorkspaceDependency { |
There was a problem hiding this comment.
Side note: we may support artifact dependencies for workspace.
There was a problem hiding this comment.
What do you mean by this?
There was a problem hiding this comment.
Other fields for unstable feature artifact dependencies
[workspace.dependencies]
bar = { artifact = "cdylib", version = "1.0", lib = true, target = "wasm32-unknown-unknown" }There was a problem hiding this comment.
I can add those fields in if needed, but they weren't in there before I made these changes
ff524ff to
b753fcf
Compare
b753fcf to
712b327
Compare
weihanglo
left a comment
There was a problem hiding this comment.
Looks good. Thank you for the effort!
|
@bors r+ |
|
☀️ Test successful - checks-actions |
18 commits in 3c5af6bed9a1a243a693e8e22ee2486bd5b82a6c..e84a7928d93a31f284b497c214a2ece69b4d7719 2023-01-24 15:48:15 +0000 to 2023-01-31 22:18:09 +0000 - chore: Add autolabel for `Command-*` labels (rust-lang/cargo#11664) - Update cross test instructions for aarch64-apple-darwin (rust-lang/cargo#11663) - Make cargo install report needed features (rust-lang/cargo#11647) - docs(contrib): Remove out-of-date process step (rust-lang/cargo#11662) - Do not error for `auth-required: true` without `-Z sparse-registry` (rust-lang/cargo#11661) - Warn on commits to non-default branches. (rust-lang/cargo#11655) - Avoid saving the same future_incompat warning multiple times (rust-lang/cargo#11648) - Mention current default value in `publish.timeout` docs (rust-lang/cargo#11652) - Make cargo aware of dwp files. (rust-lang/cargo#11572) - Reduce target info rustc query calls (rust-lang/cargo#11633) - Bump to 0.70.0; update changelog (rust-lang/cargo#11640) - Enable sparse protocol in CI (rust-lang/cargo#11632) - Fix split-debuginfo support detection (rust-lang/cargo#11347) - refactor(toml): Move `TomlWorkspaceDependency` out of `TomlDependency` (rust-lang/cargo#11565) - book: describe how the current resolver sometimes duplicates deps (rust-lang/cargo#11604) - `cargo add` check `[dependencies]` order without considering the dotted item (rust-lang/cargo#11612) - Link CoC to www.rust-lang.org/conduct.html (rust-lang/cargo#11622) - Add more labels to triagebot (rust-lang/cargo#11621)
Update cargo 18 commits in 3c5af6bed9a1a243a693e8e22ee2486bd5b82a6c..e84a7928d93a31f284b497c214a2ece69b4d7719 2023-01-24 15:48:15 +0000 to 2023-01-31 22:18:09 +0000 - chore: Add autolabel for `Command-*` labels (rust-lang/cargo#11664) - Update cross test instructions for aarch64-apple-darwin (rust-lang/cargo#11663) - Make cargo install report needed features (rust-lang/cargo#11647) - docs(contrib): Remove out-of-date process step (rust-lang/cargo#11662) - Do not error for `auth-required: true` without `-Z sparse-registry` (rust-lang/cargo#11661) - Warn on commits to non-default branches. (rust-lang/cargo#11655) - Avoid saving the same future_incompat warning multiple times (rust-lang/cargo#11648) - Mention current default value in `publish.timeout` docs (rust-lang/cargo#11652) - Make cargo aware of dwp files. (rust-lang/cargo#11572) - Reduce target info rustc query calls (rust-lang/cargo#11633) - Bump to 0.70.0; update changelog (rust-lang/cargo#11640) - Enable sparse protocol in CI (rust-lang/cargo#11632) - Fix split-debuginfo support detection (rust-lang/cargo#11347) - refactor(toml): Move `TomlWorkspaceDependency` out of `TomlDependency` (rust-lang/cargo#11565) - book: describe how the current resolver sometimes duplicates deps (rust-lang/cargo#11604) - `cargo add` check `[dependencies]` order without considering the dotted item (rust-lang/cargo#11612) - Link CoC to www.rust-lang.org/conduct.html (rust-lang/cargo#11622) - Add more labels to triagebot (rust-lang/cargo#11621) r? `@ghost`
Update cargo 18 commits in 3c5af6bed9a1a243a693e8e22ee2486bd5b82a6c..e84a7928d93a31f284b497c214a2ece69b4d7719 2023-01-24 15:48:15 +0000 to 2023-01-31 22:18:09 +0000 - chore: Add autolabel for `Command-*` labels (rust-lang/cargo#11664) - Update cross test instructions for aarch64-apple-darwin (rust-lang/cargo#11663) - Make cargo install report needed features (rust-lang/cargo#11647) - docs(contrib): Remove out-of-date process step (rust-lang/cargo#11662) - Do not error for `auth-required: true` without `-Z sparse-registry` (rust-lang/cargo#11661) - Warn on commits to non-default branches. (rust-lang/cargo#11655) - Avoid saving the same future_incompat warning multiple times (rust-lang/cargo#11648) - Mention current default value in `publish.timeout` docs (rust-lang/cargo#11652) - Make cargo aware of dwp files. (rust-lang/cargo#11572) - Reduce target info rustc query calls (rust-lang/cargo#11633) - Bump to 0.70.0; update changelog (rust-lang/cargo#11640) - Enable sparse protocol in CI (rust-lang/cargo#11632) - Fix split-debuginfo support detection (rust-lang/cargo#11347) - refactor(toml): Move `TomlWorkspaceDependency` out of `TomlDependency` (rust-lang/cargo#11565) - book: describe how the current resolver sometimes duplicates deps (rust-lang/cargo#11604) - `cargo add` check `[dependencies]` order without considering the dotted item (rust-lang/cargo#11612) - Link CoC to www.rust-lang.org/conduct.html (rust-lang/cargo#11622) - Add more labels to triagebot (rust-lang/cargo#11621) r? `@ghost`
This should not be merged until after #11409
In #11523 it was noted that you could use
{}.workspace = truein[patch.{}], but it would cause a panic. This panic was caused by an oversight on my part when implementing workspace inheritance. Before this PR any field that had the typeTomlDependencycould specify{}.workspace = trueandcargowould allow it to be aTomlWorkspaceDependency. While it could beTomlWorkspaceDependencyit would never be resolved since only:This PR makes it so that only those fields can pull from
[workspace.dependencies], while still sharingTomlDependencyeverywhere it is needed. It does this by makingMaybeWorkspacegeneric over bothDefinedandWorkspace, then movingTomlWorkspaceDependencyout ofTomlDependencyand into aMaybeWorkspacethat the correct fields can use.Closes: #11523
Footnotes
rfc2906-new-dependency-directives ↩