File tree 2 files changed +11
-12
lines changed
2 files changed +11
-12
lines changed Original file line number Diff line number Diff line change @@ -768,13 +768,6 @@ extern "rust-intrinsic" {
768
768
#[ rustc_const_stable( feature = "const_size_of" , since = "1.40.0" ) ]
769
769
pub fn size_of < T > ( ) -> usize ;
770
770
771
- /// Moves a value to an uninitialized memory location.
772
- ///
773
- /// Drop glue is not run on the destination.
774
- ///
775
- /// The stabilized version of this intrinsic is [`core::ptr::write`](crate::ptr::write).
776
- pub fn move_val_init < T > ( dst : * mut T , src : T ) ;
777
-
778
771
/// The minimum alignment of a type.
779
772
///
780
773
/// The stabilized version of this intrinsic is [`core::mem::align_of`](crate::mem::align_of).
Original file line number Diff line number Diff line change @@ -883,12 +883,18 @@ pub const unsafe fn read_unaligned<T>(src: *const T) -> T {
883
883
#[ inline]
884
884
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
885
885
pub unsafe fn write < T > ( dst : * mut T , src : T ) {
886
- if cfg ! ( debug_assertions) && !is_aligned_and_not_null ( dst) {
887
- // Not panicking to keep codegen impact smaller.
888
- abort ( ) ;
886
+ // We are calling the intrinsics directly to avoid function calls in the generated code.
887
+ extern "rust-intrinsic" {
888
+ fn copy_nonoverlapping < T > ( src : * const T , dst : * mut T , count : usize ) ;
889
+ }
890
+
891
+ // SAFETY: the caller must guarantee that `dst` is valid for writes.
892
+ // `dst` cannot overlap `src` because the caller has mutable access
893
+ // to `dst` while `src` is owned by this function.
894
+ unsafe {
895
+ copy_nonoverlapping ( & src as * const T , dst, 1 ) ;
896
+ intrinsics:: forget ( src) ;
889
897
}
890
- // SAFETY: the caller must uphold the safety contract for `move_val_init`.
891
- unsafe { intrinsics:: move_val_init ( & mut * dst, src) }
892
898
}
893
899
894
900
/// Overwrites a memory location with the given value without reading or
You can’t perform that action at this time.
0 commit comments