-
Notifications
You must be signed in to change notification settings - Fork 13
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
Allowing unstable features on any nightly Rust version is a time bomb that will break crates #24
Comments
You issue misrepresents what Lines 325 to 329 in d77ef9f
So saying that
Perhaps you've misunderstood what this function is doing with respect to these environment variables. The point is that you can disable features via these flags, and here we're checking if they've done so. Given that these flags enable a blacklist, then yes, by default there's no filtering, but that's exactly how the compiler works: if it's a nightly or dev compiler, it allows every feature by default. We're encoding that behavior.
Given all of the caveats above, this statement now becomes true. Similarly, even if your specific version supports the specific feature, it may not implement the feature in the way you think (or previously observed) it implements the feature. This is also a useful distinction to make as well. I don't believe there are any good general solutions to these problems available to us without support from |
Regarding this part, it's worth being aware that Cargo passes different flags to rustc than what it reveals to build scripts in CARGO_ENCODED_RUSTFLAGS. This means that even considering only compiler flags (i.e. disregarding the fact that a given feature name might mean a different thing to rustc from compiler to compiler), implementing reliable behavior for As an example of the consequence, a crate with |
Let me correct that I mean on any nightly Rust version. The The issue is that Rust 1.50.0-nightly supports different unstable features than Rust 1.66.0-nightly. Features that exist on 1.80.1-nightly may cease to exist on 1.95.0-nightly. It's not sufficient to check whether the compiler allows feature flags, it's necessary to check whether it allows the specific feature flag. The assumption that all flags work unless explicitly disallowed in rustflags is unreliable. Specifically, this weak check breaks ahash 0.7 that checks for stdsimd feature flag that no longer exists in nightly Rust version, but version_check says it's okay to use it. This will break ahash again when Rust changes specialization feature flags. |
proc-macro2 used to have the same check of |
@kornelski I have my own reasons for wanting to disable autodetection of nightly sometimes, so I wrote a small utility to override version-based detection. Let me know if it is useful for you. |
version_check/src/lib.rs
Lines 349 to 351 in d77ef9f
By default Cargo does not pass any rustflags. These env vars are for users' extra flags, and don't include the usual flags used when compiling, so de-facto there's no filtering, and
version_check
naively allows any feature flag on any (edit: nightly) Rust version.Rust renames, removes, or stabilizes nightly flags without warning. Crates checking for flags using
version_check
will sooner or later end up breaking the build by using flags that may no longer exist.This check needs to be more robust. At least try compiling a file with
#![feature(…)]
in it to check if it still exists.The text was updated successfully, but these errors were encountered: