Skip to content

Commit f9b6f51

Browse files
committed
cfg out the check in read
1 parent 2986cc0 commit f9b6f51

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

library/core/src/ptr/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1426,6 +1426,7 @@ pub const unsafe fn read<T>(src: *const T) -> T {
14261426

14271427
// SAFETY: the caller must guarantee that `src` is valid for reads.
14281428
unsafe {
1429+
#[cfg(debug_assertions)]
14291430
ub_checks::assert_unsafe_precondition!(
14301431
check_language_ub,
14311432
"ptr::read requires that the pointer argument is aligned and non-null",
@@ -1634,7 +1635,6 @@ pub const unsafe fn write<T>(dst: *mut T, src: T) {
16341635
// `dst` cannot overlap `src` because the caller has mutable access
16351636
// to `dst` while `src` is owned by this function.
16361637
unsafe {
1637-
#[cfg(debug_assertions)]
16381638
ub_checks::assert_unsafe_precondition!(
16391639
check_language_ub,
16401640
"ptr::write requires that the pointer argument is aligned and non-null",

0 commit comments

Comments
 (0)