diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs index ffa6ffb40b61a..d409e0a4bd315 100644 --- a/compiler/rustc_feature/src/accepted.rs +++ b/compiler/rustc_feature/src/accepted.rs @@ -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. diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index c117e0fcf7ccc..bf216d3b16e74 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -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), diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index b46eac6d8a602..474685c0d60f2 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -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. diff --git a/compiler/rustc_trait_selection/src/lib.rs b/compiler/rustc_trait_selection/src/lib.rs index 67328defe36b5..8cd57c003282a 100644 --- a/compiler/rustc_trait_selection/src/lib.rs +++ b/compiler/rustc_trait_selection/src/lib.rs @@ -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)] diff --git a/src/doc/unstable-book/src/language-features/cfg-version.md b/src/doc/unstable-book/src/language-features/cfg-version.md deleted file mode 100644 index a6ec42cecba8a..0000000000000 --- a/src/doc/unstable-book/src/language-features/cfg-version.md +++ /dev/null @@ -1,35 +0,0 @@ -# `cfg_version` - -The tracking issue for this feature is: [#64796] - -[#64796]: https://github.com/rust-lang/rust/issues/64796 - ------------------------- - -The `cfg_version` feature makes it possible to execute different code -depending on the compiler version. It will return true if the compiler -version is greater than or equal to the specified version. - -## Examples - -```rust -#![feature(cfg_version)] - -#[cfg(version("1.42"))] // 1.42 and above -fn a() { - // ... -} - -#[cfg(not(version("1.42")))] // 1.41 and below -fn a() { - // ... -} - -fn b() { - if cfg!(version("1.42")) { - // ... - } else { - // ... - } -} -``` diff --git a/tests/ui/cfg/assume-incomplete-release/assume-incomplete.rs b/tests/ui/cfg/assume-incomplete-release/assume-incomplete.rs index cafb7389e29fa..f825368e51e1f 100644 --- a/tests/ui/cfg/assume-incomplete-release/assume-incomplete.rs +++ b/tests/ui/cfg/assume-incomplete-release/assume-incomplete.rs @@ -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; diff --git a/tests/ui/cfg/cfg-version/cfg-version-expand.rs b/tests/ui/cfg/cfg-version/cfg-version-expand.rs index 8c426b4a41f51..63a7e3f3440a4 100644 --- a/tests/ui/cfg/cfg-version/cfg-version-expand.rs +++ b/tests/ui/cfg/cfg-version/cfg-version-expand.rs @@ -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"))] diff --git a/tests/ui/cfg/cfg-version/cfg-version-expand.stderr b/tests/ui/cfg/cfg-version/cfg-version-expand.stderr index a9a8d86c0fa94..d905cc616a4ff 100644 --- a/tests/ui/cfg/cfg-version/cfg-version-expand.stderr +++ b/tests/ui/cfg/cfg-version/cfg-version-expand.stderr @@ -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"))] | ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/cfg/cfg-version/syntax.rs b/tests/ui/cfg/cfg-version/syntax.rs index 22aab47e1ecdf..5fe0d0d7eceda 100644 --- a/tests/ui/cfg/cfg-version/syntax.rs +++ b/tests/ui/cfg/cfg-version/syntax.rs @@ -1,7 +1,5 @@ //! Check `#[cfg(version(..))]` parsing. -#![feature(cfg_version)] - // Overall grammar // =============== // diff --git a/tests/ui/cfg/cfg-version/syntax.stderr b/tests/ui/cfg/cfg-version/syntax.stderr index 2facd96076317..d12f233b8ce8b 100644 --- a/tests/ui/cfg/cfg-version/syntax.stderr +++ b/tests/ui/cfg/cfg-version/syntax.stderr @@ -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")] | ^^^^^^^^^^^^^^^^ @@ -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")); | ^^^^^^^^^^^^^^^^ @@ -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 diff --git a/tests/ui/check-cfg/wrong-version-syntax.fixed b/tests/ui/check-cfg/wrong-version-syntax.fixed index efbe2ed1bd855..3b27a2fdf2233 100644 --- a/tests/ui/check-cfg/wrong-version-syntax.fixed +++ b/tests/ui/check-cfg/wrong-version-syntax.fixed @@ -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() {} diff --git a/tests/ui/check-cfg/wrong-version-syntax.rs b/tests/ui/check-cfg/wrong-version-syntax.rs index 221ecf4cae887..c4f1bf65c4a04 100644 --- a/tests/ui/check-cfg/wrong-version-syntax.rs +++ b/tests/ui/check-cfg/wrong-version-syntax.rs @@ -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() {} diff --git a/tests/ui/check-cfg/wrong-version-syntax.stderr b/tests/ui/check-cfg/wrong-version-syntax.stderr index 97157a0c02b97..0d7bbf68d9c1f 100644 --- a/tests/ui/check-cfg/wrong-version-syntax.stderr +++ b/tests/ui/check-cfg/wrong-version-syntax.stderr @@ -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"))] | ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/feature-gates/feature-gate-cfg-version.rs b/tests/ui/feature-gates/feature-gate-cfg-version.rs deleted file mode 100644 index ec2446cc14648..0000000000000 --- a/tests/ui/feature-gates/feature-gate-cfg-version.rs +++ /dev/null @@ -1,12 +0,0 @@ -//! Feature gate test for `cfg_version`. -//! -//! Tracking issue: #64796. - -#[cfg(version("1.42"))] -//~^ ERROR `cfg(version)` is experimental and subject to change -fn bar() {} - -fn main() { - assert!(cfg!(version("1.42"))); - //~^ ERROR `cfg(version)` is experimental and subject to change -} diff --git a/tests/ui/feature-gates/feature-gate-cfg-version.stderr b/tests/ui/feature-gates/feature-gate-cfg-version.stderr deleted file mode 100644 index 7cb2f1e07afe6..0000000000000 --- a/tests/ui/feature-gates/feature-gate-cfg-version.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0658]: `cfg(version)` is experimental and subject to change - --> $DIR/feature-gate-cfg-version.rs:5:7 - | -LL | #[cfg(version("1.42"))] - | ^^^^^^^^^^^^^^^ - | - = note: see issue #64796 for more information - = help: add `#![feature(cfg_version)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: `cfg(version)` is experimental and subject to change - --> $DIR/feature-gate-cfg-version.rs:10:18 - | -LL | assert!(cfg!(version("1.42"))); - | ^^^^^^^^^^^^^^^ - | - = note: see issue #64796 for more information - = help: add `#![feature(cfg_version)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0658`.