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;
100
100
pub const unsafe fn unreachable_unchecked ( ) -> ! {
101
101
// SAFETY: the safety contract for `intrinsics::unreachable` must
102
102
// be upheld by the caller.
103
- unsafe { intrinsics:: unreachable ( ) }
103
+ unsafe {
104
+ intrinsics:: assert_unsafe_precondition!( ( ) => false ) ;
105
+ intrinsics:: unreachable ( )
106
+ }
104
107
}
105
108
106
109
/// 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 {
1114
1114
// Also, since we just wrote a valid value into `tmp`, it is guaranteed
1115
1115
// to be properly initialized.
1116
1116
unsafe {
1117
+ assert_unsafe_precondition ! ( [ T ] ( src: * const T ) => is_aligned_and_not_null( src) ) ;
1117
1118
copy_nonoverlapping ( src, tmp. as_mut_ptr ( ) , 1 ) ;
1118
1119
tmp. assume_init ( )
1119
1120
}
@@ -1307,6 +1308,7 @@ pub const unsafe fn write<T>(dst: *mut T, src: T) {
1307
1308
// `dst` cannot overlap `src` because the caller has mutable access
1308
1309
// to `dst` while `src` is owned by this function.
1309
1310
unsafe {
1311
+ assert_unsafe_precondition ! ( [ T ] ( dst: * mut T ) => is_aligned_and_not_null( dst) ) ;
1310
1312
copy_nonoverlapping ( & src as * const T , dst, 1 ) ;
1311
1313
intrinsics:: forget ( src) ;
1312
1314
}
You can’t perform that action at this time.
0 commit comments