Version test fail for beta channel
la10736 opened this issue · 2 comments
if version().unwrap() >= Version::parse("1.40.0").unwrap() {
println!("cargo:rustc-cfg=compiler_has_important_bugfix");
}
}
Should pass when we use beta channel...
michele@mdamico-laptop:~/sviluppo/rstest$ rustup show
Default host: x86_64-unknown-linux-gnu
rustup home: /home/michele/.rustup
installed toolchains
--------------------
stable-x86_64-unknown-linux-gnu (default)
beta-x86_64-unknown-linux-gnu
nightly-x86_64-unknown-linux-gnu
active toolchain
----------------
stable-x86_64-unknown-linux-gnu (default)
rustc 1.39.0 (4560ea788 2019-11-04)
Now I worked around this by
if ver.major > 1 || ver.minor >= 40 {
println!("cargo:rustc-cfg=deprecate_parametrize_matrix");
}
I'm running into a similar situation where I'm asserting that the currently running version of rust is within a range of mine.
However, the semver comparison operations are too generic and aren't as helpful as they could be.
For example, for my minimum bound (say, 1.30.0
), I can't just do: if version()? >= Version::parse("1.30.0")?
, since that will be false
for 1.30.0-beta
, which isn't the result I want in this case.
Additionally, for nightlies, they exist in a sort of Schrodinger's box and I'd like to handle them accordingly:
- If I've got
1.29.0-nightly
, then I can definitely reject it - If I've got
1.30.0-nightly
, then I'd like to accept it, but print a warning to the user and say "hey, we're expecting features that exist in1.30.0
, but your version of nightly may or may not have that feature yet. Continue at your own peril" - If I've got
1.31.0-nightly
, then I can definitely accept it
Perhaps the right move here is to re-implement semver's Version
abstraction, but make it much more rust-version-specific, with helpful special comparison functions? E.g.:
enum HowCompatibleIsItAnyways {
Compatible,
MaybeCompatible,
NotCompatible
}
impl RustVersion {
fn is_compatible_with(other: RustVersion) -> HowCompatibleIsItAnways { ... }
}
In my view, reusing semver::Version
is a feature that would solve the original report if applied correctly. For the follow-up, I think that the current API gives you enough data to implement this logic itself. Implementing it inside rustc-version has the substantial risk of being too opinionated, making some things harder. Going to close this, feel free to reopen if you still think there's something to improve on within these design constraints.