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

Filter combos that contain dependencies. #21

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

nihohit
Copy link
Contributor

@nihohit nihohit commented Oct 6, 2024

If a combo contains two features that one is a direct or indirect dependency, the combo will now be filtered.

#19

@BD103 BD103 self-requested a review October 6, 2024 21:03
@BD103 BD103 linked an issue Oct 6, 2024 that may be closed by this pull request
@BD103
Copy link
Member

BD103 commented Oct 10, 2024

Sorry, but I probably won't have to review this until next week. My apologies!

Copy link
Member

@BD103 BD103 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! From a first pass I have a note about hashing FeatureKey. Additionally, could you update tests/complex or add a new test crate to test feature dependencies as well? You can use your original example as a starting point:

[dependencies]
foo = []
bar = ["foo"]
foobar = ["bar"]

Thank you so much, and sorry for the delay! :)

src/intern.rs Outdated
@@ -18,7 +18,7 @@ use std::{
/// using the same [`FeatureKey`] to get the string from two separate [`FeatureStorage`]s will likely result
/// in two different strings (if [`FeatureStorage::get()`] doesn't return [`None`], that is).
#[repr(transparent)]
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not implement Hash, since it itself is a hash. (Hashing a hash is just extra work without extra benefit!)

Instead, FeatureKey should derive Ord and PartialOrd and be used in a BTreeSet instead of a HashSet. BTreeSet offers the same de-duplication capabilities as HashSet, but is faster because it doesn't hash the key.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@nihohit
Copy link
Contributor Author

nihohit commented Oct 25, 2024

could you update tests/complex or add a new test crate to test feature dependencies as well?

Sure! what are the checks for the test features? just to run flag-frenzy over them manually, and check that there was no degradation?

@nihohit
Copy link
Contributor Author

nihohit commented Oct 27, 2024

@BD103, another feature to consider, not for this PR:

[dependencies]
simple = { path = "../simple", optional = true }
empty = { path = "../empty", optional = true }

[features]
contains-dependencies = ["dependency1", "dependency2"]
dependency1 = ["dependency3"]
dependency2 = ["empty"]
dependency3 = []

The simple dependency is used by the dependency2 feature, and the empty dependency is unused by all features. Can we add a configuration that is a midway between disabling all optional dependencies and enabling all optional dependencies, to only check the unused optional dependencies?
It's roughly the equivalent of adding

empty = []

or

empty = ["dep:empty"]

to the configuration.

@BD103
Copy link
Member

BD103 commented Oct 31, 2024

Sure! what are the checks for the test features? just to run flag-frenzy over them manually, and check that there was no degradation?

Yup! There are no automated checks yet, so it's just manual.

@BD103, another feature to consider, not for this PR:

Could you open an issue for this?

@nihohit
Copy link
Contributor Author

nihohit commented Oct 31, 2024

@BD103 done - both manual checks, and the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Combo calculator allows combos that contain feature dependencies.
2 participants