Open
Conversation
clarfonthey
reviewed
Jan 7, 2026
theemathas
reviewed
Jan 7, 2026
theemathas
reviewed
Jan 7, 2026
theemathas
reviewed
Jan 7, 2026
weiznich
reviewed
Jan 7, 2026
Contributor
weiznich
left a comment
There was a problem hiding this comment.
Overall I linke the idea, but I have some questions and remarks
(Obvious disclaimer: I'm not associated with any team, that's just my personal opinion, so feel free to ignore that)
clarfonthey
reviewed
Jan 7, 2026
tgross35
reviewed
Jan 7, 2026
Contributor
RFCs are the place for community feedback. Insight from future feature users that aren't team members is just as (if not more) valuable, and always welcome in all discussion areas ❤️ |
Urgau
reviewed
Jan 7, 2026
tgross35
reviewed
Jan 7, 2026
tgross35
reviewed
Jan 8, 2026
hanna-kruppe
reviewed
Jan 8, 2026
860a935 to
11de2c7
Compare
This reverts commit 11de2c7. It had some in-progress changes I didn't mean to commit.
tmccombs
reviewed
Jan 20, 2026
madsmtm
approved these changes
Jan 21, 2026
Co-authored-by: Mads Marquart <mads@marquart.dk>
Co-authored-by: Mads Marquart <mads@marquart.dk>
Co-authored-by: Ed Page <eopage@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This RFC proposes a general mechanism for version-based conditional compilation called "typed cfgs".
Summary
This RFC proposes "typed
cfgs", a new form of conditional compilation predicate that understands types. Initially, this RFC proposes to add support for version-typedcfgs, allowing for ergonomic version comparisons against the language version supported by the compiler. This would be exposed through two new built-incfgnames:rust_version, which can be compared against a language version literal, e.g.,#[cfg(rust_version >= "1.85")].rust_edition, which can be compared against an edition literal, e.g.,#[cfg(rust_edition >= "2024")].This design solves a long-standing problem of conditionally compiling code for different Rust versions without requiring build scripts or forcing libraries to increase their Minimum Supported Rust Version (MSRV). It also replaces the
cfg(version(..))part of RFC 2523.History
There have been several previous attempts to solve the problem of conditional compilation by Rust version.
#[cfg(version(..))]. However, it left the syntax as an open question. Attempts to stabilize it were blocked because the new syntax would be a hard error on older compilers, defeating the goal of supporting older MSRVs.#[cfg(version_since(rust, "1.95"))]for Rust-version conditional compilation #3857 proposed#[cfg(version_since(rust, ...))], which solved the MSRV problem and generalized the mechanism beyond Rust versions while defining the interaction with command line flags like--check-cfg.This RFC takes the lessons from both previous attempts. It proposes a path to the ergonomic
rust_version >= "..."syntax that was preferred during language team discussions, while providing a clear MSRV-compatibility story from day one.The RFC also incorporates use cases from the
cfg_target_versionRFC (#3750), which proposed a way to compare against the version of the target platform's SDK (e.g.,#[cfg(target_version(macos >= "10.15"))]). Version-typed cfgs provide a path to supporting these comparions.Finally, it takes cues from previous discussions around mutually exclusive features and a
cfg_value!()macro, and lays out a path toward more single-valued config types that could support these features.Rendered