macros.rs (f8badd150763ae0f9c8482fabe0fdbac81735d34) | macros.rs (071cedc84e907f6984b3de3285ec2b077d3c3cdb) |
---|---|
1// SPDX-License-Identifier: Apache-2.0 OR MIT 2 3//! This module provides the macros that actually implement the proc-macros `pin_data` and 4//! `pinned_drop`. It also contains `__init_internal` the implementation of the `{try_}{pin_}init!` 5//! macros. 6//! 7//! These macros should never be called directly, since they expect their input to be 8//! in a certain format which is internal. If used incorrectly, these macros can lead to UB even in --- 1201 unchanged lines hidden (view full) --- 1210 ) => { 1211 unsafe { $crate::init::__internal::DropGuard::forget($field) }; 1212 1213 $crate::__init_internal!(forget_guards: 1214 @munch_fields($($rest)*), 1215 ); 1216 }; 1217} | 1// SPDX-License-Identifier: Apache-2.0 OR MIT 2 3//! This module provides the macros that actually implement the proc-macros `pin_data` and 4//! `pinned_drop`. It also contains `__init_internal` the implementation of the `{try_}{pin_}init!` 5//! macros. 6//! 7//! These macros should never be called directly, since they expect their input to be 8//! in a certain format which is internal. If used incorrectly, these macros can lead to UB even in --- 1201 unchanged lines hidden (view full) --- 1210 ) => { 1211 unsafe { $crate::init::__internal::DropGuard::forget($field) }; 1212 1213 $crate::__init_internal!(forget_guards: 1214 @munch_fields($($rest)*), 1215 ); 1216 }; 1217} |
1218 1219#[doc(hidden)] 1220#[macro_export] 1221macro_rules! __derive_zeroable { 1222 (parse_input: 1223 @sig( 1224 $(#[$($struct_attr:tt)*])* 1225 $vis:vis struct $name:ident 1226 $(where $($whr:tt)*)? 1227 ), 1228 @impl_generics($($impl_generics:tt)*), 1229 @ty_generics($($ty_generics:tt)*), 1230 @body({ 1231 $( 1232 $(#[$($field_attr:tt)*])* 1233 $field:ident : $field_ty:ty 1234 ),* $(,)? 1235 }), 1236 ) => { 1237 // SAFETY: Every field type implements `Zeroable` and padding bytes may be zero. 1238 #[automatically_derived] 1239 unsafe impl<$($impl_generics)*> $crate::init::Zeroable for $name<$($ty_generics)*> 1240 where 1241 $($($whr)*)? 1242 {} 1243 const _: () = { 1244 fn assert_zeroable<T: ?::core::marker::Sized + $crate::init::Zeroable>() {} 1245 fn ensure_zeroable<$($impl_generics)*>() 1246 where $($($whr)*)? 1247 { 1248 $(assert_zeroable::<$field_ty>();)* 1249 } 1250 }; 1251 }; 1252} |
|