-
Notifications
You must be signed in to change notification settings - Fork 103
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
Require Cargo feature opt-in for min_specialize
#239
Conversation
This commit switches away from implicitly enabling the `min_specialize` Rust nightly feature whenever a Nightly compiler is used to instead requiring an explicit opt-in with a new Cargo feature `nightly-specialize`. The goal of this commit is to fix tkaitchuck#238 and has two primary motivations: 1. In tkaitchuck#238 I'm trying to build something that depends on this crate as part of the Rust bootstrap process but this crate fails to build due to `min_specialize` not being allowed but a nightly compiler is in use. This is due to the fact that the way `-Zallow-features` is managed in the bootstrap is different than the standard Cargo way of doing so. 2. This removes a failure mode where if one day the `min_specialize` feature changes this crate won't break when built on nightly. Users of Nightly compilers will be able to continue using this crate if the feature was not explicitly opted-in to.
This pattern also causes issues with Crater and other workflows that use a current nightly to build old code. It should generally be avoided. |
Enabling this feature on stable will cause a compilation error. Given that any package in your transitive dependencies can enable it and there isn't way to override and disable a feature, this seems likely to cause more problems. |
That's correct yeah, but I only chose this route due to the preexistence of the Personally I think that the downside of a Cargo feature is less than the downside of "can be broken by any new nightly coming out" for users not opting-in to nightly features. |
|
That's a gross oversimplification of what
And
So saying it "answers true in almost every case" is misrepresenting its functionality wholly. It answers true exactly when the release channel is known to be For this particular feature, given that 1) I don't mean to minimize the problem but rather clarify it. Dealing with the first concern, using some unknown mechanism to disable features where they would otherwise be enabled, feels like a tricky situation to tackle in general. Either we teach The second concern, that some new Rust release will break your expectations of the feature, feels impossible to solve well in general without support from rustc itself. But a few ideas are:
An intermediary solution might be to do what this PR is doing, IE add an opt-in feature, as well as what this crate was doing, i.e, a best effort check to see if the feature can be enabled at all. That avoids the concern in #239 (comment) without requiring probes. The downside, of course, is that you don't get the functionality without opting-in even if your toolchain is perfectly capable of handing it. In my opinion, this problem can only be properly solved at the #[cfg(unstable(min_specialization = "0.4"))]
fn use_min_specialization() { .. } If that |
Users don't typically disable any feature flags themselves. This manual exception is too rare to matter. Sorry I wasn't clear that I'm talking about nightly compilers only. It responds
|
#242 is the way the go. |
Clearing out my open PRs, this looks like it's unlikely to land, so I'm going to close. |
This commit switches away from implicitly enabling the
min_specialize
Rust nightly feature whenever a Nightly compiler is used to instead requiring an explicit opt-in with a new Cargo featurenightly-specialize
. The goal of this commit is to fix #238 and has two primary motivations:In Require an opt-in for enabling
min_specialization
rustc feature #238 I'm trying to build something that depends on this crate as part of the Rust bootstrap process but this crate fails to build due tomin_specialize
not being allowed but a nightly compiler is in use. This is due to the fact that the way-Zallow-features
is managed in the bootstrap is different than the standard Cargo way of doing so.This removes a failure mode where if one day the
min_specialize
feature changes this crate won't break when built on nightly. Users of Nightly compilers will be able to continue using this crate if the feature was not explicitly opted-in to.