File tree Expand file tree Collapse file tree 2 files changed +6
-1
lines changed
Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -100,7 +100,10 @@ use crate::intrinsics;
100100pub const unsafe fn unreachable_unchecked ( ) -> ! {
101101 // SAFETY: the safety contract for `intrinsics::unreachable` must
102102 // be upheld by the caller.
103- unsafe { intrinsics:: unreachable ( ) }
103+ unsafe {
104+ intrinsics:: assert_unsafe_precondition!( ( ) => false ) ;
105+ intrinsics:: unreachable ( )
106+ }
104107}
105108
106109/// Emits a machine instruction to signal the processor that it is running in
Original file line number Diff line number Diff line change @@ -1114,6 +1114,7 @@ pub const unsafe fn read<T>(src: *const T) -> T {
11141114 // Also, since we just wrote a valid value into `tmp`, it is guaranteed
11151115 // to be properly initialized.
11161116 unsafe {
1117+ assert_unsafe_precondition ! ( [ T ] ( src: * const T ) => is_aligned_and_not_null( src) ) ;
11171118 copy_nonoverlapping ( src, tmp. as_mut_ptr ( ) , 1 ) ;
11181119 tmp. assume_init ( )
11191120 }
@@ -1307,6 +1308,7 @@ pub const unsafe fn write<T>(dst: *mut T, src: T) {
13071308 // `dst` cannot overlap `src` because the caller has mutable access
13081309 // to `dst` while `src` is owned by this function.
13091310 unsafe {
1311+ assert_unsafe_precondition ! ( [ T ] ( dst: * mut T ) => is_aligned_and_not_null( dst) ) ;
13101312 copy_nonoverlapping ( & src as * const T , dst, 1 ) ;
13111313 intrinsics:: forget ( src) ;
13121314 }
You can’t perform that action at this time.
0 commit comments