244
244
//! struct __InitOk;
245
245
//! // This is the expansion of `t,`, which is syntactic sugar for `t: t,`.
246
246
//! {
247
- //! unsafe { ::core::ptr::write(::core::addr_of_mut!(( *slot).t) , t) };
247
+ //! unsafe { ::core::ptr::write(&raw mut ( *slot).t, t) };
248
248
//! }
249
249
//! // Since initialization could fail later (not in this case, since the
250
250
//! // error type is `Infallible`) we will need to drop this field if there
251
251
//! // is an error later. This `DropGuard` will drop the field when it gets
252
252
//! // dropped and has not yet been forgotten.
253
253
//! let __t_guard = unsafe {
254
- //! ::pin_init::__internal::DropGuard::new(::core::addr_of_mut!(( *slot).t) )
254
+ //! ::pin_init::__internal::DropGuard::new(&raw mut ( *slot).t)
255
255
//! };
256
256
//! // Expansion of `x: 0,`:
257
257
//! // Since this can be an arbitrary expression we cannot place it inside
258
258
//! // of the `unsafe` block, so we bind it here.
259
259
//! {
260
260
//! let x = 0;
261
- //! unsafe { ::core::ptr::write(::core::addr_of_mut!(( *slot).x) , x) };
261
+ //! unsafe { ::core::ptr::write(&raw mut ( *slot).x, x) };
262
262
//! }
263
263
//! // We again create a `DropGuard`.
264
264
//! let __x_guard = unsafe {
265
- //! ::pin_init::__internal::DropGuard::new(::core::addr_of_mut!(( *slot).x) )
265
+ //! ::pin_init::__internal::DropGuard::new(&raw mut ( *slot).x)
266
266
//! };
267
267
//! // Since initialization has successfully completed, we can now forget
268
268
//! // the guards. This is not `mem::forget`, since we only have
459
459
//! {
460
460
//! struct __InitOk;
461
461
//! {
462
- //! unsafe { ::core::ptr::write(::core::addr_of_mut!(( *slot).a) , a) };
462
+ //! unsafe { ::core::ptr::write(&raw mut ( *slot).a, a) };
463
463
//! }
464
464
//! let __a_guard = unsafe {
465
- //! ::pin_init::__internal::DropGuard::new(::core::addr_of_mut!(( *slot).a) )
465
+ //! ::pin_init::__internal::DropGuard::new(&raw mut ( *slot).a)
466
466
//! };
467
467
//! let init = Bar::new(36);
468
- //! unsafe { data.b(::core::addr_of_mut!(( *slot).b) , b)? };
468
+ //! unsafe { data.b(&raw mut ( *slot).b, b)? };
469
469
//! let __b_guard = unsafe {
470
- //! ::pin_init::__internal::DropGuard::new(::core::addr_of_mut!(( *slot).b) )
470
+ //! ::pin_init::__internal::DropGuard::new(&raw mut ( *slot).b)
471
471
//! };
472
472
//! ::core::mem::forget(__b_guard);
473
473
//! ::core::mem::forget(__a_guard);
@@ -1215,15 +1215,15 @@ macro_rules! __init_internal {
1215
1215
// SAFETY: `slot` is valid, because we are inside of an initializer closure, we
1216
1216
// return when an error/panic occurs.
1217
1217
// We also use the `data` to require the correct trait (`Init` or `PinInit`) for `$field`.
1218
- unsafe { $data. $field( :: core :: ptr :: addr_of_mut! ( ( * $slot) . $field) , init) ? } ;
1218
+ unsafe { $data. $field( & raw mut ( * $slot) . $field, init) ? } ;
1219
1219
// Create the drop guard:
1220
1220
//
1221
1221
// We rely on macro hygiene to make it impossible for users to access this local variable.
1222
1222
// We use `paste!` to create new hygiene for `$field`.
1223
1223
$crate:: macros:: paste! {
1224
1224
// SAFETY: We forget the guard later when initialization has succeeded.
1225
1225
let [ < __ $field _guard >] = unsafe {
1226
- $crate:: __internal:: DropGuard :: new( :: core :: ptr :: addr_of_mut! ( ( * $slot) . $field) )
1226
+ $crate:: __internal:: DropGuard :: new( & raw mut ( * $slot) . $field)
1227
1227
} ;
1228
1228
1229
1229
$crate:: __init_internal!( init_slot( $use_data) :
@@ -1246,15 +1246,15 @@ macro_rules! __init_internal {
1246
1246
//
1247
1247
// SAFETY: `slot` is valid, because we are inside of an initializer closure, we
1248
1248
// return when an error/panic occurs.
1249
- unsafe { $crate:: Init :: __init( init, :: core :: ptr :: addr_of_mut! ( ( * $slot) . $field) ) ? } ;
1249
+ unsafe { $crate:: Init :: __init( init, & raw mut ( * $slot) . $field) ? } ;
1250
1250
// Create the drop guard:
1251
1251
//
1252
1252
// We rely on macro hygiene to make it impossible for users to access this local variable.
1253
1253
// We use `paste!` to create new hygiene for `$field`.
1254
1254
$crate:: macros:: paste! {
1255
1255
// SAFETY: We forget the guard later when initialization has succeeded.
1256
1256
let [ < __ $field _guard >] = unsafe {
1257
- $crate:: __internal:: DropGuard :: new( :: core :: ptr :: addr_of_mut! ( ( * $slot) . $field) )
1257
+ $crate:: __internal:: DropGuard :: new( & raw mut ( * $slot) . $field)
1258
1258
} ;
1259
1259
1260
1260
$crate:: __init_internal!( init_slot( ) :
@@ -1277,7 +1277,7 @@ macro_rules! __init_internal {
1277
1277
// Initialize the field.
1278
1278
//
1279
1279
// SAFETY: The memory at `slot` is uninitialized.
1280
- unsafe { :: core:: ptr:: write( :: core :: ptr :: addr_of_mut! ( ( * $slot) . $field) , $field) } ;
1280
+ unsafe { :: core:: ptr:: write( & raw mut ( * $slot) . $field, $field) } ;
1281
1281
}
1282
1282
// Create the drop guard:
1283
1283
//
@@ -1286,7 +1286,7 @@ macro_rules! __init_internal {
1286
1286
$crate:: macros:: paste! {
1287
1287
// SAFETY: We forget the guard later when initialization has succeeded.
1288
1288
let [ < __ $field _guard >] = unsafe {
1289
- $crate:: __internal:: DropGuard :: new( :: core :: ptr :: addr_of_mut! ( ( * $slot) . $field) )
1289
+ $crate:: __internal:: DropGuard :: new( & raw mut ( * $slot) . $field)
1290
1290
} ;
1291
1291
1292
1292
$crate:: __init_internal!( init_slot( $( $use_data) ?) :
0 commit comments