Revert "Revert effects of PRs 81167 and 83091."
This reverts commit 9d96b0ed8c0f37bc09e737e1ab5880e8f5dd43f2.
This commit is contained in:
parent
543ab99640
commit
5fbb1354ce
@ -682,7 +682,8 @@ pub unsafe fn uninitialized<T>() -> T {
|
|||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub fn swap<T>(x: &mut T, y: &mut T) {
|
#[rustc_const_unstable(feature = "const_swap", issue = "83163")]
|
||||||
|
pub const fn swap<T>(x: &mut T, y: &mut T) {
|
||||||
// SAFETY: the raw pointers have been created from safe mutable references satisfying all the
|
// SAFETY: the raw pointers have been created from safe mutable references satisfying all the
|
||||||
// constraints on `ptr::swap_nonoverlapping_one`
|
// constraints on `ptr::swap_nonoverlapping_one`
|
||||||
unsafe {
|
unsafe {
|
||||||
@ -812,7 +813,8 @@ pub fn take<T: Default>(dest: &mut T) -> T {
|
|||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[must_use = "if you don't need the old value, you can just assign the new value directly"]
|
#[must_use = "if you don't need the old value, you can just assign the new value directly"]
|
||||||
pub fn replace<T>(dest: &mut T, src: T) -> T {
|
#[rustc_const_unstable(feature = "const_replace", issue = "83164")]
|
||||||
|
pub const fn replace<T>(dest: &mut T, src: T) -> T {
|
||||||
// SAFETY: We read from `dest` but directly write `src` into it afterwards,
|
// SAFETY: We read from `dest` but directly write `src` into it afterwards,
|
||||||
// such that the old value is not duplicated. Nothing is dropped and
|
// such that the old value is not duplicated. Nothing is dropped and
|
||||||
// nothing here can panic.
|
// nothing here can panic.
|
||||||
|
@ -430,7 +430,8 @@ pub const unsafe fn swap_nonoverlapping<T>(x: *mut T, y: *mut T, count: usize) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub(crate) unsafe fn swap_nonoverlapping_one<T>(x: *mut T, y: *mut T) {
|
#[rustc_const_unstable(feature = "const_swap", issue = "83163")]
|
||||||
|
pub(crate) const unsafe fn swap_nonoverlapping_one<T>(x: *mut T, y: *mut T) {
|
||||||
// NOTE(eddyb) SPIR-V's Logical addressing model doesn't allow for arbitrary
|
// NOTE(eddyb) SPIR-V's Logical addressing model doesn't allow for arbitrary
|
||||||
// reinterpretation of values as (chunkable) byte arrays, and the loop in the
|
// reinterpretation of values as (chunkable) byte arrays, and the loop in the
|
||||||
// block optimization in `swap_nonoverlapping_bytes` is hard to rewrite back
|
// block optimization in `swap_nonoverlapping_bytes` is hard to rewrite back
|
||||||
@ -563,7 +564,8 @@ const unsafe fn swap_nonoverlapping_bytes(x: *mut u8, y: *mut u8, len: usize) {
|
|||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub unsafe fn replace<T>(dst: *mut T, mut src: T) -> T {
|
#[rustc_const_unstable(feature = "const_replace", issue = "83164")]
|
||||||
|
pub const unsafe fn replace<T>(dst: *mut T, mut src: T) -> T {
|
||||||
// SAFETY: the caller must guarantee that `dst` is valid to be
|
// SAFETY: the caller must guarantee that `dst` is valid to be
|
||||||
// cast to a mutable reference (valid for writes, aligned, initialized),
|
// cast to a mutable reference (valid for writes, aligned, initialized),
|
||||||
// and cannot overlap `src` since `dst` must point to a distinct
|
// and cannot overlap `src` since `dst` must point to a distinct
|
||||||
@ -869,10 +871,12 @@ pub const unsafe fn read_unaligned<T>(src: *const T) -> T {
|
|||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub unsafe fn write<T>(dst: *mut T, src: T) {
|
#[rustc_const_unstable(feature = "const_ptr_write", issue = "none")]
|
||||||
|
pub const unsafe fn write<T>(dst: *mut T, src: T) {
|
||||||
// We are calling the intrinsics directly to avoid function calls in the generated code
|
// We are calling the intrinsics directly to avoid function calls in the generated code
|
||||||
// as `intrinsics::copy_nonoverlapping` is a wrapper function.
|
// as `intrinsics::copy_nonoverlapping` is a wrapper function.
|
||||||
extern "rust-intrinsic" {
|
extern "rust-intrinsic" {
|
||||||
|
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "none")]
|
||||||
fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize);
|
fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1002,8 +1002,9 @@ impl<T: ?Sized> *mut T {
|
|||||||
///
|
///
|
||||||
/// [`ptr::write`]: crate::ptr::write()
|
/// [`ptr::write`]: crate::ptr::write()
|
||||||
#[stable(feature = "pointer_methods", since = "1.26.0")]
|
#[stable(feature = "pointer_methods", since = "1.26.0")]
|
||||||
|
#[rustc_const_unstable(feature = "const_ptr_write", issue = "none")]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub unsafe fn write(self, val: T)
|
pub const unsafe fn write(self, val: T)
|
||||||
where
|
where
|
||||||
T: Sized,
|
T: Sized,
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user