-
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
Tracking Issue for weak dependency features #8832
Comments
I think is the best option if we can make it work. foo = [ "bar/baz" ] # just /baz if bar is activated
foo = [ "bar", "bar/baz" ] # bar and bar/baz |
@mehcode I think the issue is that due to the way it's built, rustfix knows nothing about Cargo.toml, thus cargo fix does neither. I guess the solution would be to extend |
In my opinion we shouldn't have a syntax for this feature, instead a programmer could use For example, in this case there would be no warning as feature a = ["lib"]
b = ["a", "lib/feature"] However, without depending directly or indirectly on a dependency there would be a warning. b = ["lib/feature"] Then in a future edition of Rust the behaviour would change so that having |
@xfix FWIW we wanted to avoid that because it means the meaning of (although what you describe I believe is technically feasible, our hesitation was just about the confusion of having the same syntax mean two different things depending on the context) |
@alexcrichton you mean Cargo.toml? lockfiles can be shared by crates of different editions and they also don't have the |
I think having the same syntax could be balanced by having a warning when using the syntax in older editions - so there would be only a single behavior that doesn't cause a warning. Also, I think the behaviour of Add to that we can implement a warning now, we don't have to wait for Edition 2021 or something like that - a warning could be dealt with by replacing From a list of 30 most popular dependencies (by recent downloads) on crates.io I found that the 2 crates unintentionally enable optional features.
On the other hand kv_unstable_sval = ["kv_unstable", "sval/fmt"] However kv_unstable_sval = ["kv_unstable", "sval", "sval/fmt"] In fact, std = ["alloc", "getrandom", "getrandom/std"] |
Er yes I meant the manifest, not the lock file. @xfix that's perhaps plausible to simply warn, but that's also a massive task to force the entire Rust community to relearn a feature they already know. There's a very real cost to that which isn't present if we pick a new syntax. |
Personally I think that warning or not, switching it without an opt-in of either an edition or special syntax is a violation of Rust's stability guarantees. I support the idea of changing the syntax on a edition boundary, but I think this feature is too useful to wait for a new edition, or be even blocked by a discussion about the syntax :). First it can be introduced with the new custom syntax, then later one can decide whether the new edition should switch to it by default. Also there is the question of interactions between the RFC to do workspace sharing of information and having heterogenous edition choices inside a workspace. |
@alexcrichton From my experience, the current behavior is not really an expected one, but an unfortunate gotcha that I discovered independently. I'm strongly in favor of changing |
I think we need to have a distinct syntax for this, even in a new edition. I don't think we should go directly from one meaning of |
Now that the new feature resolver has gone in, are there any blockers preventing us from stabilizing this once we're confident it works as intended? I think we bikeshedded the syntax fairly extensively in the Cargo meetings. I also think we need to give people some guidance about how soon after stabilization they can safely start using this in popular crates. For instance, I'd really like to use this in |
With regard to how long before using, why would this be any different than any other MSRV change? I just checked the code for the time crate, and the main branch could use this (not any current release, though). I'd just hold out six months per my MSRV policy. |
Features go into the index, will this cause any issues with older cargo's loading older versions of a crate which has started using it in a new version? |
@Nemo157 In general the Resolver is pretty good at not picking versions that contain things it does not understand. But now that you mention it we should definitely test in this case. |
The path to stabilization is:
The testing phase is important, because enabling this causes Cargo to use the new feature resolver in "classic" mode when
I'm not sure how feasible or useful that guidance could be. Projects have widely different MSRV policies, and it's a choice they have to make based on the level of support they want to and can feasibly provide. Whatever they choose is valid, and I'm not sure we can imply with a recommendation that their choice isn't a good one. If I only want to support the latest stable, that shouldn't be shunned. Just like if someone wants to support 2 year old releases, and they need to reject PRs because it violates that choice, I think that choice is valid and shouldn't be discouraged. For git2, I think Alex is relatively aggressive on using newer releases than most projects (stable-1 I think).
Those packages are mostly ignored by older cargos. There's a test for this here (although that is not directly testing older cargos, the concept is the same). I just checked, and it works starting with version 1.19 (released 2017-07-20). Prior versions fail with a parse error. We don't have an explicit timeframe in our compatibility policy (per https://doc.crates.io/contrib/design.html#forwards-compatibility). I think a minimum of 2 years isn't bad, but we haven't discussed it much. |
@jhpratt wrote:
@Nemo157 wrote:
This was the exact concern that motivated the suggestion to give people guidance. I'm not suggesting that such guidance would tell people what their MSRV (or MSCV) policy should be. Rather, I think we need guidance (supported by testing) along the lines of "There are no special compatibility considerations here, you can follow your normal MSRV policy". I want to make sure people know that if they release a new version of their crate that uses this feature, they won't break people who are using older versions of their crate. @ehuss wrote:
Thank you for testing that! That's exactly the kind of guidance I think people will need to be able to use this feature confidently.
We had a couple of fairly detailed discussions about syntax and orthogonality, which seemed to reach a consensus on the
Makes sense. Given that people can use this feature on nightly, this seems like it should happen in parallel with testing and feedback. I've also submitted #9015 as draft documentation for the features section of the reference. |
I think that's a problem. It's one thing to have crates on crates.io break support with older cargos, it's another thing to have those older cargos be broken even if they only use an older version of the crates. Is there a way to make the feature fail in a better way for those older cargos? |
I think it is still open to be changed. There has been almost no feedback from users about this change, other than the 3 people who have commented here not liking the syntax.
I don't immediately have any ideas on how to make that work. I realize that it can be painful to break old versions of software. I'm not sure if 1.19 is old enough to draw the line. Older versions could still be used with |
How hard would it be to implement a separate |
There are two issues with that. One is that older cargos would ignore the field, and possibly end up resolving the features incorrectly (which may or may not work in practice). The other is that the features would still be listed in the If we want to have the rule that older Cargos will work as long as they have a |
Put me down as a user who does like the |
I'd say the ? syntax is acceptable as a short-term solution, but it should become the default behavior in some future edition or so. Everyone is surprised by the current default behavior. |
@ehuss Both of those are only problems if old Cargo selects a version that uses the new functionality, and I am ok with old Cargos braking if it trys to build a new crate. My (and I think @est31) concern is that and old Cargo that has a dep on and old version will stop working because Cargo can not read the index where a new unselected version uses the new sintaks. Maybe we have misunderstood your comment "Prior versions fail with a parse error." Here is the test case I am worried about: |
Anything holding up actually stabilizing this now that the RFC was merged? |
There's a fair lot of work to update crates.io, and perform testing. I may work on it this week, but it may be a long while before it hits stable. |
`fallible-iterator` doesn't need to be a dependency, it is pulled in by `gimli/std` which can't be fixed without rust-lang/cargo#8832. Signed-off-by: David Wood <[email protected]>
`fallible-iterator` doesn't need to be a dependency, it is pulled in by `gimli/std` which can't be fixed without rust-lang/cargo#8832. Signed-off-by: David Wood <[email protected]>
No rush, but @ehuss just wondering if you have made any progress on this front? |
It is just waiting on rust-lang/crates.io#3867. |
Time for FCP now that that PR was merged? Thank you for your hard work @ehuss! It truly is appreciated. |
Posted #10269 as a proposal to stabilized this. |
Summary
Original issue: #3494
Implementation: #8818
Documentation: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#weak-dependency-features
-Z weak-dep-features
will enable "weak" dependency features, wherebydep_name?/feature_name
syntax in the[features]
table will not automatically enable thedep_name
dependency (unlike thedep_name/feature_name
syntax which always enablesdep_name
). This just indicates that the feature on that dependency should be enabled if something else enables that dependency on this package.Unresolved issues
dep_name?/feat_name
?dep_name/feat_name
dep_name?feat_name
{dep="dep_name", feature="feat_name", enable-dep=false}
if-dep:dep_name/feat_name
(read this as "if dependency foo then enable feature bar").?
format means people will have to look up what it means, and searching for punctuation is difficult.org_name/pkg_name
syntax, which could contribute to the punctuation soup.dep_name/feat_name
syntax on an edition boundary. A concern is that this is not an (easily) rustfix-able change.features2
to the index. #9161.About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
The text was updated successfully, but these errors were encountered: