Lines Matching +full:b +full:- +full:facing

1 // SPDX-License-Identifier: Apache-2.0 OR MIT
3 //! This module provides the macros that actually implement the proc-macros `pin_data` and
9 //! safe code! Use the public facing macros instead.
12 //! would make matters a lot easier for implementing these as proc-macros.
33 //! fn new(t: T) -> impl PinInit<Self> {
42 //! b: Bar<u32>,
55 //! b <- Bar::new(36),
59 //! This example includes the most common and important features of the pin-init API.
63 //! - use global paths, similarly to file paths, these start with the separator: `::core::panic!()`
66 //! - macro `unsafe` hygiene: we need to ensure that we do not expand arbitrary, user-supplied
100 //! // We define the pin-data carrying struct, it is a ZST and needs to have the same generics,
104 //! __phantom: ::core::marker::PhantomData<fn(Bar<T>) -> Bar<T>>,
106 //! // We implement `Copy` for the pin-data struct, since all functions it defines will take
109 //! fn clone(&self) -> Self {
114 //! // For every field of `Bar`, the pin-data struct will define a function with the same name
125 //! ) -> ::core::result::Result<(), E> {
133 //! ) -> ::core::result::Result<(), E> {
137 //! // Implement the internal `HasPinData` trait that associates `Bar` with the pin-data struct
141 //! unsafe fn __pin_data() -> Self::PinData {
147 //! // Implement the internal `PinData` trait that marks the pin-data struct as a pin-data
158 //! // - `__phantom`: every generic must be used, since we cannot really know which generics
160 //! // - `__phantom_pin`: uses the `'__pin` lifetime and ensures that this struct is invariant
162 //! // not be trivial, e.g. the user has a `#[pin] PhantomPinned` field -- this is
167 //! __phantom_pin: ::core::marker::PhantomData<fn(&'__pin ()) -> &'__pin ()>,
168 //! __phantom: ::core::marker::PhantomData<fn(Bar<T>) -> Bar<T>>,
202 //! This macro creates an pin-initializer for the given struct. It requires that the struct is
209 //! fn new(t: T) -> impl PinInit<Self> {
219 //! fn new(t: T) -> impl PinInit<Self> {
226 //! // - the function is unsafe, hence the unsafe block
227 //! // - we `use` the `HasPinData` trait in the block, it is only available in that
274 //! // executed, but still type-checked.
301 //! | -> ::core::result::Result<(), ::core::convert::Infallible> {
327 //! b: Bar<u32>,
336 //! b: Bar<u32>,
340 //! __phantom: ::core::marker::PhantomData<fn(Foo) -> Foo>,
343 //! fn clone(&self) -> Self {
350 //! unsafe fn b<E>(
354 //! ) -> ::core::result::Result<(), E> {
361 //! ) -> ::core::result::Result<(), E> {
367 //! unsafe fn __pin_data() -> Self::PinData {
378 //! __phantom_pin: ::core::marker::PhantomData<fn(&'__pin ()) -> &'__pin ()>,
379 //! __phantom: ::core::marker::PhantomData<fn(Foo) -> Foo>,
380 //! b: Bar<u32>,
440 //! b <- Bar::new(36),
468 //! unsafe { data.b(::core::addr_of_mut!((*slot).b), b)? };
470 //! ::kernel::init::__internal::DropGuard::new(::core::addr_of_mut!((*slot).b))
481 //! b: ::core::panic!(),
491 //! | -> ::core::result::Result<(), ::core::convert::Infallible> {
532 // Proc-macro entry point, this is supplied by the proc-macro pre-parsing.
583 // The proc-macro argument, this should be `PinnedDrop` or ``.
839 fn($name<$($ty_generics)*>) -> $name<$($ty_generics)*>
846 fn clone(&self) -> Self { *self }
871 unsafe fn __pin_data() -> Self::PinData {
890 __phantom_pin: ::core::marker::PhantomData<fn(&'__pin ()) -> &'__pin ()>,
892 fn($name<$($ty_generics)*>) -> $name<$($ty_generics)*>
1002 ) -> ::core::result::Result<(), E> {
1013 ) -> ::core::result::Result<(), E> {
1027 /// - nothing: this is the base case and called by the `{try_}{pin_}init!` macros.
1028 /// - `with_update_parsed`: when the `..Zeroable::zeroed()` syntax has been handled.
1029 /// - `init_slot`: recursively creates the code that initializes all fields in `slot`.
1030 /// - `make_initializer`: recursively create the struct initializer that guarantees that every
1168 // once, this struct initializer will still be type-checked and complain with a
1183 let init = move |slot| -> ::core::result::Result<(), $err> {
1204 // In-place initialization syntax.
1205 @munch_fields($field:ident <- $val:expr, $($rest:tt)*),
1236 // In-place initialization syntax.
1237 @munch_fields($field:ident <- $val:expr, $($rest:tt)*),
1267 // Init by-value.
1352 @munch_fields($field:ident <- $val:expr, $($rest:tt)*),