-
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
Eager optional dependencies #2593
Comments
What makes this distinct from the |
Uh...I don't get how it's similar? The idea here being that these crates should not link std unless something else needs to link std. |
This seems like a pretty strong antipattern, crates magically changing their API based on other crates included elsewhere with no opt-in? |
Well, when you put it like that it does sound aweful :). The killer app for this is making conditional impls. Because orphan impls are prohibited, they must go with the implementee or the trait, but it's kind of a nuisance to bring in extra deps just because the instances couldn't be written anywhere else. Indeed the deps are "new" precisely when impls won't be used downstream anyways. This is precisely the case with the rust-void example I mention. |
@wycats and I talked about this today and the conclusion was:
The idea, then, is that there's a set of "community agreed upon" features (like "serde" or "std") which are commonly used amongst crates and can be opted into |
I still feel like those "'community agreed upon' features" would basically always end up being dependencies. Perhaps a good middle ground is the top-level crate states which dependencies (or even (crate with feature, triggering dep crate) pairs) it wants to use to enable features. |
I think I've heard @sgrif talking about something similar on the podcast ? Sorry if I'm mistaken. |
Talking to @eternaleye, I think scenarios would subsume this. |
rust-lang/rfcs#1787 is now going to pivot to this feature per the discussion there. Should I close this issue then, or wait to see where the rewritten RFC goes (in-case this should be reused the tracking issue or something)? |
Looks like this is a duplicate of #1555, so closing it in favor of that issue. If there is a nuanced difference that I missed, let me know. |
I need a better name :).
Basically the idea is many crates could depend on something else, but don't need to; therefore they should depend on it automatically iff its already a included in the build plan.
The biggest example I can think of is with std. Consider features like:
For comparison, Haskell's Cabal has some automatic flag resolution (flag == feature, basically) https://www.haskell.org/cabal/users-guide/developing-packages.html#resolution-of-conditions-and-flags which occupies a similar niche.
The text was updated successfully, but these errors were encountered: