Skip to content

Commit ff7e044

Browse files
committed
get rid of real_intrinsics module
instead import intrinsics locally in their wrapper functions
1 parent 61d286e commit ff7e044

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
@@ -1298,30 +1298,10 @@ extern "rust-intrinsic" {
12981298
pub fn nontemporal_store<T>(ptr: *mut T, val: T);
12991299
}
13001300

1301-
mod real_intrinsics {
1302-
extern "rust-intrinsic" {
1303-
/// Copies `count * size_of::<T>()` bytes from `src` to `dst`. The source
1304-
/// and destination must *not* overlap.
1305-
/// For the full docs, see the stabilized wrapper [`copy_nonoverlapping`].
1306-
///
1307-
/// [`copy_nonoverlapping`]: ../../std/ptr/fn.copy_nonoverlapping.html
1308-
pub fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize);
1309-
1310-
/// Copies `count * size_of::<T>()` bytes from `src` to `dst`. The source
1311-
/// and destination may overlap.
1312-
/// For the full docs, see the stabilized wrapper [`copy`].
1313-
///
1314-
/// [`copy`]: ../../std/ptr/fn.copy.html
1315-
pub fn copy<T>(src: *const T, dst: *mut T, count: usize);
1316-
1317-
/// Sets `count * size_of::<T>()` bytes of memory starting at `dst` to
1318-
/// `val`.
1319-
/// For the full docs, see the stabilized wrapper [`write_bytes`].
1320-
///
1321-
/// [`write_bytes`]: ../../std/ptr/fn.write_bytes.html
1322-
pub fn write_bytes<T>(dst: *mut T, val: u8, count: usize);
1323-
}
1324-
}
1301+
// Some functions are defined here because they accidentally got made
1302+
// available in this module on stable. See <https://github.com/rust-lang/rust/issues/15702>.
1303+
// (`transmute` also falls into this category, but it cannot be wrapped due to the
1304+
// check that `T` and `U` have the same size.)
13251305

13261306
/// Copies `count * size_of::<T>()` bytes from `src` to `dst`. The source
13271307
/// and destination must *not* overlap.
@@ -1409,7 +1389,10 @@ mod real_intrinsics {
14091389
#[stable(feature = "rust1", since = "1.0.0")]
14101390
#[inline]
14111391
pub unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize) {
1412-
real_intrinsics::copy_nonoverlapping(src, dst, count);
1392+
extern "rust-intrinsic" {
1393+
fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize);
1394+
}
1395+
copy_nonoverlapping(src, dst, count);
14131396
}
14141397

14151398
/// Copies `count * size_of::<T>()` bytes from `src` to `dst`. The source
@@ -1466,7 +1449,10 @@ pub unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize) {
14661449
#[stable(feature = "rust1", since = "1.0.0")]
14671450
#[inline]
14681451
pub unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
1469-
real_intrinsics::copy(src, dst, count)
1452+
extern "rust-intrinsic" {
1453+
fn copy<T>(src: *const T, dst: *mut T, count: usize);
1454+
}
1455+
copy(src, dst, count)
14701456
}
14711457

14721458
/// Sets `count * size_of::<T>()` bytes of memory starting at `dst` to
@@ -1544,5 +1530,8 @@ pub unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
15441530
#[stable(feature = "rust1", since = "1.0.0")]
15451531
#[inline]
15461532
pub unsafe fn write_bytes<T>(dst: *mut T, val: u8, count: usize) {
1547-
real_intrinsics::write_bytes(dst, val, count)
1533+
extern "rust-intrinsic" {
1534+
fn write_bytes<T>(dst: *mut T, val: u8, count: usize);
1535+
}
1536+
write_bytes(dst, val, count)
15481537
}

0 commit comments

Comments
 (0)