Stabilise inline_const

This commit is contained in:
Gary Guo 2024-04-19 16:17:02 +01:00
parent e9362896e0
commit 94c1920497
16 changed files with 11 additions and 68 deletions

View File

@ -556,7 +556,6 @@ macro_rules! gate_all {
half_open_range_patterns_in_slices,
"half-open range patterns in slices are unstable"
);
gate_all!(inline_const, "inline-const is experimental");
gate_all!(inline_const_pat, "inline-const in pattern position is experimental");
gate_all!(associated_const_equality, "associated const equality is incomplete");
gate_all!(yeet_expr, "`do yeet` expression is experimental");

View File

@ -211,6 +211,8 @@ macro_rules! declare_features {
(accepted, inclusive_range_syntax, "1.26.0", Some(28237)),
/// Allows inferring outlives requirements (RFC 2093).
(accepted, infer_outlives_requirements, "1.30.0", Some(44493)),
/// Allow anonymous constants from an inline `const` block
(accepted, inline_const, "CURRENT_RUSTC_VERSION", Some(76001)),
/// Allows irrefutable patterns in `if let` and `while let` statements (RFC 2086).
(accepted, irrefutable_let_patterns, "1.33.0", Some(44495)),
/// Allows `#[instruction_set(_)]` attribute.

View File

@ -501,8 +501,6 @@ pub fn internal(&self, feature: Symbol) -> bool {
(unstable, impl_trait_in_fn_trait_return, "1.64.0", Some(99697)),
/// Allows associated types in inherent impls.
(incomplete, inherent_associated_types, "1.52.0", Some(8995)),
/// Allow anonymous constants from an inline `const` block
(unstable, inline_const, "1.49.0", Some(76001)),
/// Allow anonymous constants from an inline `const` block in pattern position
(unstable, inline_const_pat, "1.58.0", Some(76001)),
/// Allows using `pointer` and `reference` in intra-doc links

View File

@ -37,7 +37,7 @@
#![feature(coroutines)]
#![feature(stmt_expr_attributes)]
#![feature(if_let_guard)]
#![feature(inline_const)]
#![cfg_attr(bootstrap, feature(inline_const))]
#![feature(iter_from_coroutine)]
#![feature(negative_impls)]
#![feature(never_type)]

View File

@ -4,7 +4,7 @@
#![feature(cow_is_borrowed)]
#![feature(decl_macro)]
#![feature(impl_trait_in_assoc_type)]
#![feature(inline_const)]
#![cfg_attr(bootstrap, feature(inline_const))]
#![feature(is_sorted)]
#![feature(let_chains)]
#![feature(map_try_insert)]

View File

@ -1252,8 +1252,6 @@ fn parse_constness_(&mut self, case: Case, is_closure: bool) -> Const {
fn parse_const_block(&mut self, span: Span, pat: bool) -> PResult<'a, P<Expr>> {
if pat {
self.psess.gated_spans.gate(sym::inline_const_pat, span);
} else {
self.psess.gated_spans.gate(sym::inline_const, span);
}
self.eat_keyword(kw::Const);
let (attrs, blk) = self.parse_inner_attrs_and_block()?;

View File

@ -11,7 +11,7 @@
#![cfg_attr(bootstrap, feature(associated_type_bounds))]
#![feature(const_option)]
#![feature(core_intrinsics)]
#![feature(inline_const)]
#![cfg_attr(bootstrap, feature(inline_const))]
#![feature(min_specialization)]
#![feature(never_type)]
#![feature(ptr_sub_ptr)]

View File

@ -128,7 +128,6 @@
#![feature(fn_traits)]
#![feature(hasher_prefixfree_extras)]
#![feature(hint_assert_unchecked)]
#![feature(inline_const)]
#![feature(inplace_iteration)]
#![feature(iter_advance_by)]
#![feature(iter_next_chunk)]
@ -169,6 +168,7 @@
// Language features:
// tidy-alphabetical-start
#![cfg_attr(bootstrap, feature(associated_type_bounds))]
#![cfg_attr(bootstrap, feature(inline_const))]
#![cfg_attr(not(bootstrap), rustc_preserve_ub_checks)]
#![cfg_attr(not(test), feature(coroutine_trait))]
#![cfg_attr(test, feature(panic_update_hook))]

View File

@ -201,6 +201,7 @@
//
// Language features:
// tidy-alphabetical-start
#![cfg_attr(bootstrap, feature(inline_const))]
#![feature(abi_unadjusted)]
#![feature(adt_const_params)]
#![feature(allow_internal_unsafe)]
@ -231,7 +232,6 @@
#![feature(fundamental)]
#![feature(generic_arg_infer)]
#![feature(if_let_guard)]
#![feature(inline_const)]
#![feature(intra_doc_pointers)]
#![feature(intrinsics)]
#![feature(lang_items)]

View File

@ -511,7 +511,7 @@ pub fn from_mut(v: &mut bool) -> &mut Self {
/// # Examples
///
/// ```
/// #![feature(atomic_from_mut, inline_const)]
/// #![feature(atomic_from_mut)]
/// use std::sync::atomic::{AtomicBool, Ordering};
///
/// let mut some_bools = [const { AtomicBool::new(false) }; 10];
@ -1313,7 +1313,7 @@ pub fn from_mut(v: &mut *mut T) -> &mut Self {
/// # Examples
///
/// ```
/// #![feature(atomic_from_mut, inline_const)]
/// #![feature(atomic_from_mut)]
/// use std::ptr::null_mut;
/// use std::sync::atomic::{AtomicPtr, Ordering};
///
@ -2303,7 +2303,7 @@ pub fn from_mut(v: &mut $int_type) -> &mut Self {
/// # Examples
///
/// ```
/// #![feature(atomic_from_mut, inline_const)]
/// #![feature(atomic_from_mut)]
#[doc = concat!($extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering};")]
///
#[doc = concat!("let mut some_ints = [const { ", stringify!($atomic_type), "::new(0) }; 10];")]

View File

@ -46,7 +46,7 @@
#![feature(hasher_prefixfree_extras)]
#![feature(hashmap_internals)]
#![feature(try_find)]
#![feature(inline_const)]
#![cfg_attr(bootstrap, feature(inline_const))]
#![feature(is_sorted)]
#![feature(layout_for_ptr)]
#![feature(pattern)]

View File

@ -7,7 +7,6 @@
convert_float_to_int,
core_intrinsics,
decl_macro,
inline_const,
intra_doc_pointers,
repr_simd,
simd_ffi,

View File

@ -2,8 +2,6 @@
The tracking issue for this feature is: [#76001]
See also [`inline_const`](inline-const.md)
------
This feature allows you to use inline constant expressions in pattern position:

View File

@ -1,32 +0,0 @@
# `inline_const`
The tracking issue for this feature is: [#76001]
See also [`inline_const_pat`](inline-const-pat.md)
------
This feature allows you to use inline constant expressions. For example, you can
turn this code:
```rust
# fn add_one(x: i32) -> i32 { x + 1 }
const MY_COMPUTATION: i32 = 1 + 2 * 3 / 4;
fn main() {
let x = add_one(MY_COMPUTATION);
}
```
into this code:
```rust
#![feature(inline_const)]
# fn add_one(x: i32) -> i32 { x + 1 }
fn main() {
let x = add_one(const { 1 + 2 * 3 / 4 });
}
```
[#76001]: https://github.com/rust-lang/rust/issues/76001

View File

@ -1,6 +0,0 @@
fn main() {
let _ = const {
//~^ ERROR inline-const is experimental [E0658]
true
};
}

View File

@ -1,13 +0,0 @@
error[E0658]: inline-const is experimental
--> $DIR/feature-gate-inline_const.rs:2:13
|
LL | let _ = const {
| ^^^^^
|
= note: see issue #76001 <https://github.com/rust-lang/rust/issues/76001> for more information
= help: add `#![feature(inline_const)]` 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 1 previous error
For more information about this error, try `rustc --explain E0658`.