|
371 | 371 | use crate::cmp::Ordering;
|
372 | 372 | use crate::fmt;
|
373 | 373 | use crate::hash;
|
374 |
| -use crate::intrinsics::{ |
375 |
| - self, assert_unsafe_precondition, is_aligned_and_not_null, is_nonoverlapping, |
376 |
| -}; |
| 374 | +use crate::intrinsics; |
| 375 | +#[cfg(not(miri))] |
| 376 | +use crate::intrinsics::{assert_unsafe_precondition, is_aligned_and_not_null, is_nonoverlapping}; |
377 | 377 |
|
378 | 378 | use crate::mem::{self, MaybeUninit};
|
379 | 379 |
|
@@ -895,6 +895,7 @@ pub const unsafe fn swap_nonoverlapping<T>(x: *mut T, y: *mut T, count: usize) {
|
895 | 895 | };
|
896 | 896 | }
|
897 | 897 |
|
| 898 | + #[cfg(not(miri))] // This precondition is already always checked by Miri |
898 | 899 | // SAFETY: the caller must guarantee that `x` and `y` are
|
899 | 900 | // valid for writes and properly aligned.
|
900 | 901 | unsafe {
|
@@ -998,6 +999,7 @@ pub const unsafe fn replace<T>(dst: *mut T, mut src: T) -> T {
|
998 | 999 | // and cannot overlap `src` since `dst` must point to a distinct
|
999 | 1000 | // allocated object.
|
1000 | 1001 | unsafe {
|
| 1002 | + #[cfg(not(miri))] // This precondition is already always checked by Miri |
1001 | 1003 | assert_unsafe_precondition!(
|
1002 | 1004 | "ptr::replace requires that the pointer argument is aligned and non-null",
|
1003 | 1005 | [T](dst: *mut T) => is_aligned_and_not_null(dst)
|
@@ -1496,6 +1498,7 @@ pub const unsafe fn write_unaligned<T>(dst: *mut T, src: T) {
|
1496 | 1498 | pub unsafe fn read_volatile<T>(src: *const T) -> T {
|
1497 | 1499 | // SAFETY: the caller must uphold the safety contract for `volatile_load`.
|
1498 | 1500 | unsafe {
|
| 1501 | + #[cfg(not(miri))] // This precondition is already always checked by Miri |
1499 | 1502 | assert_unsafe_precondition!(
|
1500 | 1503 | "ptr::read_volatile requires that the pointer argument is aligned and non-null",
|
1501 | 1504 | [T](src: *const T) => is_aligned_and_not_null(src)
|
@@ -1570,6 +1573,7 @@ pub unsafe fn read_volatile<T>(src: *const T) -> T {
|
1570 | 1573 | pub unsafe fn write_volatile<T>(dst: *mut T, src: T) {
|
1571 | 1574 | // SAFETY: the caller must uphold the safety contract for `volatile_store`.
|
1572 | 1575 | unsafe {
|
| 1576 | + #[cfg(not(miri))] // This precondition is already always checked by Miri |
1573 | 1577 | assert_unsafe_precondition!(
|
1574 | 1578 | "ptr::write_volatile requires that the pointer argument is aligned and non-null",
|
1575 | 1579 | [T](dst: *mut T) => is_aligned_and_not_null(dst)
|
|
0 commit comments