Skip to content

Commit 860a935

Browse files
committed
Add drawback about feature checks prior to rust_version
1 parent c3f74b6 commit 860a935

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

text/0000-version-typed-cfgs.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ This section is subject to change prior to stabilization.
253253
- Making the perfect the enemy of the good. RFC 2523 was accepted, and an implementation of its `version()` predicate is ready.
254254
- Increased compiler complexity. This introduces a new concept of "typed" `cfg`s into the compiler, which adds complexity to the parsing and evaluation logic for conditional compilation.
255255
- Subtlety of MSRV-preserving patterns: The need for the "stacked `cfg`" pattern (`#[cfg(rust_version)] #[cfg(rust_version >= ...)]` and `#[cfg_attr(rust_version, cfg(rust_version >= ...))]`) is subtle. While we will add lints to guide users, it's less direct than a simple predicate. However, this subtlety is the explicit tradeoff made to achieve MSRV compatibility.
256+
- The MSRV-preserving pattern still does not allow using the feature to check for versions prior to when this feature was introduced.
256257
- The "stacked `cfg`" pattern does not work inside Cargo, so users will not be able to use this feature in Cargo until their MSRV is bumped. For cases where a dependency needs to be conditional on the Rust version, one can define a "polyfill" crate and make use of the MSRV-aware feature resolver, like the `is_terminal_polyfill` crate does.
257258
- Conditional compilation adds testing complexity. In practice, most crate maintainers only test their MSRV and the latest stable.
258259
- This does not support branching on specific nightly versions. rustversion supports this with syntax like `#[rustversion::since(2025-01-01)]`.

0 commit comments

Comments
 (0)