diff options
| author | Ralf Jung <post@ralfj.de> | 2024-12-25 10:36:32 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2024-12-25 10:36:32 +0100 |
| commit | 6de3a2e3a9c45e12f63a8e861131a39b1eb0e021 (patch) | |
| tree | 61ecea4b14cf5648ad4626f85b0ad359342e3c59 | |
| parent | 68b9e4f5f5566424b8edc2c75feefe3a4ee2fa72 (diff) | |
| download | rust-6de3a2e3a9c45e12f63a8e861131a39b1eb0e021.tar.gz rust-6de3a2e3a9c45e12f63a8e861131a39b1eb0e021.zip | |
stabilize const_swap
| -rw-r--r-- | library/core/src/intrinsics/mod.rs | 3 | ||||
| -rw-r--r-- | library/core/src/lib.rs | 1 | ||||
| -rw-r--r-- | library/core/src/mem/mod.rs | 2 | ||||
| -rw-r--r-- | library/core/src/ptr/mod.rs | 3 | ||||
| -rw-r--r-- | library/core/src/ptr/mut_ptr.rs | 2 | ||||
| -rw-r--r-- | library/core/src/ptr/non_null.rs | 2 | ||||
| -rw-r--r-- | library/core/src/slice/mod.rs | 2 | ||||
| -rw-r--r-- | library/core/tests/lib.rs | 1 | ||||
| -rw-r--r-- | tests/ui/consts/issue-94371.rs | 2 | ||||
| -rw-r--r-- | tests/ui/consts/qualif-indirect-mutation-fail.rs | 1 | ||||
| -rw-r--r-- | tests/ui/consts/qualif-indirect-mutation-fail.stderr | 22 | ||||
| -rw-r--r-- | tests/ui/thread-local/thread-local-static.rs | 1 | ||||
| -rw-r--r-- | tests/ui/thread-local/thread-local-static.stderr | 4 |
13 files changed, 20 insertions, 26 deletions
diff --git a/library/core/src/intrinsics/mod.rs b/library/core/src/intrinsics/mod.rs index 42b8eb33a1a..9844243d168 100644 --- a/library/core/src/intrinsics/mod.rs +++ b/library/core/src/intrinsics/mod.rs @@ -3954,7 +3954,8 @@ pub const fn is_val_statically_known<T: Copy>(_arg: T) -> bool { #[inline] #[rustc_intrinsic] // Const-unstable because `swap_nonoverlapping` is const-unstable. -#[rustc_const_unstable(feature = "const_typed_swap", issue = "none")] +#[rustc_intrinsic_const_stable_indirect] +#[rustc_allow_const_fn_unstable(const_swap_nonoverlapping)] // this is anyway not called since CTFE implements the intrinsic pub const unsafe fn typed_swap<T>(x: *mut T, y: *mut T) { // SAFETY: The caller provided single non-overlapping items behind // pointers, so swapping them with `count: 1` is fine. diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index a7f741a9408..c7646f9f270 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -111,7 +111,6 @@ #![feature(array_ptr_get)] #![feature(asm_experimental_arch)] #![feature(const_eval_select)] -#![feature(const_typed_swap)] #![feature(core_intrinsics)] #![feature(coverage_attribute)] #![feature(internal_impls_macro)] diff --git a/library/core/src/mem/mod.rs b/library/core/src/mem/mod.rs index 57acc9dcd6e..1576eb43152 100644 --- a/library/core/src/mem/mod.rs +++ b/library/core/src/mem/mod.rs @@ -725,7 +725,7 @@ pub unsafe fn uninitialized<T>() -> T { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_const_unstable(feature = "const_swap", issue = "83163")] +#[rustc_const_stable(feature = "const_swap", since = "CURRENT_RUSTC_VERSION")] #[rustc_diagnostic_item = "mem_swap"] pub const fn swap<T>(x: &mut T, y: &mut T) { // SAFETY: `&mut` guarantees these are typed readable and writable diff --git a/library/core/src/ptr/mod.rs b/library/core/src/ptr/mod.rs index e6e13eaff7b..ac074c097d9 100644 --- a/library/core/src/ptr/mod.rs +++ b/library/core/src/ptr/mod.rs @@ -1009,9 +1009,8 @@ pub const fn slice_from_raw_parts_mut<T>(data: *mut T, len: usize) -> *mut [T] { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_const_unstable(feature = "const_swap", issue = "83163")] +#[rustc_const_stable(feature = "const_swap", since = "CURRENT_RUSTC_VERSION")] #[rustc_diagnostic_item = "ptr_swap"] -#[rustc_const_stable_indirect] pub const unsafe fn swap<T>(x: *mut T, y: *mut T) { // Give ourselves some scratch space to work with. // We do not have to worry about drops: `MaybeUninit` does nothing when dropped. diff --git a/library/core/src/ptr/mut_ptr.rs b/library/core/src/ptr/mut_ptr.rs index 34567917b52..d75d570a969 100644 --- a/library/core/src/ptr/mut_ptr.rs +++ b/library/core/src/ptr/mut_ptr.rs @@ -1594,7 +1594,7 @@ impl<T: ?Sized> *mut T { /// /// [`ptr::swap`]: crate::ptr::swap() #[stable(feature = "pointer_methods", since = "1.26.0")] - #[rustc_const_unstable(feature = "const_swap", issue = "83163")] + #[rustc_const_stable(feature = "const_swap", since = "CURRENT_RUSTC_VERSION")] #[inline(always)] pub const unsafe fn swap(self, with: *mut T) where diff --git a/library/core/src/ptr/non_null.rs b/library/core/src/ptr/non_null.rs index e0ba469272e..1058fa42cc1 100644 --- a/library/core/src/ptr/non_null.rs +++ b/library/core/src/ptr/non_null.rs @@ -1146,7 +1146,7 @@ impl<T: ?Sized> NonNull<T> { /// [`ptr::swap`]: crate::ptr::swap() #[inline(always)] #[stable(feature = "non_null_convenience", since = "1.80.0")] - #[rustc_const_unstable(feature = "const_swap", issue = "83163")] + #[rustc_const_stable(feature = "const_swap", since = "CURRENT_RUSTC_VERSION")] pub const unsafe fn swap(self, with: NonNull<T>) where T: Sized, diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index ab65f9d6d2f..3e8c698a7ab 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -913,7 +913,7 @@ impl<T> [T] { /// assert!(v == ["a", "b", "e", "d", "c"]); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_unstable(feature = "const_swap", issue = "83163")] + #[rustc_const_stable(feature = "const_swap", since = "CURRENT_RUSTC_VERSION")] #[inline] #[track_caller] pub const fn swap(&mut self, a: usize, b: usize) { diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs index 9f0ab7b3f29..fcb26530fcf 100644 --- a/library/core/tests/lib.rs +++ b/library/core/tests/lib.rs @@ -15,7 +15,6 @@ #![feature(clone_to_uninit)] #![feature(const_black_box)] #![feature(const_eval_select)] -#![feature(const_swap)] #![feature(const_swap_nonoverlapping)] #![feature(const_trait_impl)] #![feature(core_intrinsics)] diff --git a/tests/ui/consts/issue-94371.rs b/tests/ui/consts/issue-94371.rs index ad9ee9a5a3e..b2dd7053c1f 100644 --- a/tests/ui/consts/issue-94371.rs +++ b/tests/ui/consts/issue-94371.rs @@ -1,7 +1,5 @@ //@ check-pass -#![feature(const_swap)] - #[repr(C)] struct Demo(u64, bool, u64, u32, u64, u64, u64); diff --git a/tests/ui/consts/qualif-indirect-mutation-fail.rs b/tests/ui/consts/qualif-indirect-mutation-fail.rs index c6e08a557c8..0f59a86b7cc 100644 --- a/tests/ui/consts/qualif-indirect-mutation-fail.rs +++ b/tests/ui/consts/qualif-indirect-mutation-fail.rs @@ -1,6 +1,5 @@ //@ compile-flags: --crate-type=lib #![feature(const_precise_live_drops)] -#![feature(const_swap)] // Mutable borrow of a field with drop impl. pub const fn f() { diff --git a/tests/ui/consts/qualif-indirect-mutation-fail.stderr b/tests/ui/consts/qualif-indirect-mutation-fail.stderr index f706b7cf699..e76d7d3b670 100644 --- a/tests/ui/consts/qualif-indirect-mutation-fail.stderr +++ b/tests/ui/consts/qualif-indirect-mutation-fail.stderr @@ -1,5 +1,5 @@ error[E0493]: destructor of `Option<String>` cannot be evaluated at compile-time - --> $DIR/qualif-indirect-mutation-fail.rs:13:9 + --> $DIR/qualif-indirect-mutation-fail.rs:12:9 | LL | let mut x = None; | ^^^^^ the destructor for this type cannot be evaluated in constants @@ -19,13 +19,13 @@ note: inside `std::ptr::drop_in_place::<String> - shim(Some(String))` note: inside `std::ptr::drop_in_place::<Option<String>> - shim(Some(Option<String>))` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL note: inside `A1` - --> $DIR/qualif-indirect-mutation-fail.rs:19:1 + --> $DIR/qualif-indirect-mutation-fail.rs:18:1 | LL | }; | ^ error[E0493]: destructor of `Option<String>` cannot be evaluated at compile-time - --> $DIR/qualif-indirect-mutation-fail.rs:29:9 + --> $DIR/qualif-indirect-mutation-fail.rs:28:9 | LL | let _z = x; | ^^ the destructor for this type cannot be evaluated in constants @@ -44,13 +44,13 @@ note: inside `std::ptr::drop_in_place::<String> - shim(Some(String))` note: inside `std::ptr::drop_in_place::<Option<String>> - shim(Some(Option<String>))` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL note: inside `A2` - --> $DIR/qualif-indirect-mutation-fail.rs:30:1 + --> $DIR/qualif-indirect-mutation-fail.rs:29:1 | LL | }; | ^ error[E0493]: destructor of `(u32, Option<String>)` cannot be evaluated at compile-time - --> $DIR/qualif-indirect-mutation-fail.rs:7:9 + --> $DIR/qualif-indirect-mutation-fail.rs:6:9 | LL | let mut a: (u32, Option<String>) = (0, None); | ^^^^^ the destructor for this type cannot be evaluated in constant functions @@ -59,7 +59,7 @@ LL | } | - value is dropped here error[E0493]: destructor of `Option<T>` cannot be evaluated at compile-time - --> $DIR/qualif-indirect-mutation-fail.rs:34:9 + --> $DIR/qualif-indirect-mutation-fail.rs:33:9 | LL | let x: Option<T> = None; | ^ the destructor for this type cannot be evaluated in constant functions @@ -68,7 +68,7 @@ LL | } | - value is dropped here error[E0493]: destructor of `Option<T>` cannot be evaluated at compile-time - --> $DIR/qualif-indirect-mutation-fail.rs:42:9 + --> $DIR/qualif-indirect-mutation-fail.rs:41:9 | LL | let _y = x; | ^^ the destructor for this type cannot be evaluated in constant functions @@ -76,7 +76,7 @@ LL | } | - value is dropped here error[E0493]: destructor of `Option<String>` cannot be evaluated at compile-time - --> $DIR/qualif-indirect-mutation-fail.rs:50:9 + --> $DIR/qualif-indirect-mutation-fail.rs:49:9 | LL | let mut y: Option<String> = None; | ^^^^^ the destructor for this type cannot be evaluated in constant functions @@ -85,7 +85,7 @@ LL | } | - value is dropped here error[E0493]: destructor of `Option<String>` cannot be evaluated at compile-time - --> $DIR/qualif-indirect-mutation-fail.rs:47:9 + --> $DIR/qualif-indirect-mutation-fail.rs:46:9 | LL | let mut x: Option<String> = None; | ^^^^^ the destructor for this type cannot be evaluated in constant functions @@ -94,7 +94,7 @@ LL | } | - value is dropped here error[E0493]: destructor of `Option<String>` cannot be evaluated at compile-time - --> $DIR/qualif-indirect-mutation-fail.rs:60:9 + --> $DIR/qualif-indirect-mutation-fail.rs:59:9 | LL | let y: Option<String> = None; | ^ the destructor for this type cannot be evaluated in constant functions @@ -103,7 +103,7 @@ LL | } | - value is dropped here error[E0493]: destructor of `Option<String>` cannot be evaluated at compile-time - --> $DIR/qualif-indirect-mutation-fail.rs:57:9 + --> $DIR/qualif-indirect-mutation-fail.rs:56:9 | LL | let x: Option<String> = None; | ^ the destructor for this type cannot be evaluated in constant functions diff --git a/tests/ui/thread-local/thread-local-static.rs b/tests/ui/thread-local/thread-local-static.rs index af30f538366..422dac41002 100644 --- a/tests/ui/thread-local/thread-local-static.rs +++ b/tests/ui/thread-local/thread-local-static.rs @@ -1,7 +1,6 @@ //@ edition:2018 #![feature(thread_local)] -#![feature(const_swap)] #![allow(static_mut_refs)] #[thread_local] diff --git a/tests/ui/thread-local/thread-local-static.stderr b/tests/ui/thread-local/thread-local-static.stderr index 3bc1aec00c1..bb078b79748 100644 --- a/tests/ui/thread-local/thread-local-static.stderr +++ b/tests/ui/thread-local/thread-local-static.stderr @@ -1,5 +1,5 @@ error[E0133]: use of mutable static is unsafe and requires unsafe function or block - --> $DIR/thread-local-static.rs:10:28 + --> $DIR/thread-local-static.rs:9:28 | LL | std::mem::swap(x, &mut STATIC_VAR_2) | ^^^^^^^^^^^^ use of mutable static @@ -7,7 +7,7 @@ LL | std::mem::swap(x, &mut STATIC_VAR_2) = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior error[E0625]: thread-local statics cannot be accessed at compile-time - --> $DIR/thread-local-static.rs:10:28 + --> $DIR/thread-local-static.rs:9:28 | LL | std::mem::swap(x, &mut STATIC_VAR_2) | ^^^^^^^^^^^^ |
