Skip to content

Stabilize #[cfg(version(...))], take 2 #141766

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ declare_features! (
(accepted, cfg_target_feature, "1.27.0", Some(29717)),
/// Allows `cfg(target_vendor = "...")`.
(accepted, cfg_target_vendor, "1.33.0", Some(29718)),
/// Allow conditional compilation depending on rust version
(accepted, cfg_version, "CURRENT_RUSTC_VERSION", Some(64796)),
/// Allows implementing `Clone` for closures where possible (RFC 2132).
(accepted, clone_closures, "1.26.0", Some(44490)),
/// Allows coercing non capturing closures to function pointers.
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_feature/src/builtin_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ const GATED_CFGS: &[GatedCfg] = &[
Features::cfg_target_has_atomic,
),
(sym::sanitize, sym::cfg_sanitize, Features::cfg_sanitize),
(sym::version, sym::cfg_version, Features::cfg_version),
(sym::relocation_model, sym::cfg_relocation_model, Features::cfg_relocation_model),
(sym::sanitizer_cfi_generalize_pointers, sym::cfg_sanitizer_cfi, Features::cfg_sanitizer_cfi),
(sym::sanitizer_cfi_normalize_integers, sym::cfg_sanitizer_cfi, Features::cfg_sanitizer_cfi),
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,6 @@ declare_features! (
(unstable, cfg_target_thread_local, "1.7.0", Some(29594)),
/// Allows the use of `#[cfg(ub_checks)` to check if UB checks are enabled.
(unstable, cfg_ub_checks, "1.79.0", Some(123499)),
/// Allow conditional compilation depending on rust version
(unstable, cfg_version, "1.45.0", Some(64796)),
/// Allows to use the `#[cfi_encoding = ""]` attribute.
(unstable, cfi_encoding, "1.71.0", Some(89653)),
/// Allows `for<...>` on closures and coroutines.
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_trait_selection/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#![feature(assert_matches)]
#![feature(associated_type_defaults)]
#![feature(box_patterns)]
#![feature(cfg_version)]
#![feature(if_let_guard)]
#![feature(iter_intersperse)]
#![feature(iterator_try_reduce)]
Expand Down
35 changes: 0 additions & 35 deletions src/doc/unstable-book/src/language-features/cfg-version.md

This file was deleted.

2 changes: 0 additions & 2 deletions tests/ui/cfg/assume-incomplete-release/assume-incomplete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
//@ revisions: assume no_assume
//@ [assume]compile-flags: -Z assume-incomplete-release

#![feature(cfg_version)]

extern crate ver_cfg_rel;

use ver_cfg_rel::ver_cfg_rel;
Expand Down
2 changes: 0 additions & 2 deletions tests/ui/cfg/cfg-version/cfg-version-expand.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//@ run-pass
//@ rustc-env:RUSTC_OVERRIDE_VERSION_STRING=1.50.3

#![feature(cfg_version)]

#[cfg(version("1.49.0"))]
const ON_1_49_0: bool = true;
#[cfg(version("1.50"))]
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/cfg/cfg-version/cfg-version-expand.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
warning: unexpected `cfg` condition name: `version`
--> $DIR/cfg-version-expand.rs:15:11
--> $DIR/cfg-version-expand.rs:13:11
|
LL | #[cfg(not(version = "1.48.0"))]
| ^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 0 additions & 2 deletions tests/ui/cfg/cfg-version/syntax.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//! Check `#[cfg(version(..))]` parsing.

#![feature(cfg_version)]

// Overall grammar
// ===============
//
Expand Down
56 changes: 28 additions & 28 deletions tests/ui/cfg/cfg-version/syntax.stderr
Original file line number Diff line number Diff line change
@@ -1,101 +1,101 @@
error: expected a version literal
--> $DIR/syntax.rs:11:15
--> $DIR/syntax.rs:9:15
|
LL | #[cfg(version(42))]
| ^^

error: expected a version literal
--> $DIR/syntax.rs:15:15
--> $DIR/syntax.rs:13:15
|
LL | #[cfg(version(1.20))]
| ^^^^

error: expected a version literal
--> $DIR/syntax.rs:19:15
--> $DIR/syntax.rs:17:15
|
LL | #[cfg(version(false))]
| ^^^^^

error: expected single version literal
--> $DIR/syntax.rs:23:7
--> $DIR/syntax.rs:21:7
|
LL | #[cfg(version("1.43", "1.44", "1.45"))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: unknown version literal format, assuming it refers to a future version
--> $DIR/syntax.rs:51:15
--> $DIR/syntax.rs:49:15
|
LL | #[cfg(version("foo"))]
| ^^^^^

warning: unknown version literal format, assuming it refers to a future version
--> $DIR/syntax.rs:55:15
--> $DIR/syntax.rs:53:15
|
LL | #[cfg(version("1.20.0-stable"))]
| ^^^^^^^^^^^^^^^

warning: unknown version literal format, assuming it refers to a future version
--> $DIR/syntax.rs:78:15
--> $DIR/syntax.rs:76:15
|
LL | #[cfg(version("1"))]
| ^^^

warning: unknown version literal format, assuming it refers to a future version
--> $DIR/syntax.rs:82:15
--> $DIR/syntax.rs:80:15
|
LL | #[cfg(version("0"))]
| ^^^

warning: unknown version literal format, assuming it refers to a future version
--> $DIR/syntax.rs:86:15
--> $DIR/syntax.rs:84:15
|
LL | #[cfg(version(".7"))]
| ^^^^

warning: unknown version literal format, assuming it refers to a future version
--> $DIR/syntax.rs:95:15
--> $DIR/syntax.rs:93:15
|
LL | #[cfg(version("-1"))]
| ^^^^

warning: unknown version literal format, assuming it refers to a future version
--> $DIR/syntax.rs:101:15
--> $DIR/syntax.rs:99:15
|
LL | #[cfg(version("65536"))]
| ^^^^^^^

warning: unknown version literal format, assuming it refers to a future version
--> $DIR/syntax.rs:105:15
--> $DIR/syntax.rs:103:15
|
LL | #[cfg(version("1.65536.0"))]
| ^^^^^^^^^^^

warning: unknown version literal format, assuming it refers to a future version
--> $DIR/syntax.rs:109:15
--> $DIR/syntax.rs:107:15
|
LL | #[cfg(version("1.0.65536"))]
| ^^^^^^^^^^^

warning: unknown version literal format, assuming it refers to a future version
--> $DIR/syntax.rs:113:15
--> $DIR/syntax.rs:111:15
|
LL | #[cfg(version("65536.0.65536"))]
| ^^^^^^^^^^^^^^^

warning: unknown version literal format, assuming it refers to a future version
--> $DIR/syntax.rs:125:26
--> $DIR/syntax.rs:123:26
|
LL | assert!(cfg!(version("foo")));
| ^^^^^

warning: unknown version literal format, assuming it refers to a future version
--> $DIR/syntax.rs:127:26
--> $DIR/syntax.rs:125:26
|
LL | assert!(cfg!(version("1.20.0-stable")));
| ^^^^^^^^^^^^^^^

warning: unexpected `cfg` condition name: `version`
--> $DIR/syntax.rs:30:7
--> $DIR/syntax.rs:28:7
|
LL | #[cfg(version = "1.43")]
| ^^^^^^^^^^^^^^^^
Expand All @@ -110,7 +110,7 @@ LL + #[cfg(version("1.43"))]
|

warning: unexpected `cfg` condition name: `version`
--> $DIR/syntax.rs:130:18
--> $DIR/syntax.rs:128:18
|
LL | assert!(cfg!(version = "1.43"));
| ^^^^^^^^^^^^^^^^
Expand All @@ -124,61 +124,61 @@ LL + assert!(cfg!(version("1.43")));
|

error[E0425]: cannot find function `key_value_form` in this scope
--> $DIR/syntax.rs:139:5
--> $DIR/syntax.rs:137:5
|
LL | key_value_form();
| ^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `not_numbers_or_periods` in this scope
--> $DIR/syntax.rs:143:5
--> $DIR/syntax.rs:141:5
|
LL | not_numbers_or_periods();
| ^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `complex_semver_with_metadata` in this scope
--> $DIR/syntax.rs:144:5
--> $DIR/syntax.rs:142:5
|
LL | complex_semver_with_metadata();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `invalid_major_only` in this scope
--> $DIR/syntax.rs:145:5
--> $DIR/syntax.rs:143:5
|
LL | invalid_major_only();
| ^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `invalid_major_only_zero` in this scope
--> $DIR/syntax.rs:146:5
--> $DIR/syntax.rs:144:5
|
LL | invalid_major_only_zero();
| ^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `invalid_major_only_negative` in this scope
--> $DIR/syntax.rs:147:5
--> $DIR/syntax.rs:145:5
|
LL | invalid_major_only_negative();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `exceed_u16_major` in this scope
--> $DIR/syntax.rs:148:5
--> $DIR/syntax.rs:146:5
|
LL | exceed_u16_major();
| ^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `exceed_u16_minor` in this scope
--> $DIR/syntax.rs:149:5
--> $DIR/syntax.rs:147:5
|
LL | exceed_u16_minor();
| ^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `exceed_u16_patch` in this scope
--> $DIR/syntax.rs:150:5
--> $DIR/syntax.rs:148:5
|
LL | exceed_u16_patch();
| ^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `exceed_u16_mixed` in this scope
--> $DIR/syntax.rs:151:5
--> $DIR/syntax.rs:149:5
|
LL | exceed_u16_mixed();
| ^^^^^^^^^^^^^^^^ not found in this scope
Expand Down
2 changes: 0 additions & 2 deletions tests/ui/check-cfg/wrong-version-syntax.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
//@ compile-flags: --check-cfg=cfg()
//@ run-rustfix

#![feature(cfg_version)]

#[cfg(not(version("1.48.0")))]
//~^ WARNING unexpected `cfg` condition name: `version`
pub fn g() {}
Expand Down
2 changes: 0 additions & 2 deletions tests/ui/check-cfg/wrong-version-syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
//@ compile-flags: --check-cfg=cfg()
//@ run-rustfix

#![feature(cfg_version)]

#[cfg(not(version = "1.48.0"))]
//~^ WARNING unexpected `cfg` condition name: `version`
pub fn g() {}
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/check-cfg/wrong-version-syntax.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
warning: unexpected `cfg` condition name: `version`
--> $DIR/wrong-version-syntax.rs:10:11
--> $DIR/wrong-version-syntax.rs:8:11
|
LL | #[cfg(not(version = "1.48.0"))]
| ^^^^^^^^^^^^^^^^^^
Expand Down
12 changes: 0 additions & 12 deletions tests/ui/feature-gates/feature-gate-cfg-version.rs

This file was deleted.

23 changes: 0 additions & 23 deletions tests/ui/feature-gates/feature-gate-cfg-version.stderr

This file was deleted.

Loading