autocfg icon indicating copy to clipboard operation
autocfg copied to clipboard

probe_rustc_version can lead to build failures on old nightly rustc

Open RalfJung opened this issue 1 year ago • 2 comments

One (I think common) way of using probe_rustc_version is to determine whether a given feature is stable and can be used by the crate. However, as this comment shows, there's a subtle pitfall here: even if we are on version 1.79, that might be an old nightly from the 1.79 cycle which does not yet have the feature!

Would it make sense to have probe_rustc_version ensure that the compiler is at least as new as the given stable release? Basically, this would mean that probe_rustc_version(1, 79) should check

  • If we are on beta or stable, require version 1.79
  • If we are on nightly, require version 1.80 to be sure that all features from 1.79 are included

RalfJung avatar Oct 04 '24 06:10 RalfJung

I'm wary of changing this given that Rust's cfg(version(...)) is not headed in that direction, even though it did at first.

In general, I think autocfg is better used by probing what you actually want, rather than the version.

cuviper avatar Jun 17 '25 22:06 cuviper

given that Rust's cfg(version(...)) is not headed in that direction

That seems like a mistake to me :/

RalfJung avatar Jun 17 '25 22:06 RalfJung