@@ -518,7 +518,8 @@ macro_rules! __pinned_drop {
518
518
}
519
519
) ,
520
520
) => {
521
- // SAFETY: TODO.
521
+ // SAFETY: The `OnlyCallFromDrop` token ensures the drop function can only be called
522
+ // when the struct is properly pinned.
522
523
unsafe $( $impl_sig) * {
523
524
// Inherit all attributes and the type/ident tokens for the signature.
524
525
$( #[ $( $attr) * ] ) *
@@ -878,7 +879,8 @@ macro_rules! __pin_data {
878
879
}
879
880
}
880
881
881
- // SAFETY: TODO.
882
+ // SAFETY: `__ThePinData` correctly represents the pinning structure of the original type
883
+ // and the associated type `Datee` correctly refers to the original struct type.
882
884
unsafe impl <$( $impl_generics) * >
883
885
$crate:: __internal:: PinData for __ThePinData<$( $ty_generics) * >
884
886
where $( $whr) *
@@ -1005,7 +1007,7 @@ macro_rules! __pin_data {
1005
1007
slot: * mut $p_type,
1006
1008
init: impl $crate:: PinInit <$p_type, E >,
1007
1009
) -> :: core:: result:: Result <( ) , E > {
1008
- // SAFETY: TODO .
1010
+ // SAFETY: `slot` points to valid, uninitialized memory for a `$p_type` .
1009
1011
unsafe { $crate:: PinInit :: __pinned_init( init, slot) }
1010
1012
}
1011
1013
) *
@@ -1016,7 +1018,7 @@ macro_rules! __pin_data {
1016
1018
slot: * mut $type,
1017
1019
init: impl $crate:: Init <$type, E >,
1018
1020
) -> :: core:: result:: Result <( ) , E > {
1019
- // SAFETY: TODO .
1021
+ // SAFETY: `slot` points to valid, uninitialized memory for a `$type` .
1020
1022
unsafe { $crate:: Init :: __init( init, slot) }
1021
1023
}
1022
1024
) *
@@ -1132,7 +1134,8 @@ macro_rules! __init_internal {
1132
1134
struct __InitOk;
1133
1135
// Get the data about fields from the supplied type.
1134
1136
//
1135
- // SAFETY: TODO.
1137
+ // SAFETY: The `$get_data()` function only returns metadata about the type's pinning structure.
1138
+ // No memory is accessed, only type-level information is retrieved.
1136
1139
let data = unsafe {
1137
1140
use $crate:: __internal:: $has_data;
1138
1141
// Here we abuse `paste!` to retokenize `$t`. Declarative macros have some internal
@@ -1188,7 +1191,8 @@ macro_rules! __init_internal {
1188
1191
let init = move |slot| -> :: core:: result:: Result <( ) , $err> {
1189
1192
init( slot) . map( |__InitOk| ( ) )
1190
1193
} ;
1191
- // SAFETY: TODO.
1194
+ // SAFETY: The closure property initializes the target memory location. Error handling
1195
+ // ensures memory is left in a valid state if initialization fails.
1192
1196
let init = unsafe { $crate:: $construct_closure:: <_, $err>( init) } ;
1193
1197
init
1194
1198
} } ;
@@ -1338,7 +1342,8 @@ macro_rules! __init_internal {
1338
1342
// Since we are in the closure that is never called, this will never get executed.
1339
1343
// We abuse `slot` to get the correct type inference here:
1340
1344
//
1341
- // SAFETY: TODO.
1345
+ // SAFETY: This is unreachable code that is used solely for compile-time type checking,
1346
+ // it is never executed.
1342
1347
unsafe {
1343
1348
// Here we abuse `paste!` to retokenize `$t`. Declarative macros have some internal
1344
1349
// information that is associated to already parsed fragments, so a path fragment
0 commit comments