@@ -2257,12 +2257,23 @@ extern "rust-intrinsic" {
22572257 /// This is an implementation detail of [`crate::ptr::read`] and should
22582258 /// not be used anywhere else. See its comments for why this exists.
22592259 ///
2260- /// This intrinsic can *only* be called where the argument is a local without
2261- /// projections (`read_via_copy(p )`, not `read_via_copy(*p )`) so that it
2260+ /// This intrinsic can *only* be called where the pointer is a local without
2261+ /// projections (`read_via_copy(ptr )`, not `read_via_copy(*ptr )`) so that it
22622262 /// trivially obeys runtime-MIR rules about derefs in operands.
22632263 #[ rustc_const_unstable( feature = "const_ptr_read" , issue = "80377" ) ]
22642264 #[ rustc_nounwind]
2265- pub fn read_via_copy < T > ( p : * const T ) -> T ;
2265+ pub fn read_via_copy < T > ( ptr : * const T ) -> T ;
2266+
2267+ /// This is an implementation detail of [`crate::ptr::write`] and should
2268+ /// not be used anywhere else. See its comments for why this exists.
2269+ ///
2270+ /// This intrinsic can *only* be called where the pointer is a local without
2271+ /// projections (`write_via_move(ptr, x)`, not `write_via_move(*ptr, x)`) so
2272+ /// that it trivially obeys runtime-MIR rules about derefs in operands.
2273+ #[ cfg( not( bootstrap) ) ]
2274+ #[ rustc_const_unstable( feature = "const_ptr_write" , issue = "86302" ) ]
2275+ #[ rustc_nounwind]
2276+ pub fn write_via_move < T > ( ptr : * mut T , value : T ) ;
22662277
22672278 /// Returns the value of the discriminant for the variant in 'v';
22682279 /// if `T` has no discriminant, returns `0`.
@@ -2828,3 +2839,16 @@ pub const unsafe fn transmute_unchecked<Src, Dst>(src: Src) -> Dst {
28282839 // SAFETY: It's a transmute -- the caller promised it's fine.
28292840 unsafe { transmute_copy ( & ManuallyDrop :: new ( src) ) }
28302841}
2842+
2843+ /// Polyfill for bootstrap
2844+ #[ cfg( bootstrap) ]
2845+ pub const unsafe fn write_via_move < T > ( ptr : * mut T , value : T ) {
2846+ use crate :: mem:: * ;
2847+ // SAFETY: the caller must guarantee that `dst` is valid for writes.
2848+ // `dst` cannot overlap `src` because the caller has mutable access
2849+ // to `dst` while `src` is owned by this function.
2850+ unsafe {
2851+ copy_nonoverlapping :: < T > ( & value, ptr, 1 ) ;
2852+ forget ( value) ;
2853+ }
2854+ }
0 commit comments