-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatically inherit workspace fields when running cargo new
#10870
Comments
Hi, just to make sure I understand this issue before possibly tackling it: I have a top level workspace 'my-workspace' which has this in its Cargo.toml:
I then run
Of course, assuming we have the workspace inheritence feature enabled. |
Yes We have to make sure fields like I have a slight preference for the order of the fields in
I'd just wait until #10859 is merged. We are halfway done with the FCP which is blocking the stablization |
Thank you for the information. I will be trying to do it while waiting for the merge, as a way to dig into the cargo codebase. I will keep your concerns/preferences in mind, it should make for a fun learning experience! |
Tips
|
To load the workspace, I was looking here: https://github.com/rust-lang/cargo/blob/master/src/cargo/ops/cargo_new.rs#L844-L851 It seemed to me like this would be the correct place: If the result is not an Err, we have a proper workspace and can go from there to get InheritedFields and then write them into the newly created Cargo.toml Again, thank you for the advice :) |
Why did it open again? |
@rustbot claim |
Just to be clear, will this only be done if the |
For now, yes. #6378 is for adding it to the workspace. glob support I think is common enough to not block one of these on the other. |
Problem
When I create a new workspace,
cargo new
populates some fields but leaves me to fill in the rest. If I run it within a workspace withworkspace.package
fields set, I most likely intend to inherit those in this new crate as well.Proposed Solution
When
cargo new
is run, search up for a possible workspace. If one is found, check whichworkspace.package
fields are set and then in the new package, set those fields to<field>.workspace = true
.Notes
See #10859
I don't think this is blocked on #6378 because
cargo new
in a workspace that uses globs inmembers
will automatically pick up the new crate and doesn't need #6378 to take advantage of this.The text was updated successfully, but these errors were encountered: