Skip to content
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

Merged
merged 1 commit into from
Apr 25, 2022

Conversation

@Muscraft Muscraft assigned Muscraft and unassigned Muscraft Apr 25, 2022
Comment on lines 118 to 120
req_feats
.difference(&available_features)
.for_each(|unknown| unknown_features.push(unknown.to_string()));
Copy link

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

Copy link
Owner Author

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()

Copy link

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())

Comment on lines 680 to 675
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
Copy link

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

Comment on lines 704 to 689
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 {
Copy link

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

Comment on lines 5 to 7
[features]
test = []
merge = []
Copy link

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)]
Copy link

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?

Copy link
Owner Author

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

@Muscraft Muscraft merged this pull request into cargo-add-support Apr 25, 2022
bors added a commit to rust-lang/cargo that referenced this pull request Apr 28, 2022
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`
@Muscraft Muscraft deleted the merged-activated-features branch May 27, 2022 01:15
Muscraft pushed a commit that referenced this pull request Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants