Skip to content

Commit 22244cf

Browse files
authored
Rollup merge of rust-lang#61501 - RalfJung:intrinsics, r=rkruppe
get rid of real_intrinsics module instead import intrinsics locally in their wrapper functions. (These functions are wrapper functions as a preparation to fixing rust-lang#53871.)
2 parents 97df867 + ff7e044 commit 22244cf

File tree

1 file changed

+16
-27
lines changed

1 file changed

+16
-27
lines changed

src/libcore/intrinsics.rs

+16-27
Original file line numberDiff line numberDiff line change
@@ -1326,30 +1326,10 @@ extern "rust-intrinsic" {
13261326
pub fn nontemporal_store<T>(ptr: *mut T, val: T);
13271327
}
13281328

1329-
mod real_intrinsics {
1330-
extern "rust-intrinsic" {
1331-
/// Copies `count * size_of::<T>()` bytes from `src` to `dst`. The source
1332-
/// and destination must *not* overlap.
1333-
/// For the full docs, see the stabilized wrapper [`copy_nonoverlapping`].
1334-
///
1335-
/// [`copy_nonoverlapping`]: ../../std/ptr/fn.copy_nonoverlapping.html
1336-
pub fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize);
1337-
1338-
/// Copies `count * size_of::<T>()` bytes from `src` to `dst`. The source
1339-
/// and destination may overlap.
1340-
/// For the full docs, see the stabilized wrapper [`copy`].
1341-
///
1342-
/// [`copy`]: ../../std/ptr/fn.copy.html
1343-
pub fn copy<T>(src: *const T, dst: *mut T, count: usize);
1344-
1345-
/// Sets `count * size_of::<T>()` bytes of memory starting at `dst` to
1346-
/// `val`.
1347-
/// For the full docs, see the stabilized wrapper [`write_bytes`].
1348-
///
1349-
/// [`write_bytes`]: ../../std/ptr/fn.write_bytes.html
1350-
pub fn write_bytes<T>(dst: *mut T, val: u8, count: usize);
1351-
}
1352-
}
1329+
// Some functions are defined here because they accidentally got made
1330+
// available in this module on stable. See <https://github.com/rust-lang/rust/issues/15702>.
1331+
// (`transmute` also falls into this category, but it cannot be wrapped due to the
1332+
// check that `T` and `U` have the same size.)
13531333

13541334
/// Copies `count * size_of::<T>()` bytes from `src` to `dst`. The source
13551335
/// and destination must *not* overlap.
@@ -1437,7 +1417,10 @@ mod real_intrinsics {
14371417
#[stable(feature = "rust1", since = "1.0.0")]
14381418
#[inline]
14391419
pub unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize) {
1440-
real_intrinsics::copy_nonoverlapping(src, dst, count);
1420+
extern "rust-intrinsic" {
1421+
fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize);
1422+
}
1423+
copy_nonoverlapping(src, dst, count);
14411424
}
14421425

14431426
/// Copies `count * size_of::<T>()` bytes from `src` to `dst`. The source
@@ -1494,7 +1477,10 @@ pub unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize) {
14941477
#[stable(feature = "rust1", since = "1.0.0")]
14951478
#[inline]
14961479
pub unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
1497-
real_intrinsics::copy(src, dst, count)
1480+
extern "rust-intrinsic" {
1481+
fn copy<T>(src: *const T, dst: *mut T, count: usize);
1482+
}
1483+
copy(src, dst, count)
14981484
}
14991485

15001486
/// Sets `count * size_of::<T>()` bytes of memory starting at `dst` to
@@ -1572,7 +1558,10 @@ pub unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
15721558
#[stable(feature = "rust1", since = "1.0.0")]
15731559
#[inline]
15741560
pub unsafe fn write_bytes<T>(dst: *mut T, val: u8, count: usize) {
1575-
real_intrinsics::write_bytes(dst, val, count)
1561+
extern "rust-intrinsic" {
1562+
fn write_bytes<T>(dst: *mut T, val: u8, count: usize);
1563+
}
1564+
write_bytes(dst, val, count)
15761565
}
15771566

15781567
// Simple bootstrap implementations of minnum/maxnum for stage0 compilation.

0 commit comments

Comments
 (0)