-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Decision: Use the condition name rust_version for RFC 2523 #142651
Copy link
Copy link
Open
Labels
I-lang-bikeshedThis item needs lang to commit to finishing a bikeshed.This item needs lang to commit to finishing a bikeshed.I-lang-radarItems that are on lang's radar and will need eventual work or consideration.Items that are on lang's radar and will need eventual work or consideration.T-langRelevant to the language teamRelevant to the language teamdisposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.This issue / PR is in PFCP or FCP with a disposition to merge it.proposed-final-comment-periodProposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off.Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off.
Metadata
Metadata
Assignees
Labels
I-lang-bikeshedThis item needs lang to commit to finishing a bikeshed.This item needs lang to commit to finishing a bikeshed.I-lang-radarItems that are on lang's radar and will need eventual work or consideration.Items that are on lang's radar and will need eventual work or consideration.T-langRelevant to the language teamRelevant to the language teamdisposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.This issue / PR is in PFCP or FCP with a disposition to merge it.proposed-final-comment-periodProposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off.Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off.
Type
Fields
Give feedbackNo fields configured for issues without a type.
RFC 2523 did not resolve the question of the exact syntax that should be used. We need to settle on that syntax before we can stabilize the "version" piece.
This issue proposes using the string
rust_versionas the name of the condition.Rationale
There are a few reasons to pick
rust_version, but the most important reason is that it is clear and unambiguous. The bare word "version" can be applied to many things, including the current crate version or other crate versions. Seeing that this is the Rust version removes that ambiguity.Whatever key we choose, it will appear not only in Rust code but also in Cargo manifests, so we should be careful to pick a name that will mean the same thing in different contexts. (As a secondary benefit, it aligns with the Cargo.toml key used to specify a minimum supported Rust version (MSRV),
rust-version.)Note that this does not fully resolve the syntax question; there is a further question of whether to support
#[cfg(rust_version(".."))],#[cfg(rust_version = "..")], or both.rust_versionhas the additional benefit (overversion) of allowing us to support a forward-compatible syntax that isn't an immediate error on old Rust versions. But I think we can consider the questions separately.Alternatives
versionAs mentioned above, this is ambiguous, not only in Rust code but especially in contexts like Cargo.toml where the same syntax will be used. Consider for example the following; how would a user be expected to know what
versionrefers to in this context?See #141766 (comment) for further discussion on this.
Note: The
cfg(target_version(..))RFC would only make this more confusing, as the wordtargetwould appear in the same line as unqualifiedversion, inviting confusion withtarget_version.Any use of
#[cfg(version)]is an immediate error in all existing stable versions of Rust. This means pickingversionwould prevent us from choosing to support syntax like#[cfg(version = "..")]that old versions of Rust are forwards-compatible with.lang_versionThis was discussed some in the original RFC thread, starting around #64796 (comment). Most of the discussion revolves around whether the use of the word "rust" would violate trademarks, or whether it makes sense to use the generic term "lang" to allow for a fork. The trademark question has been clarified; uses that "allow compatibility with the Rust programming language" are explicitly approved. A rebuttal to the point about language forks is available in #141766 (comment).
rustc_versionThis was also discussed in the original RFC. There are a few reasons not to choose
rustc_versionoverrust_version:rustc.And of course, it is one character longer!