@@ -2257,12 +2257,23 @@ extern "rust-intrinsic" {
2257
2257
/// This is an implementation detail of [`crate::ptr::read`] and should
2258
2258
/// not be used anywhere else. See its comments for why this exists.
2259
2259
///
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
2262
2262
/// trivially obeys runtime-MIR rules about derefs in operands.
2263
2263
#[ rustc_const_unstable( feature = "const_ptr_read" , issue = "80377" ) ]
2264
2264
#[ 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 ) ;
2266
2277
2267
2278
/// Returns the value of the discriminant for the variant in 'v';
2268
2279
/// if `T` has no discriminant, returns `0`.
@@ -2828,3 +2839,16 @@ pub const unsafe fn transmute_unchecked<Src, Dst>(src: Src) -> Dst {
2828
2839
// SAFETY: It's a transmute -- the caller promised it's fine.
2829
2840
unsafe { transmute_copy ( & ManuallyDrop :: new ( src) ) }
2830
2841
}
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