-
Notifications
You must be signed in to change notification settings - Fork 0
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
Show the merged set of activated features to the user when inheriting… #1
Conversation
src/cargo/ops/cargo_add/mod.rs
Outdated
req_feats | ||
.difference(&available_features) | ||
.for_each(|unknown| unknown_features.push(unknown.to_string())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a unknown_features.extend(req_feats.different(...))
would b clearer than the for_each
approach
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you run into issues with &&str
not living long enough. You can transition things to String
but then you introduce .to_string()
and .clone()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try unknown_features.extend(req_feats.different(...).copied())
src/cargo/ops/cargo_add/mod.rs
Outdated
let mut workspace: IndexSet<_> = dep | ||
.inherited_features | ||
.iter() | ||
.flatten() | ||
.map(|s| s.as_str()) | ||
.filter(|s| !activated.contains(s)) | ||
.collect(); | ||
workspace.sort(); | ||
let mut deactivated = dep |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't recursively activate features.
Instead add this into activated
before we do the VecDeque
and the rest of the code should just work out
src/cargo/ops/cargo_add/mod.rs
Outdated
for feat in workspace { | ||
shell.write_stderr(&prefix, &ColorSpec::new())?; | ||
shell.write_stderr('+', &ColorSpec::new().set_bold(true).set_fg(Some(Green)))?; | ||
shell.write_stderr(format_args!(" {}\n", feat), &ColorSpec::new())?; | ||
} | ||
for feat in deactivated { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't sorting the workspace features in with the regular ones and will look confusing.
If you merge into the activated features, this shouldn't be needed anymore
[features] | ||
test = [] | ||
merge = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change this to
[features]
default-base = []
default-test-base = []
default-merge-base = []
default = ["default-base", "default-test-base", "default-merge-base"]
test-base = []
test = ["test-base", "default-test-base"]
merge-base = []
merge = ["merge-base", "default-merge-base"]
unrelated = []
This will
- Show we recursively activate all
- Don't duplicate activations
- Don't just enable everything :)
@@ -152,6 +155,13 @@ impl Dependency { | |||
self | |||
} | |||
|
|||
/// Set features as an array of string (does some basic parsing) | |||
#[allow(dead_code)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this dead_code
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe I just copied this from above. I'll remove it
… from a workspace dependency
02a5439
to
55cf27e
Compare
Cargo add support for workspace inheritance Tracking issue: #8415 RFC: rust-lang/rfcs#2906 This PR adds all the required support for workspace inheritance within `cargo-add`. It was split up across a few different PRs as it required `snapbox` support from #10581 and a new `toml_edit` version from #10603. `@epage` and I decided to go ahead with this PR and add in some of the changes those PRs made. `@epage's` name on the commits is from helping to rewrite commits and some very minor additions. Changes: - #10585 - Muscraft#1 - Muscraft#3 - Muscraft#2 - Muscraft#4 r? `@epage`
Tracking issue: rust-lang#8415
RFC: rust-lang/rfcs#2906
PRs in this RFC:
Cargo.toml
rust-lang/cargo#10517license-path
, anddepednency.path
rust-lang/cargo#10538readme
rust-lang/cargo#10548rust-version
rust-lang/cargo#10563exclude
andinclude
rust-lang/cargo#10565workspace
to… rust-lang/cargo#10564InheritableFields
in aLazyCell
inside `… rust-lang/cargo#10568key.workspace = true
tokey = { workspace = true }
rust-lang/cargo#10584cargo-add
supportcargo add foo
when afoo.workspace = true
already exists rust-lang/cargo#10585Changes:
inheritable_features
tocargo_add::Dependency
print_msg
to print outinheritable_features
as neededinheritable_features
inside of available_featuresRemaining implementation work for the RFC
cargo-add
support, see epage's commentr? @epage