diff --git a/coverage/9762db8666aae4a71263fb3c4affdaf962cf87f6/coverage/home/runner/work/pinned-init/pinned-init/src/__internal.rs.html b/coverage/9762db8666aae4a71263fb3c4affdaf962cf87f6/coverage/home/runner/work/pinned-init/pinned-init/src/__internal.rs.html new file mode 100644 index 0000000..38e8f7c --- /dev/null +++ b/coverage/9762db8666aae4a71263fb3c4affdaf962cf87f6/coverage/home/runner/work/pinned-init/pinned-init/src/__internal.rs.html @@ -0,0 +1 @@ +

Coverage Report

Created: 2023-07-24 21:40

/home/runner/work/pinned-init/pinned-init/src/__internal.rs
Line
Count
Source
1
// SPDX-License-Identifier: Apache-2.0 OR MIT
2
3
//! This module contains library-internal items.
4
//!
5
//! These items must not be used outside of
6
//! - `lib.rs`
7
//! - `../pinned-init-macro/src/pin_data.rs`
8
//! - `../pinned-init-macro/src/pinned_drop.rs`
9
10
use super::*;
11
12
#[doc(hidden)]
13
pub use paste::paste;
14
15
/// See the [nomicon] for what subtyping is. See also [this table].
16
///
17
/// [nomicon]: https://doc.rust-lang.org/nomicon/subtyping.html
18
/// [this table]: https://doc.rust-lang.org/nomicon/phantom-data.html#table-of-phantomdata-patterns
19
pub(super) type Invariant<T> = PhantomData<fn(*mut T) -> *mut T>;
20
21
/// This is the module-internal type implementing `PinInit` and `Init`. It is unsafe to create this
22
/// type, since the closure needs to fulfill the same safety requirement as the
23
/// `__pinned_init`/`__init` functions.
24
pub(crate) struct InitClosure<F, T: ?Sized, E>(pub(crate) F, pub(crate) Invariant<(E, T)>);
25
26
// SAFETY: While constructing the `InitClosure`, the user promised that it upholds the
27
// `__init` invariants.
28
unsafe impl<T: ?Sized, F, E> Init<T, E> for InitClosure<F, T, E>
29
where
30
    F: FnOnce(*mut T) -> Result<(), E>,
31
{
32
    #[inline]
33
414
    unsafe fn __init(self, slot: *mut T) -> Result<(), E> {
34
414
        (self.0)(slot)
35
414
    }
Unexecuted instantiation: <pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>>::new::{closure#0}::{closure#1}, [core::mem::maybe_uninit::MaybeUninit<u8>; 1099511627776usize], core::convert::Infallible> as pinned_init::Init<[core::mem::maybe_uninit::MaybeUninit<u8>; 1099511627776usize]>>::__init
<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::EvenU64>::new::{closure#1}, alloc_fail::ring_buf::EvenU64, ()> as pinned_init::Init<alloc_fail::ring_buf::EvenU64, ()>>::__init
Line
Count
Source
33
5
    unsafe fn __init(self, slot: *mut T) -> Result<(), E> {
34
5
        (self.0)(slot)
35
5
    }
<pinned_init::__internal::InitClosure<pinned_init::zeroed<[u8; 1048576usize], core::convert::Infallible>::{closure#0}, [u8; 1048576usize], core::convert::Infallible> as pinned_init::Init<[u8; 1048576usize]>>::__init
Line
Count
Source
33
65
    unsafe fn __init(self, slot: *mut T) -> Result<(), E> {
34
65
        (self.0)(slot)
35
65
    }
<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<u8, 64usize>>::new::{closure#0}::{closure#1}, [core::mem::maybe_uninit::MaybeUninit<u8>; 64usize], core::convert::Infallible> as pinned_init::Init<[core::mem::maybe_uninit::MaybeUninit<u8>; 64usize]>>::__init
Line
Count
Source
33
1
    unsafe fn __init(self, slot: *mut T) -> Result<(), E> {
34
1
        (self.0)(slot)
35
1
    }
<pinned_init::__internal::InitClosure<<alloc::boxed::Box<alloc_fail::ring_buf::BigStruct> as pinned_init::InPlaceInit<alloc_fail::ring_buf::BigStruct>>::init<pinned_init::__internal::InitClosure<alloc_fail::ring_buf::big_struct::{closure#3}, alloc_fail::ring_buf::BigStruct, core::convert::Infallible>>::{closure#0}, alloc_fail::ring_buf::BigStruct, core::alloc::AllocError> as pinned_init::Init<alloc_fail::ring_buf::BigStruct, core::alloc::AllocError>>::__init
Line
Count
Source
33
1
    unsafe fn __init(self, slot: *mut T) -> Result<(), E> {
34
1
        (self.0)(slot)
35
1
    }
<pinned_init::__internal::InitClosure<<alloc::sync::Arc<alloc_fail::ring_buf::BigStruct> as pinned_init::InPlaceInit<alloc_fail::ring_buf::BigStruct>>::init<pinned_init::__internal::InitClosure<alloc_fail::ring_buf::big_struct::{closure#1}, alloc_fail::ring_buf::BigStruct, core::convert::Infallible>>::{closure#0}, alloc_fail::ring_buf::BigStruct, core::alloc::AllocError> as pinned_init::Init<alloc_fail::ring_buf::BigStruct, core::alloc::AllocError>>::__init
Line
Count
Source
33
1
    unsafe fn __init(self, slot: *mut T) -> Result<(), E> {
34
1
        (self.0)(slot)
35
1
    }
<pinned_init::__internal::InitClosure<pinned_init::uninit<u8, core::convert::Infallible>::{closure#0}, core::mem::maybe_uninit::MaybeUninit<u8>, core::convert::Infallible> as pinned_init::Init<core::mem::maybe_uninit::MaybeUninit<u8>>>::__init
Line
Count
Source
33
63
    unsafe fn __init(self, slot: *mut T) -> Result<(), E> {
34
63
        (self.0)(slot)
35
63
    }
<pinned_init::__internal::InitClosure<pinned_init::zeroed<core::mem::maybe_uninit::MaybeUninit<u8>, core::convert::Infallible>::{closure#0}, core::mem::maybe_uninit::MaybeUninit<u8>, core::convert::Infallible> as pinned_init::Init<core::mem::maybe_uninit::MaybeUninit<u8>>>::__init
Line
Count
Source
33
2
    unsafe fn __init(self, slot: *mut T) -> Result<(), E> {
34
2
        (self.0)(slot)
35
2
    }
<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::EvenU64, 4usize>>::new::{closure#0}::{closure#1}, [core::mem::maybe_uninit::MaybeUninit<alloc_fail::ring_buf::EvenU64>; 4usize], core::convert::Infallible> as pinned_init::Init<[core::mem::maybe_uninit::MaybeUninit<alloc_fail::ring_buf::EvenU64>; 4usize]>>::__init
Line
Count
Source
33
1
    unsafe fn __init(self, slot: *mut T) -> Result<(), E> {
34
1
        (self.0)(slot)
35
1
    }
<pinned_init::__internal::InitClosure<alloc_fail::ring_buf::with_big_struct::{closure#1}, alloc_fail::ring_buf::BigStruct, core::convert::Infallible> as pinned_init::Init<alloc_fail::ring_buf::BigStruct>>::__init
Line
Count
Source
33
63
    unsafe fn __init(self, slot: *mut T) -> Result<(), E> {
34
63
        (self.0)(slot)
35
63
    }
Unexecuted instantiation: <pinned_init::__internal::InitClosure<pinned_init::zeroed<[u8; 1099511627776usize], core::convert::Infallible>::{closure#0}, [u8; 1099511627776usize], core::convert::Infallible> as pinned_init::Init<[u8; 1099511627776usize]>>::__init
<pinned_init::__internal::InitClosure<alloc_fail::ring_buf::big_struct::{closure#1}, alloc_fail::ring_buf::BigStruct, core::convert::Infallible> as pinned_init::Init<alloc_fail::ring_buf::BigStruct>>::__init
Line
Count
Source
33
1
    unsafe fn __init(self, slot: *mut T) -> Result<(), E> {
34
1
        (self.0)(slot)
35
1
    }
Unexecuted instantiation: <pinned_init::__internal::InitClosure<<alloc::sync::Arc<[u8; 1099511627776usize]> as pinned_init::InPlaceInit<[u8; 1099511627776usize]>>::init<pinned_init::__internal::InitClosure<pinned_init::zeroed<[u8; 1099511627776usize], core::convert::Infallible>::{closure#0}, [u8; 1099511627776usize], core::convert::Infallible>>::{closure#0}, [u8; 1099511627776usize], core::alloc::AllocError> as pinned_init::Init<[u8; 1099511627776usize], core::alloc::AllocError>>::__init
Unexecuted instantiation: <pinned_init::__internal::InitClosure<<alloc::boxed::Box<[u8; 1099511627776usize]> as pinned_init::InPlaceInit<[u8; 1099511627776usize]>>::init<pinned_init::__internal::InitClosure<pinned_init::zeroed<[u8; 1099511627776usize], core::convert::Infallible>::{closure#0}, [u8; 1099511627776usize], core::convert::Infallible>>::{closure#0}, [u8; 1099511627776usize], core::alloc::AllocError> as pinned_init::Init<[u8; 1099511627776usize], core::alloc::AllocError>>::__init
<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>::new::{closure#0}::{closure#1}, [core::mem::maybe_uninit::MaybeUninit<alloc_fail::ring_buf::BigStruct>; 64usize], core::convert::Infallible> as pinned_init::Init<[core::mem::maybe_uninit::MaybeUninit<alloc_fail::ring_buf::BigStruct>; 64usize]>>::__init
Line
Count
Source
33
1
    unsafe fn __init(self, slot: *mut T) -> Result<(), E> {
34
1
        (self.0)(slot)
35
1
    }
<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::EvenU64>::new2::{closure#1}, alloc_fail::ring_buf::EvenU64, core::alloc::AllocError> as pinned_init::Init<alloc_fail::ring_buf::EvenU64, core::alloc::AllocError>>::__init
Line
Count
Source
33
2
    unsafe fn __init(self, slot: *mut T) -> Result<(), E> {
34
2
        (self.0)(slot)
35
2
    }
Unexecuted instantiation: <pinned_init::__internal::InitClosure<alloc_fail::ring_buf::with_big_struct::{closure#3}, alloc_fail::ring_buf::BigStruct, core::convert::Infallible> as pinned_init::Init<alloc_fail::ring_buf::BigStruct>>::__init
<pinned_init::__internal::InitClosure<alloc_fail::ring_buf::big_struct::{closure#3}, alloc_fail::ring_buf::BigStruct, core::convert::Infallible> as pinned_init::Init<alloc_fail::ring_buf::BigStruct>>::__init
Line
Count
Source
33
1
    unsafe fn __init(self, slot: *mut T) -> Result<(), E> {
34
1
        (self.0)(slot)
35
1
    }
Unexecuted instantiation: <pinned_init::__internal::InitClosure<_, _, _> as pinned_init::Init<_, _>>::__init
Unexecuted instantiation: <pinned_init::__internal::InitClosure<_, _, _> as pinned_init::Init<_, _>>::__init
<pinned_init::__internal::InitClosure<<alloc::sync::Arc<ring_buf::BigStruct> as pinned_init::InPlaceInit<ring_buf::BigStruct>>::init<pinned_init::__internal::InitClosure<ring_buf::big_struct::{closure#1}, ring_buf::BigStruct, core::convert::Infallible>>::{closure#0}, ring_buf::BigStruct, core::alloc::AllocError> as pinned_init::Init<ring_buf::BigStruct, core::alloc::AllocError>>::__init
Line
Count
Source
33
1
    unsafe fn __init(self, slot: *mut T) -> Result<(), E> {
34
1
        (self.0)(slot)
35
1
    }
<pinned_init::__internal::InitClosure<ring_buf::big_struct::{closure#3}, ring_buf::BigStruct, core::convert::Infallible> as pinned_init::Init<ring_buf::BigStruct>>::__init
Line
Count
Source
33
1
    unsafe fn __init(self, slot: *mut T) -> Result<(), E> {
34
1
        (self.0)(slot)
35
1
    }
<pinned_init::__internal::InitClosure<ring_buf::big_struct::{closure#1}, ring_buf::BigStruct, core::convert::Infallible> as pinned_init::Init<ring_buf::BigStruct>>::__init
Line
Count
Source
33
1
    unsafe fn __init(self, slot: *mut T) -> Result<(), E> {
34
1
        (self.0)(slot)
35
1
    }
<pinned_init::__internal::InitClosure<<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>::new::{closure#0}::{closure#1}, [core::mem::maybe_uninit::MaybeUninit<ring_buf::BigStruct>; 64usize], core::convert::Infallible> as pinned_init::Init<[core::mem::maybe_uninit::MaybeUninit<ring_buf::BigStruct>; 64usize]>>::__init
Line
Count
Source
33
1
    unsafe fn __init(self, slot: *mut T) -> Result<(), E> {
34
1
        (self.0)(slot)
35
1
    }
<pinned_init::__internal::InitClosure<<ring_buf::EvenU64>::new::{closure#1}, ring_buf::EvenU64, ()> as pinned_init::Init<ring_buf::EvenU64, ()>>::__init
Line
Count
Source
33
5
    unsafe fn __init(self, slot: *mut T) -> Result<(), E> {
34
5
        (self.0)(slot)
35
5
    }
Unexecuted instantiation: <pinned_init::__internal::InitClosure<ring_buf::with_big_struct::{closure#3}, ring_buf::BigStruct, core::convert::Infallible> as pinned_init::Init<ring_buf::BigStruct>>::__init
<pinned_init::__internal::InitClosure<<ring_buf::EvenU64>::new2::{closure#1}, ring_buf::EvenU64, core::alloc::AllocError> as pinned_init::Init<ring_buf::EvenU64, core::alloc::AllocError>>::__init
Line
Count
Source
33
2
    unsafe fn __init(self, slot: *mut T) -> Result<(), E> {
34
2
        (self.0)(slot)
35
2
    }
<pinned_init::__internal::InitClosure<pinned_init::uninit<u8, core::convert::Infallible>::{closure#0}, core::mem::maybe_uninit::MaybeUninit<u8>, core::convert::Infallible> as pinned_init::Init<core::mem::maybe_uninit::MaybeUninit<u8>>>::__init
Line
Count
Source
33
63
    unsafe fn __init(self, slot: *mut T) -> Result<(), E> {
34
63
        (self.0)(slot)
35
63
    }
<pinned_init::__internal::InitClosure<pinned_init::zeroed<core::mem::maybe_uninit::MaybeUninit<u8>, core::convert::Infallible>::{closure#0}, core::mem::maybe_uninit::MaybeUninit<u8>, core::convert::Infallible> as pinned_init::Init<core::mem::maybe_uninit::MaybeUninit<u8>>>::__init
Line
Count
Source
33
2
    unsafe fn __init(self, slot: *mut T) -> Result<(), E> {
34
2
        (self.0)(slot)
35
2
    }
<pinned_init::__internal::InitClosure<<ring_buf::RingBuffer<ring_buf::EvenU64, 4usize>>::new::{closure#0}::{closure#1}, [core::mem::maybe_uninit::MaybeUninit<ring_buf::EvenU64>; 4usize], core::convert::Infallible> as pinned_init::Init<[core::mem::maybe_uninit::MaybeUninit<ring_buf::EvenU64>; 4usize]>>::__init
Line
Count
Source
33
1
    unsafe fn __init(self, slot: *mut T) -> Result<(), E> {
34
1
        (self.0)(slot)
35
1
    }
<pinned_init::__internal::InitClosure<ring_buf::with_big_struct::{closure#1}, ring_buf::BigStruct, core::convert::Infallible> as pinned_init::Init<ring_buf::BigStruct>>::__init
Line
Count
Source
33
63
    unsafe fn __init(self, slot: *mut T) -> Result<(), E> {
34
63
        (self.0)(slot)
35
63
    }
<pinned_init::__internal::InitClosure<pinned_init::zeroed<[u8; 1048576usize], core::convert::Infallible>::{closure#0}, [u8; 1048576usize], core::convert::Infallible> as pinned_init::Init<[u8; 1048576usize]>>::__init
Line
Count
Source
33
65
    unsafe fn __init(self, slot: *mut T) -> Result<(), E> {
34
65
        (self.0)(slot)
35
65
    }
<pinned_init::__internal::InitClosure<<ring_buf::RingBuffer<u8, 64usize>>::new::{closure#0}::{closure#1}, [core::mem::maybe_uninit::MaybeUninit<u8>; 64usize], core::convert::Infallible> as pinned_init::Init<[core::mem::maybe_uninit::MaybeUninit<u8>; 64usize]>>::__init
Line
Count
Source
33
1
    unsafe fn __init(self, slot: *mut T) -> Result<(), E> {
34
1
        (self.0)(slot)
35
1
    }
<pinned_init::__internal::InitClosure<<alloc::boxed::Box<ring_buf::BigStruct> as pinned_init::InPlaceInit<ring_buf::BigStruct>>::init<pinned_init::__internal::InitClosure<ring_buf::big_struct::{closure#3}, ring_buf::BigStruct, core::convert::Infallible>>::{closure#0}, ring_buf::BigStruct, core::alloc::AllocError> as pinned_init::Init<ring_buf::BigStruct, core::alloc::AllocError>>::__init
Line
Count
Source
33
1
    unsafe fn __init(self, slot: *mut T) -> Result<(), E> {
34
1
        (self.0)(slot)
35
1
    }
36
}
37
38
// SAFETY: While constructing the `InitClosure`, the user promised that it upholds the
39
// `__pinned_init` invariants.
40
unsafe impl<T: ?Sized, F, E> PinInit<T, E> for InitClosure<F, T, E>
41
where
42
    F: FnOnce(*mut T) -> Result<(), E>,
43
{
44
    #[inline]
45
93.9k
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
93.9k
        (self.0)(slot)
47
93.9k
    }
<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::mutex::CMutex<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>>::new<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>::new::{closure#1}, alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>, core::convert::Infallible>>::{closure#0}::{closure#1}, core::cell::UnsafeCell<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>, core::convert::Infallible> as pinned_init::PinInit<core::cell::UnsafeCell<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::mutex::CMutex<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>>::new<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>::new::{closure#1}, alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>, core::convert::Infallible>>::{closure#1}, alloc_fail::ring_buf::mutex::CMutex<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>, core::convert::Infallible> as pinned_init::PinInit<alloc_fail::ring_buf::mutex::CMutex<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
Unexecuted instantiation: <pinned_init::__internal::InitClosure<<alloc::sync::Arc<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>> as pinned_init::InPlaceInit<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>>>::pin_init<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>>::new::{closure#1}, alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>, core::convert::Infallible>>::{closure#0}, alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>, core::alloc::AllocError> as pinned_init::PinInit<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>, core::alloc::AllocError>>::__pinned_init
<pinned_init::__internal::InitClosure<<alloc::sync::Arc<alloc_fail::ring_buf::mutex::CMutex<usize>> as pinned_init::InPlaceInit<alloc_fail::ring_buf::mutex::CMutex<usize>>>::pin_init<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::mutex::CMutex<usize>>::new<usize>::{closure#1}, alloc_fail::ring_buf::mutex::CMutex<usize>, core::convert::Infallible>>::{closure#0}, alloc_fail::ring_buf::mutex::CMutex<usize>, core::alloc::AllocError> as pinned_init::PinInit<alloc_fail::ring_buf::mutex::CMutex<usize>, core::alloc::AllocError>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
<pinned_init::__internal::InitClosure<<alloc::boxed::Box<alloc_fail::ring_buf::mutex::linked_list::ListHead> as pinned_init::InPlaceInit<alloc_fail::ring_buf::mutex::linked_list::ListHead>>::pin_init<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::mutex::linked_list::ListHead>::insert_next::{closure#1}, alloc_fail::ring_buf::mutex::linked_list::ListHead, core::convert::Infallible>>::{closure#0}, alloc_fail::ring_buf::mutex::linked_list::ListHead, core::alloc::AllocError> as pinned_init::PinInit<alloc_fail::ring_buf::mutex::linked_list::ListHead, core::alloc::AllocError>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::EvenU64, 4usize>>::new::{closure#1}, alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::EvenU64, 4usize>, core::convert::Infallible> as pinned_init::PinInit<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::EvenU64, 4usize>>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<u8, 64usize>>::new::{closure#1}, alloc_fail::ring_buf::RingBuffer<u8, 64usize>, core::convert::Infallible> as pinned_init::PinInit<alloc_fail::ring_buf::RingBuffer<u8, 64usize>>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<u8, 64usize>>::pop_no_stack::{closure#0}, u8, core::convert::Infallible> as pinned_init::PinInit<u8>>::__pinned_init
Line
Count
Source
45
63
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
63
        (self.0)(slot)
47
63
    }
<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::mutex::CMutex<usize>>::new<usize>::{closure#1}, alloc_fail::ring_buf::mutex::CMutex<usize>, core::convert::Infallible> as pinned_init::PinInit<alloc_fail::ring_buf::mutex::CMutex<usize>>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::EvenU64>::new::{closure#1}, alloc_fail::ring_buf::EvenU64, ()> as pinned_init::PinInit<alloc_fail::ring_buf::EvenU64, ()>>::__pinned_init
Line
Count
Source
45
2
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
2
        (self.0)(slot)
47
2
    }
<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::EvenU64>::new2::{closure#1}, alloc_fail::ring_buf::EvenU64, core::alloc::AllocError> as pinned_init::PinInit<alloc_fail::ring_buf::EvenU64, core::alloc::AllocError>>::__pinned_init
Line
Count
Source
45
2
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
2
        (self.0)(slot)
47
2
    }
<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::mutex::linked_list::ListHead>::insert_next::{closure#1}, alloc_fail::ring_buf::mutex::linked_list::ListHead, core::convert::Infallible> as pinned_init::PinInit<alloc_fail::ring_buf::mutex::linked_list::ListHead>>::__pinned_init
Line
Count
Source
45
4
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
4
        (self.0)(slot)
47
4
    }
<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>::new::{closure#1}, alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>, core::convert::Infallible> as pinned_init::PinInit<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::mutex::linked_list::ListHead>::insert_prev::{closure#1}, alloc_fail::ring_buf::mutex::linked_list::ListHead, core::convert::Infallible> as pinned_init::PinInit<alloc_fail::ring_buf::mutex::linked_list::ListHead>>::__pinned_init
Line
Count
Source
45
9.60k
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
9.60k
        (self.0)(slot)
47
9.60k
    }
<pinned_init::__internal::InitClosure<<alloc::sync::Arc<alloc_fail::ring_buf::mutex::CMutex<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>> as pinned_init::InPlaceInit<alloc_fail::ring_buf::mutex::CMutex<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>>>::pin_init<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::mutex::CMutex<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>>::new<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>::new::{closure#1}, alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>, core::convert::Infallible>>::{closure#1}, alloc_fail::ring_buf::mutex::CMutex<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>, core::convert::Infallible>>::{closure#0}, alloc_fail::ring_buf::mutex::CMutex<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>, core::alloc::AllocError> as pinned_init::PinInit<alloc_fail::ring_buf::mutex::CMutex<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>, core::alloc::AllocError>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
<pinned_init::__internal::InitClosure<<alloc::boxed::Box<alloc_fail::ring_buf::mutex::linked_list::ListHead> as pinned_init::InPlaceInit<alloc_fail::ring_buf::mutex::linked_list::ListHead>>::pin_init<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::mutex::linked_list::ListHead>::new::{closure#1}, alloc_fail::ring_buf::mutex::linked_list::ListHead, core::convert::Infallible>>::{closure#0}, alloc_fail::ring_buf::mutex::linked_list::ListHead, core::alloc::AllocError> as pinned_init::PinInit<alloc_fail::ring_buf::mutex::linked_list::ListHead, core::alloc::AllocError>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
Unexecuted instantiation: <pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>>::new::{closure#1}, alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>, core::convert::Infallible> as pinned_init::PinInit<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>>>::__pinned_init
<pinned_init::__internal::InitClosure<<alloc::boxed::Box<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::EvenU64, 4usize>> as pinned_init::InPlaceInit<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::EvenU64, 4usize>>>::pin_init<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::EvenU64, 4usize>>::new::{closure#1}, alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::EvenU64, 4usize>, core::convert::Infallible>>::{closure#0}, alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::EvenU64, 4usize>, core::alloc::AllocError> as pinned_init::PinInit<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::EvenU64, 4usize>, core::alloc::AllocError>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::mutex::linked_list::ListHead>::new::{closure#1}, alloc_fail::ring_buf::mutex::linked_list::ListHead, core::convert::Infallible> as pinned_init::PinInit<alloc_fail::ring_buf::mutex::linked_list::ListHead>>::__pinned_init
Line
Count
Source
45
3
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
3
        (self.0)(slot)
47
3
    }
Unexecuted instantiation: <pinned_init::__internal::InitClosure<<alloc::boxed::Box<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>> as pinned_init::InPlaceInit<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>>>::pin_init<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>>::new::{closure#1}, alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>, core::convert::Infallible>>::{closure#0}, alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>, core::alloc::AllocError> as pinned_init::PinInit<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>, core::alloc::AllocError>>::__pinned_init
<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::mutex::CMutex<usize>>::new<usize>::{closure#0}::{closure#1}, core::cell::UnsafeCell<usize>, core::convert::Infallible> as pinned_init::PinInit<core::cell::UnsafeCell<usize>>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::mutex::WaitEntry>::insert_new::{closure#1}, alloc_fail::ring_buf::mutex::WaitEntry, core::convert::Infallible> as pinned_init::PinInit<alloc_fail::ring_buf::mutex::WaitEntry>>::__pinned_init
Line
Count
Source
45
9.60k
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
9.60k
        (self.0)(slot)
47
9.60k
    }
Unexecuted instantiation: <pinned_init::__internal::InitClosure<_, _, _> as pinned_init::PinInit<_, _>>::__pinned_init
<pinned_init::__internal::InitClosure<pinned_init::__internal::stack_init_reuse::{closure#1}, pinned_init::__internal::stack_init_reuse::Foo, core::convert::Infallible> as pinned_init::PinInit<pinned_init::__internal::stack_init_reuse::Foo>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
<pinned_init::__internal::InitClosure<pinned_init::__internal::stack_init_reuse::{closure#3}, pinned_init::__internal::stack_init_reuse::Foo, core::convert::Infallible> as pinned_init::PinInit<pinned_init::__internal::stack_init_reuse::Foo>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
<pinned_init::__internal::InitClosure<<ring_buf::EvenU64>::new::{closure#1}, ring_buf::EvenU64, ()> as pinned_init::PinInit<ring_buf::EvenU64, ()>>::__pinned_init
Line
Count
Source
45
2
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
2
        (self.0)(slot)
47
2
    }
<pinned_init::__internal::InitClosure<<alloc::sync::Arc<ring_buf::mutex::CMutex<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>> as pinned_init::InPlaceInit<ring_buf::mutex::CMutex<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>>>::pin_init<pinned_init::__internal::InitClosure<<ring_buf::mutex::CMutex<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>>::new<pinned_init::__internal::InitClosure<<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>::new::{closure#1}, ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>, core::convert::Infallible>>::{closure#1}, ring_buf::mutex::CMutex<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>, core::convert::Infallible>>::{closure#0}, ring_buf::mutex::CMutex<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>, core::alloc::AllocError> as pinned_init::PinInit<ring_buf::mutex::CMutex<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>, core::alloc::AllocError>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
<pinned_init::__internal::InitClosure<<alloc::boxed::Box<ring_buf::mutex::linked_list::ListHead> as pinned_init::InPlaceInit<ring_buf::mutex::linked_list::ListHead>>::pin_init<pinned_init::__internal::InitClosure<<ring_buf::mutex::linked_list::ListHead>::new::{closure#1}, ring_buf::mutex::linked_list::ListHead, core::convert::Infallible>>::{closure#0}, ring_buf::mutex::linked_list::ListHead, core::alloc::AllocError> as pinned_init::PinInit<ring_buf::mutex::linked_list::ListHead, core::alloc::AllocError>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
<pinned_init::__internal::InitClosure<<ring_buf::RingBuffer<u8, 64usize>>::pop_no_stack::{closure#0}, u8, core::convert::Infallible> as pinned_init::PinInit<u8>>::__pinned_init
Line
Count
Source
45
63
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
63
        (self.0)(slot)
47
63
    }
<pinned_init::__internal::InitClosure<<ring_buf::EvenU64>::new2::{closure#1}, ring_buf::EvenU64, core::alloc::AllocError> as pinned_init::PinInit<ring_buf::EvenU64, core::alloc::AllocError>>::__pinned_init
Line
Count
Source
45
2
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
2
        (self.0)(slot)
47
2
    }
<pinned_init::__internal::InitClosure<<ring_buf::mutex::linked_list::ListHead>::insert_next::{closure#1}, ring_buf::mutex::linked_list::ListHead, core::convert::Infallible> as pinned_init::PinInit<ring_buf::mutex::linked_list::ListHead>>::__pinned_init
Line
Count
Source
45
4
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
4
        (self.0)(slot)
47
4
    }
<pinned_init::__internal::InitClosure<<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>::new::{closure#1}, ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>, core::convert::Infallible> as pinned_init::PinInit<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
<pinned_init::__internal::InitClosure<<ring_buf::mutex::linked_list::ListHead>::insert_prev::{closure#1}, ring_buf::mutex::linked_list::ListHead, core::convert::Infallible> as pinned_init::PinInit<ring_buf::mutex::linked_list::ListHead>>::__pinned_init
Line
Count
Source
45
14.4k
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
14.4k
        (self.0)(slot)
47
14.4k
    }
<pinned_init::__internal::InitClosure<<ring_buf::mutex::CMutex<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>>::new<pinned_init::__internal::InitClosure<<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>::new::{closure#1}, ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>, core::convert::Infallible>>::{closure#0}::{closure#1}, core::cell::UnsafeCell<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>, core::convert::Infallible> as pinned_init::PinInit<core::cell::UnsafeCell<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
<pinned_init::__internal::InitClosure<<alloc::boxed::Box<ring_buf::RingBuffer<ring_buf::EvenU64, 4usize>> as pinned_init::InPlaceInit<ring_buf::RingBuffer<ring_buf::EvenU64, 4usize>>>::pin_init<pinned_init::__internal::InitClosure<<ring_buf::RingBuffer<ring_buf::EvenU64, 4usize>>::new::{closure#1}, ring_buf::RingBuffer<ring_buf::EvenU64, 4usize>, core::convert::Infallible>>::{closure#0}, ring_buf::RingBuffer<ring_buf::EvenU64, 4usize>, core::alloc::AllocError> as pinned_init::PinInit<ring_buf::RingBuffer<ring_buf::EvenU64, 4usize>, core::alloc::AllocError>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
<pinned_init::__internal::InitClosure<<ring_buf::mutex::CMutex<usize>>::new<usize>::{closure#0}::{closure#1}, core::cell::UnsafeCell<usize>, core::convert::Infallible> as pinned_init::PinInit<core::cell::UnsafeCell<usize>>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
<pinned_init::__internal::InitClosure<<ring_buf::mutex::linked_list::ListHead>::new::{closure#1}, ring_buf::mutex::linked_list::ListHead, core::convert::Infallible> as pinned_init::PinInit<ring_buf::mutex::linked_list::ListHead>>::__pinned_init
Line
Count
Source
45
3
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
3
        (self.0)(slot)
47
3
    }
<pinned_init::__internal::InitClosure<<ring_buf::mutex::WaitEntry>::insert_new::{closure#1}, ring_buf::mutex::WaitEntry, core::convert::Infallible> as pinned_init::PinInit<ring_buf::mutex::WaitEntry>>::__pinned_init
Line
Count
Source
45
14.4k
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
14.4k
        (self.0)(slot)
47
14.4k
    }
<pinned_init::__internal::InitClosure<<ring_buf::mutex::CMutex<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>>::new<pinned_init::__internal::InitClosure<<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>::new::{closure#1}, ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>, core::convert::Infallible>>::{closure#1}, ring_buf::mutex::CMutex<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>, core::convert::Infallible> as pinned_init::PinInit<ring_buf::mutex::CMutex<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
<pinned_init::__internal::InitClosure<<alloc::sync::Arc<ring_buf::mutex::CMutex<usize>> as pinned_init::InPlaceInit<ring_buf::mutex::CMutex<usize>>>::pin_init<pinned_init::__internal::InitClosure<<ring_buf::mutex::CMutex<usize>>::new<usize>::{closure#1}, ring_buf::mutex::CMutex<usize>, core::convert::Infallible>>::{closure#0}, ring_buf::mutex::CMutex<usize>, core::alloc::AllocError> as pinned_init::PinInit<ring_buf::mutex::CMutex<usize>, core::alloc::AllocError>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
<pinned_init::__internal::InitClosure<<alloc::boxed::Box<ring_buf::mutex::linked_list::ListHead> as pinned_init::InPlaceInit<ring_buf::mutex::linked_list::ListHead>>::pin_init<pinned_init::__internal::InitClosure<<ring_buf::mutex::linked_list::ListHead>::insert_next::{closure#1}, ring_buf::mutex::linked_list::ListHead, core::convert::Infallible>>::{closure#0}, ring_buf::mutex::linked_list::ListHead, core::alloc::AllocError> as pinned_init::PinInit<ring_buf::mutex::linked_list::ListHead, core::alloc::AllocError>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
<pinned_init::__internal::InitClosure<<ring_buf::RingBuffer<ring_buf::EvenU64, 4usize>>::new::{closure#1}, ring_buf::RingBuffer<ring_buf::EvenU64, 4usize>, core::convert::Infallible> as pinned_init::PinInit<ring_buf::RingBuffer<ring_buf::EvenU64, 4usize>>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
<pinned_init::__internal::InitClosure<<ring_buf::RingBuffer<u8, 64usize>>::new::{closure#1}, ring_buf::RingBuffer<u8, 64usize>, core::convert::Infallible> as pinned_init::PinInit<ring_buf::RingBuffer<u8, 64usize>>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
<pinned_init::__internal::InitClosure<<ring_buf::mutex::CMutex<usize>>::new<usize>::{closure#1}, ring_buf::mutex::CMutex<usize>, core::convert::Infallible> as pinned_init::PinInit<ring_buf::mutex::CMutex<usize>>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
<pinned_init::__internal::InitClosure<<linked_list::ListHead>::insert_next::{closure#1}, linked_list::ListHead, core::convert::Infallible> as pinned_init::PinInit<linked_list::ListHead>>::__pinned_init
Line
Count
Source
45
4
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
4
        (self.0)(slot)
47
4
    }
<pinned_init::__internal::InitClosure<<alloc::boxed::Box<linked_list::ListHead> as pinned_init::InPlaceInit<linked_list::ListHead>>::pin_init<pinned_init::__internal::InitClosure<<linked_list::ListHead>::new::{closure#1}, linked_list::ListHead, core::convert::Infallible>>::{closure#0}, linked_list::ListHead, core::alloc::AllocError> as pinned_init::PinInit<linked_list::ListHead, core::alloc::AllocError>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
<pinned_init::__internal::InitClosure<<alloc::boxed::Box<linked_list::ListHead> as pinned_init::InPlaceInit<linked_list::ListHead>>::pin_init<pinned_init::__internal::InitClosure<<linked_list::ListHead>::insert_next::{closure#1}, linked_list::ListHead, core::convert::Infallible>>::{closure#0}, linked_list::ListHead, core::alloc::AllocError> as pinned_init::PinInit<linked_list::ListHead, core::alloc::AllocError>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
<pinned_init::__internal::InitClosure<<linked_list::ListHead>::new::{closure#1}, linked_list::ListHead, core::convert::Infallible> as pinned_init::PinInit<linked_list::ListHead>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
<pinned_init::__internal::InitClosure<<mutex::WaitEntry>::insert_new::{closure#1}, mutex::WaitEntry, core::convert::Infallible> as pinned_init::PinInit<mutex::WaitEntry>>::__pinned_init
Line
Count
Source
45
10.1k
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
10.1k
        (self.0)(slot)
47
10.1k
    }
<pinned_init::__internal::InitClosure<<alloc::boxed::Box<mutex::linked_list::ListHead> as pinned_init::InPlaceInit<mutex::linked_list::ListHead>>::pin_init<pinned_init::__internal::InitClosure<<mutex::linked_list::ListHead>::insert_next::{closure#1}, mutex::linked_list::ListHead, core::convert::Infallible>>::{closure#0}, mutex::linked_list::ListHead, core::alloc::AllocError> as pinned_init::PinInit<mutex::linked_list::ListHead, core::alloc::AllocError>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
<pinned_init::__internal::InitClosure<<alloc::sync::Arc<mutex::CMutex<usize>> as pinned_init::InPlaceInit<mutex::CMutex<usize>>>::pin_init<pinned_init::__internal::InitClosure<<mutex::CMutex<usize>>::new<usize>::{closure#1}, mutex::CMutex<usize>, core::convert::Infallible>>::{closure#0}, mutex::CMutex<usize>, core::alloc::AllocError> as pinned_init::PinInit<mutex::CMutex<usize>, core::alloc::AllocError>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
<pinned_init::__internal::InitClosure<<mutex::linked_list::ListHead>::new::{closure#1}, mutex::linked_list::ListHead, core::convert::Infallible> as pinned_init::PinInit<mutex::linked_list::ListHead>>::__pinned_init
Line
Count
Source
45
2
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
2
        (self.0)(slot)
47
2
    }
<pinned_init::__internal::InitClosure<<alloc::boxed::Box<mutex::linked_list::ListHead> as pinned_init::InPlaceInit<mutex::linked_list::ListHead>>::pin_init<pinned_init::__internal::InitClosure<<mutex::linked_list::ListHead>::new::{closure#1}, mutex::linked_list::ListHead, core::convert::Infallible>>::{closure#0}, mutex::linked_list::ListHead, core::alloc::AllocError> as pinned_init::PinInit<mutex::linked_list::ListHead, core::alloc::AllocError>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
<pinned_init::__internal::InitClosure<<mutex::linked_list::ListHead>::insert_next::{closure#1}, mutex::linked_list::ListHead, core::convert::Infallible> as pinned_init::PinInit<mutex::linked_list::ListHead>>::__pinned_init
Line
Count
Source
45
4
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
4
        (self.0)(slot)
47
4
    }
<pinned_init::__internal::InitClosure<<mutex::CMutex<usize>>::new<usize>::{closure#0}::{closure#1}, core::cell::UnsafeCell<usize>, core::convert::Infallible> as pinned_init::PinInit<core::cell::UnsafeCell<usize>>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
<pinned_init::__internal::InitClosure<<mutex::linked_list::ListHead>::insert_prev::{closure#1}, mutex::linked_list::ListHead, core::convert::Infallible> as pinned_init::PinInit<mutex::linked_list::ListHead>>::__pinned_init
Line
Count
Source
45
10.1k
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
10.1k
        (self.0)(slot)
47
10.1k
    }
<pinned_init::__internal::InitClosure<<mutex::CMutex<usize>>::new<usize>::{closure#1}, mutex::CMutex<usize>, core::convert::Infallible> as pinned_init::PinInit<mutex::CMutex<usize>>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
<pinned_init::__internal::InitClosure<<pthread_mutex::pthread_mtx::PThreadMutex<usize>>::new::{closure#1}, pthread_mutex::pthread_mtx::PThreadMutex<usize>, pthread_mutex::pthread_mtx::Error> as pinned_init::PinInit<pthread_mutex::pthread_mtx::PThreadMutex<usize>, pthread_mutex::pthread_mtx::Error>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
<pinned_init::__internal::InitClosure<<pthread_mutex::pthread_mtx::PThreadMutex<_>>::new::init_raw::{closure#0}, core::cell::UnsafeCell<libc::unix::linux_like::linux::pthread_mutex_t>, pthread_mutex::pthread_mtx::Error> as pinned_init::PinInit<core::cell::UnsafeCell<libc::unix::linux_like::linux::pthread_mutex_t>, pthread_mutex::pthread_mtx::Error>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
<pinned_init::__internal::InitClosure<<static_init::mutex::linked_list::ListHead>::new::{closure#1}, static_init::mutex::linked_list::ListHead, core::convert::Infallible> as pinned_init::PinInit<static_init::mutex::linked_list::ListHead>>::__pinned_init
Line
Count
Source
45
2
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
2
        (self.0)(slot)
47
2
    }
<pinned_init::__internal::InitClosure<<alloc::sync::Arc<static_init::mutex::CMutex<usize>> as pinned_init::InPlaceInit<static_init::mutex::CMutex<usize>>>::pin_init<pinned_init::__internal::InitClosure<<static_init::mutex::CMutex<usize>>::new<usize>::{closure#1}, static_init::mutex::CMutex<usize>, core::convert::Infallible>>::{closure#0}, static_init::mutex::CMutex<usize>, core::alloc::AllocError> as pinned_init::PinInit<static_init::mutex::CMutex<usize>, core::alloc::AllocError>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
<pinned_init::__internal::InitClosure<<static_init::mutex::CMutex<usize>>::new<usize>::{closure#0}::{closure#1}, core::cell::UnsafeCell<usize>, core::convert::Infallible> as pinned_init::PinInit<core::cell::UnsafeCell<usize>>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
<pinned_init::__internal::InitClosure<<static_init::mutex::linked_list::ListHead>::insert_prev::{closure#1}, static_init::mutex::linked_list::ListHead, core::convert::Infallible> as pinned_init::PinInit<static_init::mutex::linked_list::ListHead>>::__pinned_init
Line
Count
Source
45
12.6k
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
12.6k
        (self.0)(slot)
47
12.6k
    }
<pinned_init::__internal::InitClosure<<static_init::mutex::CMutex<usize>>::new<usize>::{closure#1}, static_init::mutex::CMutex<usize>, core::convert::Infallible> as pinned_init::PinInit<static_init::mutex::CMutex<usize>>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
<pinned_init::__internal::InitClosure<<alloc::boxed::Box<static_init::mutex::linked_list::ListHead> as pinned_init::InPlaceInit<static_init::mutex::linked_list::ListHead>>::pin_init<pinned_init::__internal::InitClosure<<static_init::mutex::linked_list::ListHead>::insert_next::{closure#1}, static_init::mutex::linked_list::ListHead, core::convert::Infallible>>::{closure#0}, static_init::mutex::linked_list::ListHead, core::alloc::AllocError> as pinned_init::PinInit<static_init::mutex::linked_list::ListHead, core::alloc::AllocError>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
<pinned_init::__internal::InitClosure<<static_init::mutex::linked_list::ListHead>::insert_next::{closure#1}, static_init::mutex::linked_list::ListHead, core::convert::Infallible> as pinned_init::PinInit<static_init::mutex::linked_list::ListHead>>::__pinned_init
Line
Count
Source
45
4
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
4
        (self.0)(slot)
47
4
    }
<pinned_init::__internal::InitClosure<<static_init::mutex::WaitEntry>::insert_new::{closure#1}, static_init::mutex::WaitEntry, core::convert::Infallible> as pinned_init::PinInit<static_init::mutex::WaitEntry>>::__pinned_init
Line
Count
Source
45
12.6k
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
12.6k
        (self.0)(slot)
47
12.6k
    }
<pinned_init::__internal::InitClosure<<alloc::boxed::Box<static_init::mutex::linked_list::ListHead> as pinned_init::InPlaceInit<static_init::mutex::linked_list::ListHead>>::pin_init<pinned_init::__internal::InitClosure<<static_init::mutex::linked_list::ListHead>::new::{closure#1}, static_init::mutex::linked_list::ListHead, core::convert::Infallible>>::{closure#0}, static_init::mutex::linked_list::ListHead, core::alloc::AllocError> as pinned_init::PinInit<static_init::mutex::linked_list::ListHead, core::alloc::AllocError>>::__pinned_init
Line
Count
Source
45
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
1
        (self.0)(slot)
47
1
    }
48
}
49
50
/// This trait is only implemented via the `#[pin_data]` proc-macro. It is used to facilitate
51
/// the pin projections within the initializers.
52
///
53
/// # Safety
54
///
55
/// Only the `init` module is allowed to use this trait.
56
pub unsafe trait HasPinData {
57
    type PinData: PinData;
58
59
    unsafe fn __pin_data() -> Self::PinData;
60
}
61
62
/// Marker trait for pinning data of structs.
63
///
64
/// # Safety
65
///
66
/// Only the `init` module is allowed to use this trait.
67
pub unsafe trait PinData: Copy {
68
    type Datee: ?Sized + HasPinData;
69
70
    /// Type inference helper function.
71
93.7k
    fn make_closure<F, O, E>(self, f: F) -> F
72
93.7k
    where
73
93.7k
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
93.7k
    {
75
93.7k
        f
76
93.7k
    }
<alloc_fail::ring_buf::_::__ThePinData<alloc_fail::ring_buf::BigStruct, 64usize> as pinned_init::__internal::PinData>::make_closure::<<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>::new::{closure#0}, <alloc_fail::ring_buf::RingBuffer<_, _>>::new::__InitOk, core::convert::Infallible>
Line
Count
Source
71
1
    fn make_closure<F, O, E>(self, f: F) -> F
72
1
    where
73
1
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
1
    {
75
1
        f
76
1
    }
<alloc_fail::ring_buf::mutex::_::__ThePinData<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>> as pinned_init::__internal::PinData>::make_closure::<<alloc_fail::ring_buf::mutex::CMutex<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>>::new<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>::new::{closure#1}, alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>, core::convert::Infallible>>::{closure#0}, <alloc_fail::ring_buf::mutex::CMutex<_>>::new::__InitOk, core::convert::Infallible>
Line
Count
Source
71
1
    fn make_closure<F, O, E>(self, f: F) -> F
72
1
    where
73
1
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
1
    {
75
1
        f
76
1
    }
<alloc_fail::ring_buf::_::__ThePinData<u8, 64usize> as pinned_init::__internal::PinData>::make_closure::<<alloc_fail::ring_buf::RingBuffer<u8, 64usize>>::new::{closure#0}, <alloc_fail::ring_buf::RingBuffer<_, _>>::new::__InitOk, core::convert::Infallible>
Line
Count
Source
71
1
    fn make_closure<F, O, E>(self, f: F) -> F
72
1
    where
73
1
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
1
    {
75
1
        f
76
1
    }
<alloc_fail::ring_buf::_::__ThePinData<alloc_fail::ring_buf::EvenU64, 4usize> as pinned_init::__internal::PinData>::make_closure::<<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::EvenU64, 4usize>>::new::{closure#0}, <alloc_fail::ring_buf::RingBuffer<_, _>>::new::__InitOk, core::convert::Infallible>
Line
Count
Source
71
1
    fn make_closure<F, O, E>(self, f: F) -> F
72
1
    where
73
1
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
1
    {
75
1
        f
76
1
    }
<alloc_fail::ring_buf::mutex::_::__ThePinData as pinned_init::__internal::PinData>::make_closure::<<alloc_fail::ring_buf::mutex::WaitEntry>::insert_new::{closure#0}, <alloc_fail::ring_buf::mutex::WaitEntry>::insert_new::__InitOk, core::convert::Infallible>
Line
Count
Source
71
9.60k
    fn make_closure<F, O, E>(self, f: F) -> F
72
9.60k
    where
73
9.60k
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
9.60k
    {
75
9.60k
        f
76
9.60k
    }
<alloc_fail::ring_buf::_::__ThePinData<u8, 1099511627776usize> as pinned_init::__internal::PinData>::make_closure::<<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>>::new::{closure#0}, <alloc_fail::ring_buf::RingBuffer<_, _>>::new::__InitOk, core::convert::Infallible>
Line
Count
Source
71
2
    fn make_closure<F, O, E>(self, f: F) -> F
72
2
    where
73
2
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
2
    {
75
2
        f
76
2
    }
<alloc_fail::ring_buf::mutex::_::__ThePinData<usize> as pinned_init::__internal::PinData>::make_closure::<<alloc_fail::ring_buf::mutex::CMutex<usize>>::new<usize>::{closure#0}, <alloc_fail::ring_buf::mutex::CMutex<_>>::new::__InitOk, core::convert::Infallible>
Line
Count
Source
71
1
    fn make_closure<F, O, E>(self, f: F) -> F
72
1
    where
73
1
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
1
    {
75
1
        f
76
1
    }
<alloc_fail::ring_buf::mutex::linked_list::_::__ThePinData as pinned_init::__internal::PinData>::make_closure::<<alloc_fail::ring_buf::mutex::linked_list::ListHead>::new::{closure#0}, <alloc_fail::ring_buf::mutex::linked_list::ListHead>::new::__InitOk, core::convert::Infallible>
Line
Count
Source
71
3
    fn make_closure<F, O, E>(self, f: F) -> F
72
3
    where
73
3
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
3
    {
75
3
        f
76
3
    }
<alloc_fail::ring_buf::mutex::linked_list::_::__ThePinData as pinned_init::__internal::PinData>::make_closure::<<alloc_fail::ring_buf::mutex::linked_list::ListHead>::insert_next::{closure#0}, <alloc_fail::ring_buf::mutex::linked_list::ListHead>::insert_next::__InitOk, core::convert::Infallible>
Line
Count
Source
71
4
    fn make_closure<F, O, E>(self, f: F) -> F
72
4
    where
73
4
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
4
    {
75
4
        f
76
4
    }
<alloc_fail::ring_buf::mutex::linked_list::_::__ThePinData as pinned_init::__internal::PinData>::make_closure::<<alloc_fail::ring_buf::mutex::linked_list::ListHead>::insert_prev::{closure#0}, <alloc_fail::ring_buf::mutex::linked_list::ListHead>::insert_prev::__InitOk, core::convert::Infallible>
Line
Count
Source
71
9.60k
    fn make_closure<F, O, E>(self, f: F) -> F
72
9.60k
    where
73
9.60k
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
9.60k
    {
75
9.60k
        f
76
9.60k
    }
Unexecuted instantiation: <_ as pinned_init::__internal::PinData>::make_closure::<_, _, _>
Unexecuted instantiation: <_ as pinned_init::__internal::PinData>::make_closure::<_, _, _>
<ring_buf::mutex::_::__ThePinData<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>> as pinned_init::__internal::PinData>::make_closure::<<ring_buf::mutex::CMutex<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>>::new<pinned_init::__internal::InitClosure<<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>::new::{closure#1}, ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>, core::convert::Infallible>>::{closure#0}, <ring_buf::mutex::CMutex<_>>::new::__InitOk, core::convert::Infallible>
Line
Count
Source
71
1
    fn make_closure<F, O, E>(self, f: F) -> F
72
1
    where
73
1
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
1
    {
75
1
        f
76
1
    }
<ring_buf::mutex::linked_list::_::__ThePinData as pinned_init::__internal::PinData>::make_closure::<<ring_buf::mutex::linked_list::ListHead>::insert_next::{closure#0}, <ring_buf::mutex::linked_list::ListHead>::insert_next::__InitOk, core::convert::Infallible>
Line
Count
Source
71
4
    fn make_closure<F, O, E>(self, f: F) -> F
72
4
    where
73
4
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
4
    {
75
4
        f
76
4
    }
<ring_buf::mutex::_::__ThePinData<usize> as pinned_init::__internal::PinData>::make_closure::<<ring_buf::mutex::CMutex<usize>>::new<usize>::{closure#0}, <ring_buf::mutex::CMutex<_>>::new::__InitOk, core::convert::Infallible>
Line
Count
Source
71
1
    fn make_closure<F, O, E>(self, f: F) -> F
72
1
    where
73
1
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
1
    {
75
1
        f
76
1
    }
<ring_buf::mutex::linked_list::_::__ThePinData as pinned_init::__internal::PinData>::make_closure::<<ring_buf::mutex::linked_list::ListHead>::new::{closure#0}, <ring_buf::mutex::linked_list::ListHead>::new::__InitOk, core::convert::Infallible>
Line
Count
Source
71
3
    fn make_closure<F, O, E>(self, f: F) -> F
72
3
    where
73
3
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
3
    {
75
3
        f
76
3
    }
<ring_buf::mutex::_::__ThePinData as pinned_init::__internal::PinData>::make_closure::<<ring_buf::mutex::WaitEntry>::insert_new::{closure#0}, <ring_buf::mutex::WaitEntry>::insert_new::__InitOk, core::convert::Infallible>
Line
Count
Source
71
14.4k
    fn make_closure<F, O, E>(self, f: F) -> F
72
14.4k
    where
73
14.4k
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
14.4k
    {
75
14.4k
        f
76
14.4k
    }
<ring_buf::mutex::linked_list::_::__ThePinData as pinned_init::__internal::PinData>::make_closure::<<ring_buf::mutex::linked_list::ListHead>::insert_prev::{closure#0}, <ring_buf::mutex::linked_list::ListHead>::insert_prev::__InitOk, core::convert::Infallible>
Line
Count
Source
71
14.4k
    fn make_closure<F, O, E>(self, f: F) -> F
72
14.4k
    where
73
14.4k
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
14.4k
    {
75
14.4k
        f
76
14.4k
    }
<ring_buf::_::__ThePinData<ring_buf::BigStruct, 64usize> as pinned_init::__internal::PinData>::make_closure::<<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>::new::{closure#0}, <ring_buf::RingBuffer<_, _>>::new::__InitOk, core::convert::Infallible>
Line
Count
Source
71
1
    fn make_closure<F, O, E>(self, f: F) -> F
72
1
    where
73
1
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
1
    {
75
1
        f
76
1
    }
<ring_buf::_::__ThePinData<ring_buf::EvenU64, 4usize> as pinned_init::__internal::PinData>::make_closure::<<ring_buf::RingBuffer<ring_buf::EvenU64, 4usize>>::new::{closure#0}, <ring_buf::RingBuffer<_, _>>::new::__InitOk, core::convert::Infallible>
Line
Count
Source
71
1
    fn make_closure<F, O, E>(self, f: F) -> F
72
1
    where
73
1
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
1
    {
75
1
        f
76
1
    }
<ring_buf::_::__ThePinData<u8, 64usize> as pinned_init::__internal::PinData>::make_closure::<<ring_buf::RingBuffer<u8, 64usize>>::new::{closure#0}, <ring_buf::RingBuffer<_, _>>::new::__InitOk, core::convert::Infallible>
Line
Count
Source
71
1
    fn make_closure<F, O, E>(self, f: F) -> F
72
1
    where
73
1
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
1
    {
75
1
        f
76
1
    }
<linked_list::_::__ThePinData as pinned_init::__internal::PinData>::make_closure::<<linked_list::ListHead>::insert_next::{closure#0}, <linked_list::ListHead>::insert_next::__InitOk, core::convert::Infallible>
Line
Count
Source
71
4
    fn make_closure<F, O, E>(self, f: F) -> F
72
4
    where
73
4
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
4
    {
75
4
        f
76
4
    }
<linked_list::_::__ThePinData as pinned_init::__internal::PinData>::make_closure::<<linked_list::ListHead>::new::{closure#0}, <linked_list::ListHead>::new::__InitOk, core::convert::Infallible>
Line
Count
Source
71
1
    fn make_closure<F, O, E>(self, f: F) -> F
72
1
    where
73
1
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
1
    {
75
1
        f
76
1
    }
<mutex::_::__ThePinData<usize> as pinned_init::__internal::PinData>::make_closure::<<mutex::CMutex<usize>>::new<usize>::{closure#0}, <mutex::CMutex<_>>::new::__InitOk, core::convert::Infallible>
Line
Count
Source
71
1
    fn make_closure<F, O, E>(self, f: F) -> F
72
1
    where
73
1
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
1
    {
75
1
        f
76
1
    }
<mutex::_::__ThePinData as pinned_init::__internal::PinData>::make_closure::<<mutex::WaitEntry>::insert_new::{closure#0}, <mutex::WaitEntry>::insert_new::__InitOk, core::convert::Infallible>
Line
Count
Source
71
10.1k
    fn make_closure<F, O, E>(self, f: F) -> F
72
10.1k
    where
73
10.1k
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
10.1k
    {
75
10.1k
        f
76
10.1k
    }
<mutex::linked_list::_::__ThePinData as pinned_init::__internal::PinData>::make_closure::<<mutex::linked_list::ListHead>::new::{closure#0}, <mutex::linked_list::ListHead>::new::__InitOk, core::convert::Infallible>
Line
Count
Source
71
2
    fn make_closure<F, O, E>(self, f: F) -> F
72
2
    where
73
2
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
2
    {
75
2
        f
76
2
    }
<mutex::linked_list::_::__ThePinData as pinned_init::__internal::PinData>::make_closure::<<mutex::linked_list::ListHead>::insert_next::{closure#0}, <mutex::linked_list::ListHead>::insert_next::__InitOk, core::convert::Infallible>
Line
Count
Source
71
4
    fn make_closure<F, O, E>(self, f: F) -> F
72
4
    where
73
4
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
4
    {
75
4
        f
76
4
    }
<mutex::linked_list::_::__ThePinData as pinned_init::__internal::PinData>::make_closure::<<mutex::linked_list::ListHead>::insert_prev::{closure#0}, <mutex::linked_list::ListHead>::insert_prev::__InitOk, core::convert::Infallible>
Line
Count
Source
71
10.1k
    fn make_closure<F, O, E>(self, f: F) -> F
72
10.1k
    where
73
10.1k
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
10.1k
    {
75
10.1k
        f
76
10.1k
    }
<pthread_mutex::pthread_mtx::_::__ThePinData<usize> as pinned_init::__internal::PinData>::make_closure::<<pthread_mutex::pthread_mtx::PThreadMutex<usize>>::new::{closure#0}, <pthread_mutex::pthread_mtx::PThreadMutex<_>>::new::__InitOk, pthread_mutex::pthread_mtx::Error>
Line
Count
Source
71
1
    fn make_closure<F, O, E>(self, f: F) -> F
72
1
    where
73
1
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
1
    {
75
1
        f
76
1
    }
<static_init::mutex::_::__ThePinData<usize> as pinned_init::__internal::PinData>::make_closure::<<static_init::mutex::CMutex<usize>>::new<usize>::{closure#0}, <static_init::mutex::CMutex<_>>::new::__InitOk, core::convert::Infallible>
Line
Count
Source
71
1
    fn make_closure<F, O, E>(self, f: F) -> F
72
1
    where
73
1
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
1
    {
75
1
        f
76
1
    }
<static_init::mutex::linked_list::_::__ThePinData as pinned_init::__internal::PinData>::make_closure::<<static_init::mutex::linked_list::ListHead>::insert_next::{closure#0}, <static_init::mutex::linked_list::ListHead>::insert_next::__InitOk, core::convert::Infallible>
Line
Count
Source
71
4
    fn make_closure<F, O, E>(self, f: F) -> F
72
4
    where
73
4
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
4
    {
75
4
        f
76
4
    }
<static_init::mutex::linked_list::_::__ThePinData as pinned_init::__internal::PinData>::make_closure::<<static_init::mutex::linked_list::ListHead>::insert_prev::{closure#0}, <static_init::mutex::linked_list::ListHead>::insert_prev::__InitOk, core::convert::Infallible>
Line
Count
Source
71
12.6k
    fn make_closure<F, O, E>(self, f: F) -> F
72
12.6k
    where
73
12.6k
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
12.6k
    {
75
12.6k
        f
76
12.6k
    }
<static_init::mutex::_::__ThePinData as pinned_init::__internal::PinData>::make_closure::<<static_init::mutex::WaitEntry>::insert_new::{closure#0}, <static_init::mutex::WaitEntry>::insert_new::__InitOk, core::convert::Infallible>
Line
Count
Source
71
12.6k
    fn make_closure<F, O, E>(self, f: F) -> F
72
12.6k
    where
73
12.6k
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
12.6k
    {
75
12.6k
        f
76
12.6k
    }
<static_init::mutex::linked_list::_::__ThePinData as pinned_init::__internal::PinData>::make_closure::<<static_init::mutex::linked_list::ListHead>::new::{closure#0}, <static_init::mutex::linked_list::ListHead>::new::__InitOk, core::convert::Infallible>
Line
Count
Source
71
2
    fn make_closure<F, O, E>(self, f: F) -> F
72
2
    where
73
2
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
2
    {
75
2
        f
76
2
    }
77
}
78
79
/// This trait is automatically implemented for every type. It aims to provide the same type
80
/// inference help as `HasPinData`.
81
///
82
/// # Safety
83
///
84
/// Only the `init` module is allowed to use this trait.
85
pub unsafe trait HasInitData {
86
    type InitData: InitData;
87
88
    unsafe fn __init_data() -> Self::InitData;
89
}
90
91
/// Same function as `PinData`, but for arbitrary data.
92
///
93
/// # Safety
94
///
95
/// Only the `init` module is allowed to use this trait.
96
pub unsafe trait InitData: Copy {
97
    type Datee: ?Sized + HasInitData;
98
99
    /// Type inference helper function.
100
160
    fn make_closure<F, O, E>(self, f: F) -> F
101
160
    where
102
160
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
103
160
    {
104
160
        f
105
160
    }
<pinned_init::__internal::AllData<alloc_fail::ring_buf::EvenU64> as pinned_init::__internal::InitData>::make_closure::<<alloc_fail::ring_buf::EvenU64>::new2::{closure#0}, <alloc_fail::ring_buf::EvenU64>::new2::__InitOk, core::alloc::AllocError>
Line
Count
Source
100
4
    fn make_closure<F, O, E>(self, f: F) -> F
101
4
    where
102
4
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
103
4
    {
104
4
        f
105
4
    }
<pinned_init::__internal::AllData<alloc_fail::ring_buf::BigStruct> as pinned_init::__internal::InitData>::make_closure::<alloc_fail::ring_buf::with_big_struct::{closure#0}, alloc_fail::ring_buf::with_big_struct::__InitOk, core::convert::Infallible>
Line
Count
Source
100
63
    fn make_closure<F, O, E>(self, f: F) -> F
101
63
    where
102
63
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
103
63
    {
104
63
        f
105
63
    }
<pinned_init::__internal::AllData<alloc_fail::ring_buf::BigStruct> as pinned_init::__internal::InitData>::make_closure::<alloc_fail::ring_buf::big_struct::{closure#2}, alloc_fail::ring_buf::big_struct::__InitOk, core::convert::Infallible>
Line
Count
Source
100
1
    fn make_closure<F, O, E>(self, f: F) -> F
101
1
    where
102
1
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
103
1
    {
104
1
        f
105
1
    }
<pinned_init::__internal::AllData<alloc_fail::ring_buf::EvenU64> as pinned_init::__internal::InitData>::make_closure::<<alloc_fail::ring_buf::EvenU64>::new::{closure#0}, <alloc_fail::ring_buf::EvenU64>::new::__InitOk, ()>
Line
Count
Source
100
9
    fn make_closure<F, O, E>(self, f: F) -> F
101
9
    where
102
9
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
103
9
    {
104
9
        f
105
9
    }
<pinned_init::__internal::AllData<alloc_fail::ring_buf::BigStruct> as pinned_init::__internal::InitData>::make_closure::<alloc_fail::ring_buf::big_struct::{closure#0}, alloc_fail::ring_buf::big_struct::__InitOk, core::convert::Infallible>
Line
Count
Source
100
1
    fn make_closure<F, O, E>(self, f: F) -> F
101
1
    where
102
1
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
103
1
    {
104
1
        f
105
1
    }
<pinned_init::__internal::AllData<alloc_fail::ring_buf::BigStruct> as pinned_init::__internal::InitData>::make_closure::<alloc_fail::ring_buf::with_big_struct::{closure#2}, alloc_fail::ring_buf::with_big_struct::__InitOk, core::convert::Infallible>
Line
Count
Source
100
1
    fn make_closure<F, O, E>(self, f: F) -> F
101
1
    where
102
1
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
103
1
    {
104
1
        f
105
1
    }
Unexecuted instantiation: <_ as pinned_init::__internal::InitData>::make_closure::<_, _, _>
<pinned_init::__internal::AllData<pinned_init::__internal::stack_init_reuse::Foo> as pinned_init::__internal::InitData>::make_closure::<pinned_init::__internal::stack_init_reuse::{closure#2}, pinned_init::__internal::stack_init_reuse::__InitOk, core::convert::Infallible>
Line
Count
Source
100
1
    fn make_closure<F, O, E>(self, f: F) -> F
101
1
    where
102
1
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
103
1
    {
104
1
        f
105
1
    }
<pinned_init::__internal::AllData<pinned_init::__internal::stack_init_reuse::Foo> as pinned_init::__internal::InitData>::make_closure::<pinned_init::__internal::stack_init_reuse::{closure#0}, pinned_init::__internal::stack_init_reuse::__InitOk, core::convert::Infallible>
Line
Count
Source
100
1
    fn make_closure<F, O, E>(self, f: F) -> F
101
1
    where
102
1
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
103
1
    {
104
1
        f
105
1
    }
<pinned_init::__internal::AllData<ring_buf::EvenU64> as pinned_init::__internal::InitData>::make_closure::<<ring_buf::EvenU64>::new::{closure#0}, <ring_buf::EvenU64>::new::__InitOk, ()>
Line
Count
Source
100
9
    fn make_closure<F, O, E>(self, f: F) -> F
101
9
    where
102
9
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
103
9
    {
104
9
        f
105
9
    }
<pinned_init::__internal::AllData<ring_buf::BigStruct> as pinned_init::__internal::InitData>::make_closure::<ring_buf::with_big_struct::{closure#2}, ring_buf::with_big_struct::__InitOk, core::convert::Infallible>
Line
Count
Source
100
1
    fn make_closure<F, O, E>(self, f: F) -> F
101
1
    where
102
1
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
103
1
    {
104
1
        f
105
1
    }
<pinned_init::__internal::AllData<ring_buf::BigStruct> as pinned_init::__internal::InitData>::make_closure::<ring_buf::big_struct::{closure#2}, ring_buf::big_struct::__InitOk, core::convert::Infallible>
Line
Count
Source
100
1
    fn make_closure<F, O, E>(self, f: F) -> F
101
1
    where
102
1
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
103
1
    {
104
1
        f
105
1
    }
<pinned_init::__internal::AllData<ring_buf::BigStruct> as pinned_init::__internal::InitData>::make_closure::<ring_buf::with_big_struct::{closure#0}, ring_buf::with_big_struct::__InitOk, core::convert::Infallible>
Line
Count
Source
100
63
    fn make_closure<F, O, E>(self, f: F) -> F
101
63
    where
102
63
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
103
63
    {
104
63
        f
105
63
    }
<pinned_init::__internal::AllData<ring_buf::EvenU64> as pinned_init::__internal::InitData>::make_closure::<<ring_buf::EvenU64>::new2::{closure#0}, <ring_buf::EvenU64>::new2::__InitOk, core::alloc::AllocError>
Line
Count
Source
100
4
    fn make_closure<F, O, E>(self, f: F) -> F
101
4
    where
102
4
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
103
4
    {
104
4
        f
105
4
    }
<pinned_init::__internal::AllData<ring_buf::BigStruct> as pinned_init::__internal::InitData>::make_closure::<ring_buf::big_struct::{closure#0}, ring_buf::big_struct::__InitOk, core::convert::Infallible>
Line
Count
Source
100
1
    fn make_closure<F, O, E>(self, f: F) -> F
101
1
    where
102
1
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
103
1
    {
104
1
        f
105
1
    }
106
}
107
108
pub struct AllData<T: ?Sized>(Invariant<T>);
109
110
impl<T: ?Sized> Clone for AllData<T> {
111
    #[cfg_attr(coverage_nightly, no_coverage)]
112
    fn clone(&self) -> Self {
113
        *self
114
    }
115
}
116
117
impl<T: ?Sized> Copy for AllData<T> {}
118
119
unsafe impl<T: ?Sized> InitData for AllData<T> {
120
    type Datee = T;
121
}
122
123
unsafe impl<T: ?Sized> HasInitData for T {
124
    type InitData = AllData<T>;
125
126
160
    unsafe fn __init_data() -> Self::InitData {
127
160
        AllData(PhantomData)
128
160
    }
<alloc_fail::ring_buf::BigStruct as pinned_init::__internal::HasInitData>::__init_data
Line
Count
Source
126
66
    unsafe fn __init_data() -> Self::InitData {
127
66
        AllData(PhantomData)
128
66
    }
<alloc_fail::ring_buf::EvenU64 as pinned_init::__internal::HasInitData>::__init_data
Line
Count
Source
126
13
    unsafe fn __init_data() -> Self::InitData {
127
13
        AllData(PhantomData)
128
13
    }
Unexecuted instantiation: <_ as pinned_init::__internal::HasInitData>::__init_data
<pinned_init::__internal::stack_init_reuse::Foo as pinned_init::__internal::HasInitData>::__init_data
Line
Count
Source
126
2
    unsafe fn __init_data() -> Self::InitData {
127
2
        AllData(PhantomData)
128
2
    }
<ring_buf::BigStruct as pinned_init::__internal::HasInitData>::__init_data
Line
Count
Source
126
66
    unsafe fn __init_data() -> Self::InitData {
127
66
        AllData(PhantomData)
128
66
    }
<ring_buf::EvenU64 as pinned_init::__internal::HasInitData>::__init_data
Line
Count
Source
126
13
    unsafe fn __init_data() -> Self::InitData {
127
13
        AllData(PhantomData)
128
13
    }
129
}
130
131
/// Stack initializer helper type. Use [`stack_pin_init`] instead of this primitive.
132
///
133
/// # Invariants
134
///
135
/// If `self.is_init` is true, then `self.value` is initialized.
136
///
137
/// [`stack_pin_init`]: crate::stack_pin_init
138
pub struct StackInit<T> {
139
    value: MaybeUninit<T>,
140
    is_init: bool,
141
}
142
143
impl<T> Drop for StackInit<T> {
144
    #[inline]
145
46.9k
    fn drop(&mut self) {
146
46.9k
        if self.is_init {
147
46.9k
            // SAFETY: As we are being dropped, we only call this once. And since `self.is_init` is
148
46.9k
            // true, `self.value` is initialized.
149
46.9k
            unsafe { self.value.assume_init_drop() };
150
46.9k
        }
2
151
46.9k
    }
<pinned_init::__internal::StackInit<u8> as core::ops::drop::Drop>::drop
Line
Count
Source
145
63
    fn drop(&mut self) {
146
63
        if self.is_init {
147
63
            // SAFETY: As we are being dropped, we only call this once. And since `self.is_init` is
148
63
            // true, `self.value` is initialized.
149
63
            unsafe { self.value.assume_init_drop() };
150
63
        }
0
151
63
    }
<pinned_init::__internal::StackInit<alloc_fail::ring_buf::RingBuffer<u8, 64usize>> as core::ops::drop::Drop>::drop
Line
Count
Source
145
1
    fn drop(&mut self) {
146
1
        if self.is_init {
147
1
            // SAFETY: As we are being dropped, we only call this once. And since `self.is_init` is
148
1
            // true, `self.value` is initialized.
149
1
            unsafe { self.value.assume_init_drop() };
150
1
        }
0
151
1
    }
<pinned_init::__internal::StackInit<alloc_fail::ring_buf::mutex::WaitEntry> as core::ops::drop::Drop>::drop
Line
Count
Source
145
9.60k
    fn drop(&mut self) {
146
9.60k
        if self.is_init {
147
9.60k
            // SAFETY: As we are being dropped, we only call this once. And since `self.is_init` is
148
9.60k
            // true, `self.value` is initialized.
149
9.60k
            unsafe { self.value.assume_init_drop() };
150
9.60k
        }
0
151
9.60k
    }
<pinned_init::__internal::StackInit<alloc_fail::ring_buf::mutex::linked_list::ListHead> as core::ops::drop::Drop>::drop
Line
Count
Source
145
3
    fn drop(&mut self) {
146
3
        if self.is_init {
147
3
            // SAFETY: As we are being dropped, we only call this once. And since `self.is_init` is
148
3
            // true, `self.value` is initialized.
149
3
            unsafe { self.value.assume_init_drop() };
150
3
        }
0
151
3
    }
<pinned_init::__internal::StackInit<alloc_fail::ring_buf::EvenU64> as core::ops::drop::Drop>::drop
Line
Count
Source
145
2
    fn drop(&mut self) {
146
2
        if self.is_init {
147
1
            // SAFETY: As we are being dropped, we only call this once. And since `self.is_init` is
148
1
            // true, `self.value` is initialized.
149
1
            unsafe { self.value.assume_init_drop() };
150
1
        }
151
2
    }
Unexecuted instantiation: <pinned_init::__internal::StackInit<_> as core::ops::drop::Drop>::drop
<pinned_init::__internal::StackInit<pinned_init::__internal::stack_init_reuse::Foo> as core::ops::drop::Drop>::drop
Line
Count
Source
145
1
    fn drop(&mut self) {
146
1
        if self.is_init {
147
1
            // SAFETY: As we are being dropped, we only call this once. And since `self.is_init` is
148
1
            // true, `self.value` is initialized.
149
1
            unsafe { self.value.assume_init_drop() };
150
1
        }
0
151
1
    }
<pinned_init::__internal::StackInit<ring_buf::EvenU64> as core::ops::drop::Drop>::drop
Line
Count
Source
145
2
    fn drop(&mut self) {
146
2
        if self.is_init {
147
1
            // SAFETY: As we are being dropped, we only call this once. And since `self.is_init` is
148
1
            // true, `self.value` is initialized.
149
1
            unsafe { self.value.assume_init_drop() };
150
1
        }
151
2
    }
<pinned_init::__internal::StackInit<ring_buf::mutex::WaitEntry> as core::ops::drop::Drop>::drop
Line
Count
Source
145
14.4k
    fn drop(&mut self) {
146
14.4k
        if self.is_init {
147
14.4k
            // SAFETY: As we are being dropped, we only call this once. And since `self.is_init` is
148
14.4k
            // true, `self.value` is initialized.
149
14.4k
            unsafe { self.value.assume_init_drop() };
150
14.4k
        }
0
151
14.4k
    }
<pinned_init::__internal::StackInit<ring_buf::RingBuffer<u8, 64usize>> as core::ops::drop::Drop>::drop
Line
Count
Source
145
1
    fn drop(&mut self) {
146
1
        if self.is_init {
147
1
            // SAFETY: As we are being dropped, we only call this once. And since `self.is_init` is
148
1
            // true, `self.value` is initialized.
149
1
            unsafe { self.value.assume_init_drop() };
150
1
        }
0
151
1
    }
<pinned_init::__internal::StackInit<u8> as core::ops::drop::Drop>::drop
Line
Count
Source
145
63
    fn drop(&mut self) {
146
63
        if self.is_init {
147
63
            // SAFETY: As we are being dropped, we only call this once. And since `self.is_init` is
148
63
            // true, `self.value` is initialized.
149
63
            unsafe { self.value.assume_init_drop() };
150
63
        }
0
151
63
    }
<pinned_init::__internal::StackInit<ring_buf::mutex::linked_list::ListHead> as core::ops::drop::Drop>::drop
Line
Count
Source
145
3
    fn drop(&mut self) {
146
3
        if self.is_init {
147
3
            // SAFETY: As we are being dropped, we only call this once. And since `self.is_init` is
148
3
            // true, `self.value` is initialized.
149
3
            unsafe { self.value.assume_init_drop() };
150
3
        }
0
151
3
    }
<pinned_init::__internal::StackInit<linked_list::ListHead> as core::ops::drop::Drop>::drop
Line
Count
Source
145
3
    fn drop(&mut self) {
146
3
        if self.is_init {
147
3
            // SAFETY: As we are being dropped, we only call this once. And since `self.is_init` is
148
3
            // true, `self.value` is initialized.
149
3
            unsafe { self.value.assume_init_drop() };
150
3
        }
0
151
3
    }
<pinned_init::__internal::StackInit<mutex::WaitEntry> as core::ops::drop::Drop>::drop
Line
Count
Source
145
10.1k
    fn drop(&mut self) {
146
10.1k
        if self.is_init {
147
10.1k
            // SAFETY: As we are being dropped, we only call this once. And since `self.is_init` is
148
10.1k
            // true, `self.value` is initialized.
149
10.1k
            unsafe { self.value.assume_init_drop() };
150
10.1k
        }
0
151
10.1k
    }
<pinned_init::__internal::StackInit<mutex::linked_list::ListHead> as core::ops::drop::Drop>::drop
Line
Count
Source
145
3
    fn drop(&mut self) {
146
3
        if self.is_init {
147
3
            // SAFETY: As we are being dropped, we only call this once. And since `self.is_init` is
148
3
            // true, `self.value` is initialized.
149
3
            unsafe { self.value.assume_init_drop() };
150
3
        }
0
151
3
    }
<pinned_init::__internal::StackInit<static_init::mutex::WaitEntry> as core::ops::drop::Drop>::drop
Line
Count
Source
145
12.6k
    fn drop(&mut self) {
146
12.6k
        if self.is_init {
147
12.6k
            // SAFETY: As we are being dropped, we only call this once. And since `self.is_init` is
148
12.6k
            // true, `self.value` is initialized.
149
12.6k
            unsafe { self.value.assume_init_drop() };
150
12.6k
        }
0
151
12.6k
    }
<pinned_init::__internal::StackInit<static_init::mutex::linked_list::ListHead> as core::ops::drop::Drop>::drop
Line
Count
Source
145
3
    fn drop(&mut self) {
146
3
        if self.is_init {
147
3
            // SAFETY: As we are being dropped, we only call this once. And since `self.is_init` is
148
3
            // true, `self.value` is initialized.
149
3
            unsafe { self.value.assume_init_drop() };
150
3
        }
0
151
3
    }
152
}
153
154
impl<T> StackInit<T> {
155
    /// Creates a new [`StackInit<T>`] that is uninitialized. Use [`stack_pin_init`] instead of this
156
    /// primitive.
157
    ///
158
    /// [`stack_pin_init`]: pinned_init::stack_pin_init
159
    #[inline]
160
46.9k
    pub fn uninit() -> Self {
161
46.9k
        Self {
162
46.9k
            value: MaybeUninit::uninit(),
163
46.9k
            is_init: false,
164
46.9k
        }
165
46.9k
    }
<pinned_init::__internal::StackInit<alloc_fail::ring_buf::EvenU64>>::uninit
Line
Count
Source
160
2
    pub fn uninit() -> Self {
161
2
        Self {
162
2
            value: MaybeUninit::uninit(),
163
2
            is_init: false,
164
2
        }
165
2
    }
<pinned_init::__internal::StackInit<alloc_fail::ring_buf::mutex::linked_list::ListHead>>::uninit
Line
Count
Source
160
3
    pub fn uninit() -> Self {
161
3
        Self {
162
3
            value: MaybeUninit::uninit(),
163
3
            is_init: false,
164
3
        }
165
3
    }
<pinned_init::__internal::StackInit<alloc_fail::ring_buf::mutex::WaitEntry>>::uninit
Line
Count
Source
160
9.60k
    pub fn uninit() -> Self {
161
9.60k
        Self {
162
9.60k
            value: MaybeUninit::uninit(),
163
9.60k
            is_init: false,
164
9.60k
        }
165
9.60k
    }
<pinned_init::__internal::StackInit<alloc_fail::ring_buf::RingBuffer<u8, 64usize>>>::uninit
Line
Count
Source
160
1
    pub fn uninit() -> Self {
161
1
        Self {
162
1
            value: MaybeUninit::uninit(),
163
1
            is_init: false,
164
1
        }
165
1
    }
<pinned_init::__internal::StackInit<u8>>::uninit
Line
Count
Source
160
63
    pub fn uninit() -> Self {
161
63
        Self {
162
63
            value: MaybeUninit::uninit(),
163
63
            is_init: false,
164
63
        }
165
63
    }
Unexecuted instantiation: <pinned_init::__internal::StackInit<_>>::uninit
<pinned_init::__internal::StackInit<pinned_init::__internal::stack_init_reuse::Foo>>::uninit
Line
Count
Source
160
1
    pub fn uninit() -> Self {
161
1
        Self {
162
1
            value: MaybeUninit::uninit(),
163
1
            is_init: false,
164
1
        }
165
1
    }
<pinned_init::__internal::StackInit<ring_buf::mutex::linked_list::ListHead>>::uninit
Line
Count
Source
160
3
    pub fn uninit() -> Self {
161
3
        Self {
162
3
            value: MaybeUninit::uninit(),
163
3
            is_init: false,
164
3
        }
165
3
    }
<pinned_init::__internal::StackInit<ring_buf::RingBuffer<u8, 64usize>>>::uninit
Line
Count
Source
160
1
    pub fn uninit() -> Self {
161
1
        Self {
162
1
            value: MaybeUninit::uninit(),
163
1
            is_init: false,
164
1
        }
165
1
    }
<pinned_init::__internal::StackInit<ring_buf::mutex::WaitEntry>>::uninit
Line
Count
Source
160
14.4k
    pub fn uninit() -> Self {
161
14.4k
        Self {
162
14.4k
            value: MaybeUninit::uninit(),
163
14.4k
            is_init: false,
164
14.4k
        }
165
14.4k
    }
<pinned_init::__internal::StackInit<u8>>::uninit
Line
Count
Source
160
63
    pub fn uninit() -> Self {
161
63
        Self {
162
63
            value: MaybeUninit::uninit(),
163
63
            is_init: false,
164
63
        }
165
63
    }
<pinned_init::__internal::StackInit<ring_buf::EvenU64>>::uninit
Line
Count
Source
160
2
    pub fn uninit() -> Self {
161
2
        Self {
162
2
            value: MaybeUninit::uninit(),
163
2
            is_init: false,
164
2
        }
165
2
    }
<pinned_init::__internal::StackInit<linked_list::ListHead>>::uninit
Line
Count
Source
160
3
    pub fn uninit() -> Self {
161
3
        Self {
162
3
            value: MaybeUninit::uninit(),
163
3
            is_init: false,
164
3
        }
165
3
    }
<pinned_init::__internal::StackInit<mutex::linked_list::ListHead>>::uninit
Line
Count
Source
160
3
    pub fn uninit() -> Self {
161
3
        Self {
162
3
            value: MaybeUninit::uninit(),
163
3
            is_init: false,
164
3
        }
165
3
    }
<pinned_init::__internal::StackInit<mutex::WaitEntry>>::uninit
Line
Count
Source
160
10.1k
    pub fn uninit() -> Self {
161
10.1k
        Self {
162
10.1k
            value: MaybeUninit::uninit(),
163
10.1k
            is_init: false,
164
10.1k
        }
165
10.1k
    }
<pinned_init::__internal::StackInit<static_init::mutex::linked_list::ListHead>>::uninit
Line
Count
Source
160
3
    pub fn uninit() -> Self {
161
3
        Self {
162
3
            value: MaybeUninit::uninit(),
163
3
            is_init: false,
164
3
        }
165
3
    }
<pinned_init::__internal::StackInit<static_init::mutex::WaitEntry>>::uninit
Line
Count
Source
160
12.6k
    pub fn uninit() -> Self {
161
12.6k
        Self {
162
12.6k
            value: MaybeUninit::uninit(),
163
12.6k
            is_init: false,
164
12.6k
        }
165
12.6k
    }
166
167
    /// Initializes the contents and returns the result.
168
    #[inline]
169
46.9k
    pub fn init<E>(self: Pin<&mut Self>, init: impl PinInit<T, E>) -> Result<Pin<&mut T>, E> {
170
46.9k
        // SAFETY: We never move out of `this`.
171
46.9k
        let this = unsafe { Pin::into_inner_unchecked(self) };
172
46.9k
        // The value is currently initialized, so it needs to be dropped before we can reuse
173
46.9k
        // the memory (this is a safety guarantee of `Pin`).
174
46.9k
        if this.is_init {
175
1
            this.is_init = false;
176
1
            // SAFETY: `this.is_init` was true and therefore `this.value` is initialized.
177
1
            unsafe { this.value.assume_init_drop() };
178
46.9k
        }
179
        // SAFETY: The memory slot is valid and this type ensures that it will stay pinned.
180
46.9k
        unsafe { init.__pinned_init(this.value.as_mut_ptr())
?2
};
181
        // INVARIANT: `this.value` is initialized above.
182
46.9k
        this.is_init = true;
183
46.9k
        // SAFETY: The slot is now pinned, since we will never give access to `&mut T`.
184
46.9k
        Ok(unsafe { Pin::new_unchecked(this.value.assume_init_mut()) })
185
46.9k
    }
<pinned_init::__internal::StackInit<u8>>::init::<core::convert::Infallible, pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<u8, 64usize>>::pop_no_stack::{closure#0}, u8, core::convert::Infallible>>
Line
Count
Source
169
63
    pub fn init<E>(self: Pin<&mut Self>, init: impl PinInit<T, E>) -> Result<Pin<&mut T>, E> {
170
63
        // SAFETY: We never move out of `this`.
171
63
        let this = unsafe { Pin::into_inner_unchecked(self) };
172
63
        // The value is currently initialized, so it needs to be dropped before we can reuse
173
63
        // the memory (this is a safety guarantee of `Pin`).
174
63
        if this.is_init {
175
0
            this.is_init = false;
176
0
            // SAFETY: `this.is_init` was true and therefore `this.value` is initialized.
177
0
            unsafe { this.value.assume_init_drop() };
178
63
        }
179
        // SAFETY: The memory slot is valid and this type ensures that it will stay pinned.
180
63
        unsafe { init.__pinned_init(this.value.as_mut_ptr())
?0
};
181
        // INVARIANT: `this.value` is initialized above.
182
63
        this.is_init = true;
183
63
        // SAFETY: The slot is now pinned, since we will never give access to `&mut T`.
184
63
        Ok(unsafe { Pin::new_unchecked(this.value.assume_init_mut()) })
185
63
    }
<pinned_init::__internal::StackInit<alloc_fail::ring_buf::RingBuffer<u8, 64usize>>>::init::<core::convert::Infallible, pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<u8, 64usize>>::new::{closure#1}, alloc_fail::ring_buf::RingBuffer<u8, 64usize>, core::convert::Infallible>>
Line
Count
Source
169
1
    pub fn init<E>(self: Pin<&mut Self>, init: impl PinInit<T, E>) -> Result<Pin<&mut T>, E> {
170
1
        // SAFETY: We never move out of `this`.
171
1
        let this = unsafe { Pin::into_inner_unchecked(self) };
172
1
        // The value is currently initialized, so it needs to be dropped before we can reuse
173
1
        // the memory (this is a safety guarantee of `Pin`).
174
1
        if this.is_init {
175
0
            this.is_init = false;
176
0
            // SAFETY: `this.is_init` was true and therefore `this.value` is initialized.
177
0
            unsafe { this.value.assume_init_drop() };
178
1
        }
179
        // SAFETY: The memory slot is valid and this type ensures that it will stay pinned.
180
1
        unsafe { init.__pinned_init(this.value.as_mut_ptr())
?0
};
181
        // INVARIANT: `this.value` is initialized above.
182
1
        this.is_init = true;
183
1
        // SAFETY: The slot is now pinned, since we will never give access to `&mut T`.
184
1
        Ok(unsafe { Pin::new_unchecked(this.value.assume_init_mut()) })
185
1
    }
<pinned_init::__internal::StackInit<alloc_fail::ring_buf::EvenU64>>::init::<(), pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::EvenU64>::new::{closure#1}, alloc_fail::ring_buf::EvenU64, ()>>
Line
Count
Source
169
2
    pub fn init<E>(self: Pin<&mut Self>, init: impl PinInit<T, E>) -> Result<Pin<&mut T>, E> {
170
2
        // SAFETY: We never move out of `this`.
171
2
        let this = unsafe { Pin::into_inner_unchecked(self) };
172
2
        // The value is currently initialized, so it needs to be dropped before we can reuse
173
2
        // the memory (this is a safety guarantee of `Pin`).
174
2
        if this.is_init {
175
0
            this.is_init = false;
176
0
            // SAFETY: `this.is_init` was true and therefore `this.value` is initialized.
177
0
            unsafe { this.value.assume_init_drop() };
178
2
        }
179
        // SAFETY: The memory slot is valid and this type ensures that it will stay pinned.
180
2
        unsafe { init.__pinned_init(this.value.as_mut_ptr())
?1
};
181
        // INVARIANT: `this.value` is initialized above.
182
1
        this.is_init = true;
183
1
        // SAFETY: The slot is now pinned, since we will never give access to `&mut T`.
184
1
        Ok(unsafe { Pin::new_unchecked(this.value.assume_init_mut()) })
185
2
    }
<pinned_init::__internal::StackInit<alloc_fail::ring_buf::mutex::WaitEntry>>::init::<core::convert::Infallible, pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::mutex::WaitEntry>::insert_new::{closure#1}, alloc_fail::ring_buf::mutex::WaitEntry, core::convert::Infallible>>
Line
Count
Source
169
9.60k
    pub fn init<E>(self: Pin<&mut Self>, init: impl PinInit<T, E>) -> Result<Pin<&mut T>, E> {
170
9.60k
        // SAFETY: We never move out of `this`.
171
9.60k
        let this = unsafe { Pin::into_inner_unchecked(self) };
172
9.60k
        // The value is currently initialized, so it needs to be dropped before we can reuse
173
9.60k
        // the memory (this is a safety guarantee of `Pin`).
174
9.60k
        if this.is_init {
175
0
            this.is_init = false;
176
0
            // SAFETY: `this.is_init` was true and therefore `this.value` is initialized.
177
0
            unsafe { this.value.assume_init_drop() };
178
9.60k
        }
179
        // SAFETY: The memory slot is valid and this type ensures that it will stay pinned.
180
9.60k
        unsafe { init.__pinned_init(this.value.as_mut_ptr())
?0
};
181
        // INVARIANT: `this.value` is initialized above.
182
9.60k
        this.is_init = true;
183
9.60k
        // SAFETY: The slot is now pinned, since we will never give access to `&mut T`.
184
9.60k
        Ok(unsafe { Pin::new_unchecked(this.value.assume_init_mut()) })
185
9.60k
    }
<pinned_init::__internal::StackInit<alloc_fail::ring_buf::mutex::linked_list::ListHead>>::init::<core::convert::Infallible, pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::mutex::linked_list::ListHead>::insert_next::{closure#1}, alloc_fail::ring_buf::mutex::linked_list::ListHead, core::convert::Infallible>>
Line
Count
Source
169
3
    pub fn init<E>(self: Pin<&mut Self>, init: impl PinInit<T, E>) -> Result<Pin<&mut T>, E> {
170
3
        // SAFETY: We never move out of `this`.
171
3
        let this = unsafe { Pin::into_inner_unchecked(self) };
172
3
        // The value is currently initialized, so it needs to be dropped before we can reuse
173
3
        // the memory (this is a safety guarantee of `Pin`).
174
3
        if this.is_init {
175
0
            this.is_init = false;
176
0
            // SAFETY: `this.is_init` was true and therefore `this.value` is initialized.
177
0
            unsafe { this.value.assume_init_drop() };
178
3
        }
179
        // SAFETY: The memory slot is valid and this type ensures that it will stay pinned.
180
3
        unsafe { init.__pinned_init(this.value.as_mut_ptr())
?0
};
181
        // INVARIANT: `this.value` is initialized above.
182
3
        this.is_init = true;
183
3
        // SAFETY: The slot is now pinned, since we will never give access to `&mut T`.
184
3
        Ok(unsafe { Pin::new_unchecked(this.value.assume_init_mut()) })
185
3
    }
Unexecuted instantiation: <pinned_init::__internal::StackInit<_>>::init::<_, _>
<pinned_init::__internal::StackInit<pinned_init::__internal::stack_init_reuse::Foo>>::init::<core::convert::Infallible, pinned_init::__internal::InitClosure<pinned_init::__internal::stack_init_reuse::{closure#3}, pinned_init::__internal::stack_init_reuse::Foo, core::convert::Infallible>>
Line
Count
Source
169
1
    pub fn init<E>(self: Pin<&mut Self>, init: impl PinInit<T, E>) -> Result<Pin<&mut T>, E> {
170
1
        // SAFETY: We never move out of `this`.
171
1
        let this = unsafe { Pin::into_inner_unchecked(self) };
172
1
        // The value is currently initialized, so it needs to be dropped before we can reuse
173
1
        // the memory (this is a safety guarantee of `Pin`).
174
1
        if this.is_init {
175
1
            this.is_init = false;
176
1
            // SAFETY: `this.is_init` was true and therefore `this.value` is initialized.
177
1
            unsafe { this.value.assume_init_drop() };
178
1
        }
0
179
        // SAFETY: The memory slot is valid and this type ensures that it will stay pinned.
180
1
        unsafe { init.__pinned_init(this.value.as_mut_ptr())
?0
};
181
        // INVARIANT: `this.value` is initialized above.
182
1
        this.is_init = true;
183
1
        // SAFETY: The slot is now pinned, since we will never give access to `&mut T`.
184
1
        Ok(unsafe { Pin::new_unchecked(this.value.assume_init_mut()) })
185
1
    }
<pinned_init::__internal::StackInit<pinned_init::__internal::stack_init_reuse::Foo>>::init::<core::convert::Infallible, pinned_init::__internal::InitClosure<pinned_init::__internal::stack_init_reuse::{closure#1}, pinned_init::__internal::stack_init_reuse::Foo, core::convert::Infallible>>
Line
Count
Source
169
1
    pub fn init<E>(self: Pin<&mut Self>, init: impl PinInit<T, E>) -> Result<Pin<&mut T>, E> {
170
1
        // SAFETY: We never move out of `this`.
171
1
        let this = unsafe { Pin::into_inner_unchecked(self) };
172
1
        // The value is currently initialized, so it needs to be dropped before we can reuse
173
1
        // the memory (this is a safety guarantee of `Pin`).
174
1
        if this.is_init {
175
0
            this.is_init = false;
176
0
            // SAFETY: `this.is_init` was true and therefore `this.value` is initialized.
177
0
            unsafe { this.value.assume_init_drop() };
178
1
        }
179
        // SAFETY: The memory slot is valid and this type ensures that it will stay pinned.
180
1
        unsafe { init.__pinned_init(this.value.as_mut_ptr())
?0
};
181
        // INVARIANT: `this.value` is initialized above.
182
1
        this.is_init = true;
183
1
        // SAFETY: The slot is now pinned, since we will never give access to `&mut T`.
184
1
        Ok(unsafe { Pin::new_unchecked(this.value.assume_init_mut()) })
185
1
    }
<pinned_init::__internal::StackInit<u8>>::init::<core::convert::Infallible, pinned_init::__internal::InitClosure<<ring_buf::RingBuffer<u8, 64usize>>::pop_no_stack::{closure#0}, u8, core::convert::Infallible>>
Line
Count
Source
169
63
    pub fn init<E>(self: Pin<&mut Self>, init: impl PinInit<T, E>) -> Result<Pin<&mut T>, E> {
170
63
        // SAFETY: We never move out of `this`.
171
63
        let this = unsafe { Pin::into_inner_unchecked(self) };
172
63
        // The value is currently initialized, so it needs to be dropped before we can reuse
173
63
        // the memory (this is a safety guarantee of `Pin`).
174
63
        if this.is_init {
175
0
            this.is_init = false;
176
0
            // SAFETY: `this.is_init` was true and therefore `this.value` is initialized.
177
0
            unsafe { this.value.assume_init_drop() };
178
63
        }
179
        // SAFETY: The memory slot is valid and this type ensures that it will stay pinned.
180
63
        unsafe { init.__pinned_init(this.value.as_mut_ptr())
?0
};
181
        // INVARIANT: `this.value` is initialized above.
182
63
        this.is_init = true;
183
63
        // SAFETY: The slot is now pinned, since we will never give access to `&mut T`.
184
63
        Ok(unsafe { Pin::new_unchecked(this.value.assume_init_mut()) })
185
63
    }
<pinned_init::__internal::StackInit<ring_buf::RingBuffer<u8, 64usize>>>::init::<core::convert::Infallible, pinned_init::__internal::InitClosure<<ring_buf::RingBuffer<u8, 64usize>>::new::{closure#1}, ring_buf::RingBuffer<u8, 64usize>, core::convert::Infallible>>
Line
Count
Source
169
1
    pub fn init<E>(self: Pin<&mut Self>, init: impl PinInit<T, E>) -> Result<Pin<&mut T>, E> {
170
1
        // SAFETY: We never move out of `this`.
171
1
        let this = unsafe { Pin::into_inner_unchecked(self) };
172
1
        // The value is currently initialized, so it needs to be dropped before we can reuse
173
1
        // the memory (this is a safety guarantee of `Pin`).
174
1
        if this.is_init {
175
0
            this.is_init = false;
176
0
            // SAFETY: `this.is_init` was true and therefore `this.value` is initialized.
177
0
            unsafe { this.value.assume_init_drop() };
178
1
        }
179
        // SAFETY: The memory slot is valid and this type ensures that it will stay pinned.
180
1
        unsafe { init.__pinned_init(this.value.as_mut_ptr())
?0
};
181
        // INVARIANT: `this.value` is initialized above.
182
1
        this.is_init = true;
183
1
        // SAFETY: The slot is now pinned, since we will never give access to `&mut T`.
184
1
        Ok(unsafe { Pin::new_unchecked(this.value.assume_init_mut()) })
185
1
    }
<pinned_init::__internal::StackInit<ring_buf::EvenU64>>::init::<(), pinned_init::__internal::InitClosure<<ring_buf::EvenU64>::new::{closure#1}, ring_buf::EvenU64, ()>>
Line
Count
Source
169
2
    pub fn init<E>(self: Pin<&mut Self>, init: impl PinInit<T, E>) -> Result<Pin<&mut T>, E> {
170
2
        // SAFETY: We never move out of `this`.
171
2
        let this = unsafe { Pin::into_inner_unchecked(self) };
172
2
        // The value is currently initialized, so it needs to be dropped before we can reuse
173
2
        // the memory (this is a safety guarantee of `Pin`).
174
2
        if this.is_init {
175
0
            this.is_init = false;
176
0
            // SAFETY: `this.is_init` was true and therefore `this.value` is initialized.
177
0
            unsafe { this.value.assume_init_drop() };
178
2
        }
179
        // SAFETY: The memory slot is valid and this type ensures that it will stay pinned.
180
2
        unsafe { init.__pinned_init(this.value.as_mut_ptr())
?1
};
181
        // INVARIANT: `this.value` is initialized above.
182
1
        this.is_init = true;
183
1
        // SAFETY: The slot is now pinned, since we will never give access to `&mut T`.
184
1
        Ok(unsafe { Pin::new_unchecked(this.value.assume_init_mut()) })
185
2
    }
<pinned_init::__internal::StackInit<ring_buf::mutex::WaitEntry>>::init::<core::convert::Infallible, pinned_init::__internal::InitClosure<<ring_buf::mutex::WaitEntry>::insert_new::{closure#1}, ring_buf::mutex::WaitEntry, core::convert::Infallible>>
Line
Count
Source
169
14.4k
    pub fn init<E>(self: Pin<&mut Self>, init: impl PinInit<T, E>) -> Result<Pin<&mut T>, E> {
170
14.4k
        // SAFETY: We never move out of `this`.
171
14.4k
        let this = unsafe { Pin::into_inner_unchecked(self) };
172
14.4k
        // The value is currently initialized, so it needs to be dropped before we can reuse
173
14.4k
        // the memory (this is a safety guarantee of `Pin`).
174
14.4k
        if this.is_init {
175
0
            this.is_init = false;
176
0
            // SAFETY: `this.is_init` was true and therefore `this.value` is initialized.
177
0
            unsafe { this.value.assume_init_drop() };
178
14.4k
        }
179
        // SAFETY: The memory slot is valid and this type ensures that it will stay pinned.
180
14.4k
        unsafe { init.__pinned_init(this.value.as_mut_ptr())
?0
};
181
        // INVARIANT: `this.value` is initialized above.
182
14.4k
        this.is_init = true;
183
14.4k
        // SAFETY: The slot is now pinned, since we will never give access to `&mut T`.
184
14.4k
        Ok(unsafe { Pin::new_unchecked(this.value.assume_init_mut()) })
185
14.4k
    }
<pinned_init::__internal::StackInit<ring_buf::mutex::linked_list::ListHead>>::init::<core::convert::Infallible, pinned_init::__internal::InitClosure<<ring_buf::mutex::linked_list::ListHead>::insert_next::{closure#1}, ring_buf::mutex::linked_list::ListHead, core::convert::Infallible>>
Line
Count
Source
169
3
    pub fn init<E>(self: Pin<&mut Self>, init: impl PinInit<T, E>) -> Result<Pin<&mut T>, E> {
170
3
        // SAFETY: We never move out of `this`.
171
3
        let this = unsafe { Pin::into_inner_unchecked(self) };
172
3
        // The value is currently initialized, so it needs to be dropped before we can reuse
173
3
        // the memory (this is a safety guarantee of `Pin`).
174
3
        if this.is_init {
175
0
            this.is_init = false;
176
0
            // SAFETY: `this.is_init` was true and therefore `this.value` is initialized.
177
0
            unsafe { this.value.assume_init_drop() };
178
3
        }
179
        // SAFETY: The memory slot is valid and this type ensures that it will stay pinned.
180
3
        unsafe { init.__pinned_init(this.value.as_mut_ptr())
?0
};
181
        // INVARIANT: `this.value` is initialized above.
182
3
        this.is_init = true;
183
3
        // SAFETY: The slot is now pinned, since we will never give access to `&mut T`.
184
3
        Ok(unsafe { Pin::new_unchecked(this.value.assume_init_mut()) })
185
3
    }
<pinned_init::__internal::StackInit<linked_list::ListHead>>::init::<core::convert::Infallible, pinned_init::__internal::InitClosure<<linked_list::ListHead>::insert_next::{closure#1}, linked_list::ListHead, core::convert::Infallible>>
Line
Count
Source
169
3
    pub fn init<E>(self: Pin<&mut Self>, init: impl PinInit<T, E>) -> Result<Pin<&mut T>, E> {
170
3
        // SAFETY: We never move out of `this`.
171
3
        let this = unsafe { Pin::into_inner_unchecked(self) };
172
3
        // The value is currently initialized, so it needs to be dropped before we can reuse
173
3
        // the memory (this is a safety guarantee of `Pin`).
174
3
        if this.is_init {
175
0
            this.is_init = false;
176
0
            // SAFETY: `this.is_init` was true and therefore `this.value` is initialized.
177
0
            unsafe { this.value.assume_init_drop() };
178
3
        }
179
        // SAFETY: The memory slot is valid and this type ensures that it will stay pinned.
180
3
        unsafe { init.__pinned_init(this.value.as_mut_ptr())
?0
};
181
        // INVARIANT: `this.value` is initialized above.
182
3
        this.is_init = true;
183
3
        // SAFETY: The slot is now pinned, since we will never give access to `&mut T`.
184
3
        Ok(unsafe { Pin::new_unchecked(this.value.assume_init_mut()) })
185
3
    }
<pinned_init::__internal::StackInit<mutex::linked_list::ListHead>>::init::<core::convert::Infallible, pinned_init::__internal::InitClosure<<mutex::linked_list::ListHead>::insert_next::{closure#1}, mutex::linked_list::ListHead, core::convert::Infallible>>
Line
Count
Source
169
3
    pub fn init<E>(self: Pin<&mut Self>, init: impl PinInit<T, E>) -> Result<Pin<&mut T>, E> {
170
3
        // SAFETY: We never move out of `this`.
171
3
        let this = unsafe { Pin::into_inner_unchecked(self) };
172
3
        // The value is currently initialized, so it needs to be dropped before we can reuse
173
3
        // the memory (this is a safety guarantee of `Pin`).
174
3
        if this.is_init {
175
0
            this.is_init = false;
176
0
            // SAFETY: `this.is_init` was true and therefore `this.value` is initialized.
177
0
            unsafe { this.value.assume_init_drop() };
178
3
        }
179
        // SAFETY: The memory slot is valid and this type ensures that it will stay pinned.
180
3
        unsafe { init.__pinned_init(this.value.as_mut_ptr())
?0
};
181
        // INVARIANT: `this.value` is initialized above.
182
3
        this.is_init = true;
183
3
        // SAFETY: The slot is now pinned, since we will never give access to `&mut T`.
184
3
        Ok(unsafe { Pin::new_unchecked(this.value.assume_init_mut()) })
185
3
    }
<pinned_init::__internal::StackInit<mutex::WaitEntry>>::init::<core::convert::Infallible, pinned_init::__internal::InitClosure<<mutex::WaitEntry>::insert_new::{closure#1}, mutex::WaitEntry, core::convert::Infallible>>
Line
Count
Source
169
10.1k
    pub fn init<E>(self: Pin<&mut Self>, init: impl PinInit<T, E>) -> Result<Pin<&mut T>, E> {
170
10.1k
        // SAFETY: We never move out of `this`.
171
10.1k
        let this = unsafe { Pin::into_inner_unchecked(self) };
172
10.1k
        // The value is currently initialized, so it needs to be dropped before we can reuse
173
10.1k
        // the memory (this is a safety guarantee of `Pin`).
174
10.1k
        if this.is_init {
175
0
            this.is_init = false;
176
0
            // SAFETY: `this.is_init` was true and therefore `this.value` is initialized.
177
0
            unsafe { this.value.assume_init_drop() };
178
10.1k
        }
179
        // SAFETY: The memory slot is valid and this type ensures that it will stay pinned.
180
10.1k
        unsafe { init.__pinned_init(this.value.as_mut_ptr())
?0
};
181
        // INVARIANT: `this.value` is initialized above.
182
10.1k
        this.is_init = true;
183
10.1k
        // SAFETY: The slot is now pinned, since we will never give access to `&mut T`.
184
10.1k
        Ok(unsafe { Pin::new_unchecked(this.value.assume_init_mut()) })
185
10.1k
    }
<pinned_init::__internal::StackInit<static_init::mutex::WaitEntry>>::init::<core::convert::Infallible, pinned_init::__internal::InitClosure<<static_init::mutex::WaitEntry>::insert_new::{closure#1}, static_init::mutex::WaitEntry, core::convert::Infallible>>
Line
Count
Source
169
12.6k
    pub fn init<E>(self: Pin<&mut Self>, init: impl PinInit<T, E>) -> Result<Pin<&mut T>, E> {
170
12.6k
        // SAFETY: We never move out of `this`.
171
12.6k
        let this = unsafe { Pin::into_inner_unchecked(self) };
172
12.6k
        // The value is currently initialized, so it needs to be dropped before we can reuse
173
12.6k
        // the memory (this is a safety guarantee of `Pin`).
174
12.6k
        if this.is_init {
175
0
            this.is_init = false;
176
0
            // SAFETY: `this.is_init` was true and therefore `this.value` is initialized.
177
0
            unsafe { this.value.assume_init_drop() };
178
12.6k
        }
179
        // SAFETY: The memory slot is valid and this type ensures that it will stay pinned.
180
12.6k
        unsafe { init.__pinned_init(this.value.as_mut_ptr())
?0
};
181
        // INVARIANT: `this.value` is initialized above.
182
12.6k
        this.is_init = true;
183
12.6k
        // SAFETY: The slot is now pinned, since we will never give access to `&mut T`.
184
12.6k
        Ok(unsafe { Pin::new_unchecked(this.value.assume_init_mut()) })
185
12.6k
    }
<pinned_init::__internal::StackInit<static_init::mutex::linked_list::ListHead>>::init::<core::convert::Infallible, pinned_init::__internal::InitClosure<<static_init::mutex::linked_list::ListHead>::insert_next::{closure#1}, static_init::mutex::linked_list::ListHead, core::convert::Infallible>>
Line
Count
Source
169
3
    pub fn init<E>(self: Pin<&mut Self>, init: impl PinInit<T, E>) -> Result<Pin<&mut T>, E> {
170
3
        // SAFETY: We never move out of `this`.
171
3
        let this = unsafe { Pin::into_inner_unchecked(self) };
172
3
        // The value is currently initialized, so it needs to be dropped before we can reuse
173
3
        // the memory (this is a safety guarantee of `Pin`).
174
3
        if this.is_init {
175
0
            this.is_init = false;
176
0
            // SAFETY: `this.is_init` was true and therefore `this.value` is initialized.
177
0
            unsafe { this.value.assume_init_drop() };
178
3
        }
179
        // SAFETY: The memory slot is valid and this type ensures that it will stay pinned.
180
3
        unsafe { init.__pinned_init(this.value.as_mut_ptr())
?0
};
181
        // INVARIANT: `this.value` is initialized above.
182
3
        this.is_init = true;
183
3
        // SAFETY: The slot is now pinned, since we will never give access to `&mut T`.
184
3
        Ok(unsafe { Pin::new_unchecked(this.value.assume_init_mut()) })
185
3
    }
186
}
187
188
1
#[test]
189
1
fn stack_init_reuse() {
190
1
    use core::pin::pin;
191
2
    #[derive(Debug)]
192
1
    struct Foo {
193
1
        a: usize,
194
1
        b: String,
195
1
    }
196
1
    let mut slot: Pin<&mut StackInit<Foo>> = pin!(StackInit::uninit());
197
1
    let value: Result<Pin<&mut Foo>, core::convert::Infallible> =
198
2
        slot.as_mut().init(crate::init!(Foo {
pinned_init::__internal::stack_init_reuse::{closure#1}
Line
Count
Source
198
1
        slot.as_mut().init(crate::init!(Foo {
pinned_init::__internal::stack_init_reuse::{closure#0}
Line
Count
Source
198
1
        slot.as_mut().init(crate::init!(Foo {
199
1
            a: 42,
200
1
            b: "Hello".to_owned(),
201
1
        }));
Unexecuted instantiation: pinned_init::__internal::stack_init_reuse::{closure#0}::{closure#0}
pinned_init::__internal::stack_init_reuse::{closure#1}::{closure#0}
Line
Count
Source
198
1
        slot.as_mut().init(crate::init!(Foo {
199
1
            a: 42,
200
1
            b: "Hello".to_owned(),
201
1
        }));
202
1
    let value = value.unwrap();
203
1
    println!("{value:?}");
204
1
    let value: Result<Pin<&mut Foo>, core::convert::Infallible> =
205
2
        slot.as_mut().init(crate::init!(Foo {
pinned_init::__internal::stack_init_reuse::{closure#3}
Line
Count
Source
205
1
        slot.as_mut().init(crate::init!(Foo {
pinned_init::__internal::stack_init_reuse::{closure#2}
Line
Count
Source
205
1
        slot.as_mut().init(crate::init!(Foo {
206
1
            a: 24,
207
1
            b: "world!".to_owned(),
208
1
        }));
pinned_init::__internal::stack_init_reuse::{closure#3}::{closure#0}
Line
Count
Source
205
1
        slot.as_mut().init(crate::init!(Foo {
206
1
            a: 24,
207
1
            b: "world!".to_owned(),
208
1
        }));
Unexecuted instantiation: pinned_init::__internal::stack_init_reuse::{closure#2}::{closure#0}
209
1
    let value = value.unwrap();
210
1
    println!("{value:?}");
211
1
}
212
213
/// When a value of this type is dropped, it drops a `T`.
214
///
215
/// Can be forgotton to prevent the drop.
216
pub struct DropGuard<T: ?Sized> {
217
    ptr: *mut T,
218
}
219
220
impl<T: ?Sized> DropGuard<T> {
221
    /// Creates a new [`DropGuard<T>`]. It will [`ptr::drop_in_place`] `ptr` when it gets dropped.
222
    ///
223
    /// # Safety
224
    ///
225
    /// `ptr` must be a valid pointer.
226
    ///
227
    /// It is the callers responsibility that `self` will only get dropped if the pointee of `ptr`:
228
    /// - has not been dropped,
229
    /// - is not accessible by any other means,
230
    /// - will not be dropped by any other means.
231
    #[inline]
232
234k
    pub unsafe fn new(ptr: *mut T) -> Self {
233
234k
        Self { ptr }
234
234k
    }
<pinned_init::__internal::DropGuard<alloc_fail::ring_buf::mutex::linked_list::ListHead>>::new
Line
Count
Source
232
9.60k
    pub unsafe fn new(ptr: *mut T) -> Self {
233
9.60k
        Self { ptr }
234
9.60k
    }
<pinned_init::__internal::DropGuard<*mut alloc_fail::ring_buf::EvenU64>>::new
Line
Count
Source
232
2
    pub unsafe fn new(ptr: *mut T) -> Self {
233
2
        Self { ptr }
234
2
    }
<pinned_init::__internal::DropGuard<alloc::string::String>>::new
Line
Count
Source
232
11
    pub unsafe fn new(ptr: *mut T) -> Self {
233
11
        Self { ptr }
234
11
    }
<pinned_init::__internal::DropGuard<alloc_fail::ring_buf::mutex::SpinLock>>::new
Line
Count
Source
232
2
    pub unsafe fn new(ptr: *mut T) -> Self {
233
2
        Self { ptr }
234
2
    }
<pinned_init::__internal::DropGuard<u64>>::new
Line
Count
Source
232
4
    pub unsafe fn new(ptr: *mut T) -> Self {
233
4
        Self { ptr }
234
4
    }
<pinned_init::__internal::DropGuard<core::cell::UnsafeCell<usize>>>::new
Line
Count
Source
232
1
    pub unsafe fn new(ptr: *mut T) -> Self {
233
1
        Self { ptr }
234
1
    }
<pinned_init::__internal::DropGuard<alloc_fail::ring_buf::mutex::linked_list::Link>>::new
Line
Count
Source
232
19.2k
    pub unsafe fn new(ptr: *mut T) -> Self {
233
19.2k
        Self { ptr }
234
19.2k
    }
<pinned_init::__internal::DropGuard<core::marker::PhantomPinned>>::new
Line
Count
Source
232
9.61k
    pub unsafe fn new(ptr: *mut T) -> Self {
233
9.61k
        Self { ptr }
234
9.61k
    }
Unexecuted instantiation: <pinned_init::__internal::DropGuard<[core::mem::maybe_uninit::MaybeUninit<u8>; 1099511627776usize]>>::new
<pinned_init::__internal::DropGuard<[core::mem::maybe_uninit::MaybeUninit<alloc_fail::ring_buf::BigStruct>; 64usize]>>::new
Line
Count
Source
232
1
    pub unsafe fn new(ptr: *mut T) -> Self {
233
1
        Self { ptr }
234
1
    }
<pinned_init::__internal::DropGuard<[u8; 1048576usize]>>::new
Line
Count
Source
232
65
    pub unsafe fn new(ptr: *mut T) -> Self {
233
65
        Self { ptr }
234
65
    }
<pinned_init::__internal::DropGuard<[core::mem::maybe_uninit::MaybeUninit<alloc_fail::ring_buf::EvenU64>; 4usize]>>::new
Line
Count
Source
232
1
    pub unsafe fn new(ptr: *mut T) -> Self {
233
1
        Self { ptr }
234
1
    }
<pinned_init::__internal::DropGuard<core::mem::maybe_uninit::MaybeUninit<u8>>>::new
Line
Count
Source
232
65
    pub unsafe fn new(ptr: *mut T) -> Self {
233
65
        Self { ptr }
234
65
    }
<pinned_init::__internal::DropGuard<std::thread::Thread>>::new
Line
Count
Source
232
9.60k
    pub unsafe fn new(ptr: *mut T) -> Self {
233
9.60k
        Self { ptr }
234
9.60k
    }
<pinned_init::__internal::DropGuard<[core::mem::maybe_uninit::MaybeUninit<u8>; 64usize]>>::new
Line
Count
Source
232
1
    pub unsafe fn new(ptr: *mut T) -> Self {
233
1
        Self { ptr }
234
1
    }
<pinned_init::__internal::DropGuard<core::cell::UnsafeCell<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>>>::new
Line
Count
Source
232
1
    pub unsafe fn new(ptr: *mut T) -> Self {
233
1
        Self { ptr }
234
1
    }
<pinned_init::__internal::DropGuard<*mut alloc_fail::ring_buf::BigStruct>>::new
Line
Count
Source
232
2
    pub unsafe fn new(ptr: *mut T) -> Self {
233
2
        Self { ptr }
234
2
    }
<pinned_init::__internal::DropGuard<*mut u8>>::new
Line
Count
Source
232
2
    pub unsafe fn new(ptr: *mut T) -> Self {
233
2
        Self { ptr }
234
2
    }
<pinned_init::__internal::DropGuard<core::cell::Cell<bool>>>::new
Line
Count
Source
232
2
    pub unsafe fn new(ptr: *mut T) -> Self {
233
2
        Self { ptr }
234
2
    }
Unexecuted instantiation: <pinned_init::__internal::DropGuard<_>>::new
<pinned_init::__internal::DropGuard<usize>>::new
Line
Count
Source
232
2
    pub unsafe fn new(ptr: *mut T) -> Self {
233
2
        Self { ptr }
234
2
    }
<pinned_init::__internal::DropGuard<alloc::string::String>>::new
Line
Count
Source
232
2
    pub unsafe fn new(ptr: *mut T) -> Self {
233
2
        Self { ptr }
234
2
    }
<pinned_init::__internal::DropGuard<core::mem::maybe_uninit::MaybeUninit<u8>>>::new
Line
Count
Source
232
65
    pub unsafe fn new(ptr: *mut T) -> Self {
233
65
        Self { ptr }
234
65
    }
<pinned_init::__internal::DropGuard<[core::mem::maybe_uninit::MaybeUninit<u8>; 64usize]>>::new
Line
Count
Source
232
1
    pub unsafe fn new(ptr: *mut T) -> Self {
233
1
        Self { ptr }
234
1
    }
<pinned_init::__internal::DropGuard<core::cell::UnsafeCell<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>>>::new
Line
Count
Source
232
1
    pub unsafe fn new(ptr: *mut T) -> Self {
233
1
        Self { ptr }
234
1
    }
<pinned_init::__internal::DropGuard<ring_buf::mutex::linked_list::ListHead>>::new
Line
Count
Source
232
14.4k
    pub unsafe fn new(ptr: *mut T) -> Self {
233
14.4k
        Self { ptr }
234
14.4k
    }
<pinned_init::__internal::DropGuard<*mut u8>>::new
Line
Count
Source
232
2
    pub unsafe fn new(ptr: *mut T) -> Self {
233
2
        Self { ptr }
234
2
    }
<pinned_init::__internal::DropGuard<ring_buf::mutex::SpinLock>>::new
Line
Count
Source
232
2
    pub unsafe fn new(ptr: *mut T) -> Self {
233
2
        Self { ptr }
234
2
    }
<pinned_init::__internal::DropGuard<[core::mem::maybe_uninit::MaybeUninit<ring_buf::EvenU64>; 4usize]>>::new
Line
Count
Source
232
1
    pub unsafe fn new(ptr: *mut T) -> Self {
233
1
        Self { ptr }
234
1
    }
<pinned_init::__internal::DropGuard<alloc::string::String>>::new
Line
Count
Source
232
11
    pub unsafe fn new(ptr: *mut T) -> Self {
233
11
        Self { ptr }
234
11
    }
<pinned_init::__internal::DropGuard<core::cell::UnsafeCell<usize>>>::new
Line
Count
Source
232
1
    pub unsafe fn new(ptr: *mut T) -> Self {
233
1
        Self { ptr }
234
1
    }
<pinned_init::__internal::DropGuard<ring_buf::mutex::linked_list::Link>>::new
Line
Count
Source
232
28.9k
    pub unsafe fn new(ptr: *mut T) -> Self {
233
28.9k
        Self { ptr }
234
28.9k
    }
<pinned_init::__internal::DropGuard<core::cell::Cell<bool>>>::new
Line
Count
Source
232
2
    pub unsafe fn new(ptr: *mut T) -> Self {
233
2
        Self { ptr }
234
2
    }
<pinned_init::__internal::DropGuard<u64>>::new
Line
Count
Source
232
4
    pub unsafe fn new(ptr: *mut T) -> Self {
233
4
        Self { ptr }
234
4
    }
<pinned_init::__internal::DropGuard<std::thread::Thread>>::new
Line
Count
Source
232
14.4k
    pub unsafe fn new(ptr: *mut T) -> Self {
233
14.4k
        Self { ptr }
234
14.4k
    }
<pinned_init::__internal::DropGuard<core::marker::PhantomPinned>>::new
Line
Count
Source
232
14.4k
    pub unsafe fn new(ptr: *mut T) -> Self {
233
14.4k
        Self { ptr }
234
14.4k
    }
<pinned_init::__internal::DropGuard<[core::mem::maybe_uninit::MaybeUninit<ring_buf::BigStruct>; 64usize]>>::new
Line
Count
Source
232
1
    pub unsafe fn new(ptr: *mut T) -> Self {
233
1
        Self { ptr }
234
1
    }
<pinned_init::__internal::DropGuard<*mut ring_buf::EvenU64>>::new
Line
Count
Source
232
2
    pub unsafe fn new(ptr: *mut T) -> Self {
233
2
        Self { ptr }
234
2
    }
<pinned_init::__internal::DropGuard<*mut ring_buf::BigStruct>>::new
Line
Count
Source
232
2
    pub unsafe fn new(ptr: *mut T) -> Self {
233
2
        Self { ptr }
234
2
    }
<pinned_init::__internal::DropGuard<[u8; 1048576usize]>>::new
Line
Count
Source
232
65
    pub unsafe fn new(ptr: *mut T) -> Self {
233
65
        Self { ptr }
234
65
    }
<pinned_init::__internal::DropGuard<core::marker::PhantomPinned>>::new
Line
Count
Source
232
5
    pub unsafe fn new(ptr: *mut T) -> Self {
233
5
        Self { ptr }
234
5
    }
<pinned_init::__internal::DropGuard<linked_list::Link>>::new
Line
Count
Source
232
10
    pub unsafe fn new(ptr: *mut T) -> Self {
233
10
        Self { ptr }
234
10
    }
<pinned_init::__internal::DropGuard<mutex::linked_list::ListHead>>::new
Line
Count
Source
232
10.1k
    pub unsafe fn new(ptr: *mut T) -> Self {
233
10.1k
        Self { ptr }
234
10.1k
    }
<pinned_init::__internal::DropGuard<mutex::linked_list::Link>>::new
Line
Count
Source
232
20.2k
    pub unsafe fn new(ptr: *mut T) -> Self {
233
20.2k
        Self { ptr }
234
20.2k
    }
<pinned_init::__internal::DropGuard<core::cell::UnsafeCell<usize>>>::new
Line
Count
Source
232
1
    pub unsafe fn new(ptr: *mut T) -> Self {
233
1
        Self { ptr }
234
1
    }
<pinned_init::__internal::DropGuard<mutex::SpinLock>>::new
Line
Count
Source
232
1
    pub unsafe fn new(ptr: *mut T) -> Self {
233
1
        Self { ptr }
234
1
    }
<pinned_init::__internal::DropGuard<std::thread::Thread>>::new
Line
Count
Source
232
10.1k
    pub unsafe fn new(ptr: *mut T) -> Self {
233
10.1k
        Self { ptr }
234
10.1k
    }
<pinned_init::__internal::DropGuard<core::cell::Cell<bool>>>::new
Line
Count
Source
232
1
    pub unsafe fn new(ptr: *mut T) -> Self {
233
1
        Self { ptr }
234
1
    }
<pinned_init::__internal::DropGuard<core::marker::PhantomPinned>>::new
Line
Count
Source
232
10.1k
    pub unsafe fn new(ptr: *mut T) -> Self {
233
10.1k
        Self { ptr }
234
10.1k
    }
<pinned_init::__internal::DropGuard<core::cell::UnsafeCell<libc::unix::linux_like::linux::pthread_mutex_t>>>::new
Line
Count
Source
232
1
    pub unsafe fn new(ptr: *mut T) -> Self {
233
1
        Self { ptr }
234
1
    }
<pinned_init::__internal::DropGuard<core::cell::UnsafeCell<usize>>>::new
Line
Count
Source
232
1
    pub unsafe fn new(ptr: *mut T) -> Self {
233
1
        Self { ptr }
234
1
    }
<pinned_init::__internal::DropGuard<core::marker::PhantomPinned>>::new
Line
Count
Source
232
1
    pub unsafe fn new(ptr: *mut T) -> Self {
233
1
        Self { ptr }
234
1
    }
<pinned_init::__internal::DropGuard<core::cell::Cell<bool>>>::new
Line
Count
Source
232
1
    pub unsafe fn new(ptr: *mut T) -> Self {
233
1
        Self { ptr }
234
1
    }
<pinned_init::__internal::DropGuard<static_init::mutex::SpinLock>>::new
Line
Count
Source
232
1
    pub unsafe fn new(ptr: *mut T) -> Self {
233
1
        Self { ptr }
234
1
    }
<pinned_init::__internal::DropGuard<static_init::mutex::linked_list::Link>>::new
Line
Count
Source
232
25.2k
    pub unsafe fn new(ptr: *mut T) -> Self {
233
25.2k
        Self { ptr }
234
25.2k
    }
<pinned_init::__internal::DropGuard<std::thread::Thread>>::new
Line
Count
Source
232
12.6k
    pub unsafe fn new(ptr: *mut T) -> Self {
233
12.6k
        Self { ptr }
234
12.6k
    }
<pinned_init::__internal::DropGuard<core::marker::PhantomPinned>>::new
Line
Count
Source
232
12.6k
    pub unsafe fn new(ptr: *mut T) -> Self {
233
12.6k
        Self { ptr }
234
12.6k
    }
<pinned_init::__internal::DropGuard<core::cell::UnsafeCell<usize>>>::new
Line
Count
Source
232
1
    pub unsafe fn new(ptr: *mut T) -> Self {
233
1
        Self { ptr }
234
1
    }
<pinned_init::__internal::DropGuard<static_init::mutex::linked_list::ListHead>>::new
Line
Count
Source
232
12.6k
    pub unsafe fn new(ptr: *mut T) -> Self {
233
12.6k
        Self { ptr }
234
12.6k
    }
235
}
236
237
impl<T: ?Sized> Drop for DropGuard<T> {
238
    #[inline]
239
14
    fn drop(&mut self) {
240
14
        // SAFETY: A `DropGuard` can only be constructed using the unsafe `new` function
241
14
        // ensuring that this operation is safe.
242
14
        unsafe { ptr::drop_in_place(self.ptr) }
243
14
    }
Unexecuted instantiation: <pinned_init::__internal::DropGuard<alloc_fail::ring_buf::mutex::linked_list::Link> as core::ops::drop::Drop>::drop
<pinned_init::__internal::DropGuard<alloc::string::String> as core::ops::drop::Drop>::drop
Line
Count
Source
239
7
    fn drop(&mut self) {
240
7
        // SAFETY: A `DropGuard` can only be constructed using the unsafe `new` function
241
7
        // ensuring that this operation is safe.
242
7
        unsafe { ptr::drop_in_place(self.ptr) }
243
7
    }
Unexecuted instantiation: <pinned_init::__internal::DropGuard<alloc_fail::ring_buf::mutex::SpinLock> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <pinned_init::__internal::DropGuard<alloc_fail::ring_buf::mutex::linked_list::ListHead> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <pinned_init::__internal::DropGuard<*mut alloc_fail::ring_buf::EvenU64> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <pinned_init::__internal::DropGuard<core::cell::Cell<bool>> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <pinned_init::__internal::DropGuard<[core::mem::maybe_uninit::MaybeUninit<u8>; 64usize]> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <pinned_init::__internal::DropGuard<*mut alloc_fail::ring_buf::BigStruct> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <pinned_init::__internal::DropGuard<*mut u8> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <pinned_init::__internal::DropGuard<std::thread::Thread> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <pinned_init::__internal::DropGuard<[core::mem::maybe_uninit::MaybeUninit<alloc_fail::ring_buf::EvenU64>; 4usize]> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <pinned_init::__internal::DropGuard<[u8; 1048576usize]> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <pinned_init::__internal::DropGuard<[core::mem::maybe_uninit::MaybeUninit<alloc_fail::ring_buf::BigStruct>; 64usize]> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <pinned_init::__internal::DropGuard<[core::mem::maybe_uninit::MaybeUninit<u8>; 1099511627776usize]> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <pinned_init::__internal::DropGuard<_> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <pinned_init::__internal::DropGuard<usize> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <pinned_init::__internal::DropGuard<[core::mem::maybe_uninit::MaybeUninit<u8>; 64usize]> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <pinned_init::__internal::DropGuard<ring_buf::mutex::linked_list::ListHead> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <pinned_init::__internal::DropGuard<*mut u8> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <pinned_init::__internal::DropGuard<[u8; 1048576usize]> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <pinned_init::__internal::DropGuard<[core::mem::maybe_uninit::MaybeUninit<ring_buf::BigStruct>; 64usize]> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <pinned_init::__internal::DropGuard<*mut ring_buf::EvenU64> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <pinned_init::__internal::DropGuard<std::thread::Thread> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <pinned_init::__internal::DropGuard<*mut ring_buf::BigStruct> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <pinned_init::__internal::DropGuard<core::cell::Cell<bool>> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <pinned_init::__internal::DropGuard<ring_buf::mutex::linked_list::Link> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <pinned_init::__internal::DropGuard<[core::mem::maybe_uninit::MaybeUninit<ring_buf::EvenU64>; 4usize]> as core::ops::drop::Drop>::drop
<pinned_init::__internal::DropGuard<alloc::string::String> as core::ops::drop::Drop>::drop
Line
Count
Source
239
7
    fn drop(&mut self) {
240
7
        // SAFETY: A `DropGuard` can only be constructed using the unsafe `new` function
241
7
        // ensuring that this operation is safe.
242
7
        unsafe { ptr::drop_in_place(self.ptr) }
243
7
    }
Unexecuted instantiation: <pinned_init::__internal::DropGuard<ring_buf::mutex::SpinLock> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <pinned_init::__internal::DropGuard<linked_list::Link> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <pinned_init::__internal::DropGuard<mutex::linked_list::Link> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <pinned_init::__internal::DropGuard<mutex::linked_list::ListHead> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <pinned_init::__internal::DropGuard<core::cell::Cell<bool>> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <pinned_init::__internal::DropGuard<std::thread::Thread> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <pinned_init::__internal::DropGuard<mutex::SpinLock> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <pinned_init::__internal::DropGuard<core::cell::UnsafeCell<libc::unix::linux_like::linux::pthread_mutex_t>> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <pinned_init::__internal::DropGuard<core::cell::UnsafeCell<usize>> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <pinned_init::__internal::DropGuard<std::thread::Thread> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <pinned_init::__internal::DropGuard<core::cell::Cell<bool>> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <pinned_init::__internal::DropGuard<static_init::mutex::SpinLock> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <pinned_init::__internal::DropGuard<static_init::mutex::linked_list::Link> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <pinned_init::__internal::DropGuard<static_init::mutex::linked_list::ListHead> as core::ops::drop::Drop>::drop
244
}
245
246
/// Token used by `PinnedDrop` to prevent calling the function without creating this unsafely
247
/// created struct. This is needed, because the `drop` function is safe, but should not be called
248
/// manually.
249
pub struct OnlyCallFromDrop(());
250
251
impl OnlyCallFromDrop {
252
    /// # Safety
253
    ///
254
    /// This function should only be called from the [`Drop::drop`] function and only be used to
255
    /// delegate the destruction to the pinned destructor [`PinnedDrop::drop`] of the same type.
256
46.8k
    pub unsafe fn new() -> Self {
257
46.8k
        Self(())
258
46.8k
    }
<pinned_init::__internal::OnlyCallFromDrop>::new
Line
Count
Source
256
46.8k
    pub unsafe fn new() -> Self {
257
46.8k
        Self(())
258
46.8k
    }
Unexecuted instantiation: <pinned_init::__internal::OnlyCallFromDrop>::new
259
}
\ No newline at end of file diff --git a/coverage/9762db8666aae4a71263fb3c4affdaf962cf87f6/coverage/home/runner/work/pinned-init/pinned-init/src/lib.rs.html b/coverage/9762db8666aae4a71263fb3c4affdaf962cf87f6/coverage/home/runner/work/pinned-init/pinned-init/src/lib.rs.html new file mode 100644 index 0000000..6fba133 --- /dev/null +++ b/coverage/9762db8666aae4a71263fb3c4affdaf962cf87f6/coverage/home/runner/work/pinned-init/pinned-init/src/lib.rs.html @@ -0,0 +1 @@ +

Coverage Report

Created: 2023-07-24 21:40

/home/runner/work/pinned-init/pinned-init/src/lib.rs
Line
Count
Source (jump to first uncovered line)
1
// SPDX-License-Identifier: Apache-2.0 OR MIT
2
3
//! Library to safely and fallibly initialize pinned `struct`s using in-place constructors.
4
//!
5
//! It also allows in-place initialization of big `struct`s that would otherwise produce a stack
6
//! overflow.
7
//!
8
//! This library's main use-case is in [Rust-for-Linux]. Although this version can be used
9
//! standalone.
10
//!
11
//! There are cases when you want to in-place initialize a struct. For example when it is very big
12
//! and moving it from the stack is not an option, because it is bigger than the stack itself.
13
//! Another reason would be that you need the address of the object to initialize it. This stands
14
//! in direct conflict with Rust's normal process of first initializing an object and then moving
15
//! it into it's final memory location.
16
//!
17
//! This library allows you to do in-place initialization safely.
18
//!
19
//! # Nightly only
20
//!
21
//! This library requires unstable features and thus can only be used with a nightly compiler.
22
//! The used features are:
23
//! - `allocator_api`
24
//! - `new_uninit` (only if the `alloc` or `std` features are enabled)
25
//! - `get_mut_unchecked` (only if the `alloc` or `std` features are enabled)
26
//!
27
//! The user will be required to activate these features:
28
//! - `allocator_api`
29
//!
30
//! # Overview
31
//!
32
//! To initialize a `struct` with an in-place constructor you will need two things:
33
//! - an in-place constructor,
34
//! - a memory location that can hold your `struct` (this can be the [stack], an [`Arc<T>`],
35
//!   [`Box<T>`] or any other smart pointer that implements [`InPlaceInit`]).
36
//!
37
//! To get an in-place constructor there are generally three options:
38
//! - directly creating an in-place constructor using the [`pin_init!`] macro,
39
//! - a custom function/macro returning an in-place constructor provided by someone else,
40
//! - using the unsafe function [`pin_init_from_closure()`] to manually create an initializer.
41
//!
42
//! Aside from pinned initialization, this library also supports in-place construction without pinning,
43
//! the macros/types/functions are generally named like the pinned variants without the `pin`
44
//! prefix.
45
//!
46
//! # Examples
47
//!
48
//! Throught some examples we will make use of the `CMutex` type which can be found in the examples
49
//! directory of the repository. It is essentially a rebuild of the `mutex` from the Linux kernel
50
//! in userland. So it also uses a wait list and a basic spinlock. Importantly it needs to be
51
//! pinned to be locked and thus is a prime candidate for this library.
52
//!
53
//! ## Using the [`pin_init!`] macro
54
//!
55
//! If you want to use [`PinInit`], then you will have to annotate your `struct` with
56
//! `#[`[`pin_data`]`]`. It is a macro that uses `#[pin]` as a marker for
57
//! [structurally pinned fields]. After doing this, you can then create an in-place constructor via
58
//! [`pin_init!`]. The syntax is almost the same as normal `struct` initializers. The difference is
59
//! that you need to write `<-` instead of `:` for fields that you want to initialize in-place.
60
//!
61
//! ```rust
62
//! # #![allow(clippy::disallowed_names, clippy::new_ret_no_self)]
63
//! # #![feature(allocator_api, no_coverage)]
64
//! use pinned_init::*;
65
//! # use core::pin::Pin;
66
//! # #[path = "../examples/mutex.rs"] mod mutex; use mutex::*;
67
//! #[pin_data]
68
//! struct Foo {
69
//!     #[pin]
70
//!     a: CMutex<usize>,
71
//!     b: u32,
72
//! }
73
//!
74
//! let foo = pin_init!(Foo {
75
//!     a <- CMutex::new(42),
76
//!     b: 24,
77
//! });
78
//! # let _ = Box::pin_init(foo);
79
//! ```
80
//!
81
//! `foo` now is of the type [`impl PinInit<Foo>`]. We can now use any smart pointer that we like
82
//! (or just the stack) to actually initialize a `Foo`:
83
//!
84
//! ```rust
85
//! # #![allow(clippy::disallowed_names, clippy::new_ret_no_self)]
86
//! # #![feature(allocator_api, no_coverage)]
87
//! # #[path = "../examples/mutex.rs"] mod mutex; use mutex::*;
88
//! # use pinned_init::*;
89
//! # use core::pin::Pin;
90
//! # #[pin_data]
91
//! # struct Foo {
92
//! #     #[pin]
93
//! #     a: CMutex<usize>,
94
//! #     b: u32,
95
//! # }
96
//! # let foo = pin_init!(Foo {
97
//! #     a <- CMutex::new(42),
98
//! #     b: 24,
99
//! # });
100
//! let foo: Result<Pin<Box<Foo>>, core::alloc::AllocError> = Box::pin_init(foo);
101
//! ```
102
//!
103
//! For more information see the [`pin_init!`] macro.
104
//!
105
//! ## Using a custom function/macro that returns an initializer
106
//!
107
//! Many types that use this library supply a function/macro that returns an initializer, because
108
//! the above method only works for types where you can access the fields.
109
//!
110
//! ```rust
111
//! # #![feature(allocator_api, no_coverage)]
112
//! # #[path = "../examples/mutex.rs"] mod mutex; use mutex::*;
113
//! # use pinned_init::*;
114
//! # use std::{alloc::AllocError, pin::Pin};
115
//! let mtx: Result<Pin<Box<CMutex<usize>>>, AllocError> = Box::pin_init(CMutex::new(42));
116
//! ```
117
//!
118
//! To declare an init macro/function you just return an [`impl PinInit<T, E>`]:
119
//!
120
//! ```rust
121
//! # #![allow(clippy::disallowed_names, clippy::new_ret_no_self)]
122
//! # #![feature(allocator_api, no_coverage)]
123
//! # use pinned_init::*;
124
//! # #[path = "../examples/mutex.rs"] mod mutex; use mutex::*;
125
//! use core::alloc::AllocError;
126
//! #[pin_data]
127
//! struct DriverData {
128
//!     #[pin]
129
//!     status: CMutex<i32>,
130
//!     buffer: Box<[u8; 1_000_000]>,
131
//! }
132
//!
133
//! struct DriverDataError;
134
//!
135
//! # impl From<core::convert::Infallible> for DriverDataError {
136
//! #     fn from(i: core::convert::Infallible) -> Self { match i {} }
137
//! # }
138
//! # impl From<AllocError> for DriverDataError {
139
//! #     fn from(_: AllocError) -> Self { Self }
140
//! # }
141
//! #
142
//! impl DriverData {
143
//!     fn new() -> impl PinInit<Self, DriverDataError> {
144
//!         try_pin_init!(Self {
145
//!             status <- CMutex::new(0),
146
//!             buffer: Box::init(zeroed())?,
147
//!         }? DriverDataError)
148
//!     }
149
//! }
150
//! # let _ = Box::pin_init(DriverData::new());
151
//! ```
152
//!
153
//! ## Manual creation of an initializer
154
//!
155
//! Often when working with primitives the previous approaches are not sufficient. That is where
156
//! [`pin_init_from_closure()`] comes in. This `unsafe` function allows you to create a
157
//! [`impl PinInit<T, E>`] directly from a closure. Of course you have to ensure that the closure
158
//! actually does the initialization in the correct way. Here are the things to look out for
159
//! (we are calling the parameter to the closure `slot`):
160
//! - when the closure returns `Ok(())`, then it has completed the initialization successfully, so
161
//!   `slot` now contains a valid bit pattern for the type `T`,
162
//! - when the closure returns `Err(e)`, then the caller may deallocate the memory at `slot`, so
163
//!   you need to take care to clean up anything if your initialization fails mid-way,
164
//! - you may assume that `slot` will stay pinned even after the closure returns until `drop` of
165
//!   `slot` gets called.
166
//!
167
//! ```rust
168
//! # #![feature(extern_types)]
169
//! # #![cfg_attr(coverage_nightly, feature(no_coverage))]
170
//! use pinned_init::*;
171
//! use core::{ptr::addr_of_mut, marker::PhantomPinned, cell::UnsafeCell, pin::Pin};
172
//! mod bindings {
173
//!     extern "C" {
174
//!         pub type foo;
175
//!         pub fn init_foo(ptr: *mut foo);
176
//!         pub fn destroy_foo(ptr: *mut foo);
177
//!         #[must_use = "you must check the error return code"]
178
//!         pub fn enable_foo(ptr: *mut foo, flags: u32) -> i32;
179
//!     }
180
//! }
181
//!
182
//! /// # Invariants
183
//! ///
184
//! /// `foo` is always initialized
185
//! #[pin_data(PinnedDrop)]
186
//! pub struct RawFoo {
187
//!     #[pin]
188
//!     _p: PhantomPinned,
189
//!     #[pin]
190
//!     foo: UnsafeCell<bindings::foo>,
191
//! }
192
//!
193
//! impl RawFoo {
194
//! #   #[cfg_attr(coverage_nightly, no_coverage)]
195
//!     pub fn new(flags: u32) -> impl PinInit<Self, i32> {
196
//!         // SAFETY:
197
//!         // - when the closure returns `Ok(())`, then it has successfully initialized and
198
//!         //   enabled `foo`,
199
//!         // - when it returns `Err(e)`, then it has cleaned up before
200
//!         unsafe {
201
//!             pin_init_from_closure(move |slot: *mut Self| {
202
//!                 // `slot` contains uninit memory, avoid creating a reference.
203
//!                 let foo = addr_of_mut!((*slot).foo);
204
//!
205
//!                 // Initialize the `foo`
206
//!                 bindings::init_foo(UnsafeCell::raw_get(foo));
207
//!
208
//!                 // Try to enable it.
209
//!                 let err = bindings::enable_foo(UnsafeCell::raw_get(foo), flags);
210
//!                 if err != 0 {
211
//!                     // Enabling has failed, first clean up the foo and then return the error.
212
//!                     bindings::destroy_foo(UnsafeCell::raw_get(foo));
213
//!                     Err(err)
214
//!                 } else {
215
//!                     // All fields of `RawFoo` have been initialized, since `_p` is a ZST.
216
//!                     Ok(())
217
//!                 }
218
//!             })
219
//!         }
220
//!     }
221
//! }
222
//!
223
//! #[pinned_drop]
224
//! impl PinnedDrop for RawFoo {
225
//! #   #[cfg_attr(coverage_nightly, no_coverage)]
226
//!     fn drop(self: Pin<&mut Self>) {
227
//!         // SAFETY: Since `foo` is initialized, destroying is safe.
228
//!         unsafe { bindings::destroy_foo(self.foo.get()) };
229
//!     }
230
//! }
231
//! ```
232
//!
233
//! For more information on how to use [`pin_init_from_closure()`], you can take a look at the
234
//! uses inside the `kernel` crate from the [Rust-for-Linux] project. The `sync` module is a good
235
//! starting point.
236
//!
237
//! [structurally pinned fields]:
238
//!     https://doc.rust-lang.org/std/pin/index.html#pinning-is-structural-for-field
239
//! [stack]: crate::stack_pin_init
240
//! [`Arc<T>`]: alloc::sync::Arc
241
//! [`Box<T>`]: alloc::boxed::Box
242
//! [`impl PinInit<Foo>`]: PinInit
243
//! [`impl PinInit<T, E>`]: PinInit
244
//! [`impl Init<T, E>`]: Init
245
//! [`pin_data`]: ::pinned_init_macro::pin_data
246
//! [Rust-for-Linux]: https://rust-for-linux.com/
247
248
#![forbid(missing_docs, unsafe_op_in_unsafe_fn)]
249
#![cfg_attr(not(feature = "std"), no_std)]
250
#![feature(allocator_api)]
251
#![cfg_attr(any(feature = "alloc"), feature(new_uninit))]
252
#![cfg_attr(any(feature = "alloc"), feature(get_mut_unchecked))]
253
#![cfg_attr(coverage_nightly, feature(no_coverage))]
254
255
#[cfg(any(feature = "alloc"))]
256
extern crate alloc;
257
258
#[cfg(any(feature = "alloc"))]
259
use alloc::{boxed::Box, sync::Arc};
260
use core::{
261
    alloc::AllocError,
262
    cell::UnsafeCell,
263
    convert::Infallible,
264
    marker::PhantomData,
265
    mem::MaybeUninit,
266
    num::*,
267
    pin::Pin,
268
    ptr::{self, NonNull},
269
};
270
271
#[doc(hidden)]
272
pub mod __internal;
273
#[doc(hidden)]
274
pub mod macros;
275
276
pub use pinned_init_macro::{pin_data, pinned_drop, Zeroable};
277
278
/// Initialize and pin a type directly on the stack.
279
///
280
/// # Examples
281
///
282
/// ```rust
283
/// # #![allow(clippy::disallowed_names, clippy::new_ret_no_self)]
284
/// # #![feature(allocator_api, no_coverage)]
285
/// # #[path = "../examples/mutex.rs"] mod mutex; use mutex::*;
286
/// # use pinned_init::*;
287
/// # use core::pin::Pin;
288
/// #[pin_data]
289
/// struct Foo {
290
///     #[pin]
291
///     a: CMutex<usize>,
292
///     b: Bar,
293
/// }
294
///
295
/// #[pin_data]
296
/// struct Bar {
297
///     x: u32,
298
/// }
299
///
300
/// stack_pin_init!(let foo = pin_init!(Foo {
301
///     a <- CMutex::new(42),
302
///     b: Bar {
303
///         x: 64,
304
///     },
305
/// }));
306
/// let foo: Pin<&mut Foo> = foo;
307
/// println!("a: {}", &*foo.a.lock());
308
/// ```
309
///
310
/// # Syntax
311
///
312
/// A normal `let` binding with optional type annotation. The expression is expected to implement
313
/// [`PinInit`]/[`Init`] with the error type [`Infallible`]. If you want to use a different error
314
/// type, then use [`stack_try_pin_init!`].
315
#[macro_export]
316
macro_rules! stack_pin_init {
317
    (let $var:ident $(: $t:ty)? = $val:expr) => {
318
        let val = $val;
319
        let mut $var = ::core::pin::pin!($crate::__internal::StackInit$(::<$t>)?::uninit());
320
        let mut $var = match $crate::__internal::StackInit::init($var, val) {
321
            Ok(res) => res,
322
            Err(x) => {
323
                let x: ::core::convert::Infallible = x;
324
                match x {}
325
            }
326
        };
327
    };
328
}
329
330
/// Initialize and pin a type directly on the stack.
331
///
332
/// # Examples
333
///
334
/// ```rust
335
/// # #![allow(clippy::disallowed_names, clippy::new_ret_no_self)]
336
/// # #![feature(allocator_api, no_coverage)]
337
/// # #[path = "../examples/mutex.rs"] mod mutex; use mutex::*;
338
/// # use pinned_init::*;
339
/// # use core::{alloc::AllocError, pin::Pin, convert::Infallible};
340
/// # #[derive(Debug)]
341
/// # struct FooError;
342
/// # impl From<AllocError> for FooError { fn from(_: AllocError) -> Self { Self } }
343
/// # impl From<Infallible> for FooError { fn from(_: Infallible) -> Self { Self } }
344
/// #[pin_data]
345
/// struct Foo {
346
///     #[pin]
347
///     a: CMutex<usize>,
348
///     b: Box<Bar>,
349
/// }
350
///
351
/// struct Bar {
352
///     x: u32,
353
/// }
354
///
355
/// stack_try_pin_init!(let foo: Foo = try_pin_init!(Foo {
356
///     a <- CMutex::new(42),
357
///     b: Box::try_new(Bar {
358
///         x: 64,
359
///     })?,
360
/// }? FooError));
361
/// let foo = foo.unwrap();
362
/// println!("a: {}", &*foo.a.lock());
363
/// ```
364
///
365
/// ```rust
366
/// # #![allow(clippy::disallowed_names, clippy::new_ret_no_self)]
367
/// # #![feature(allocator_api, no_coverage)]
368
/// # #[path = "../examples/mutex.rs"] mod mutex; use mutex::*;
369
/// # use pinned_init::*;
370
/// # use core::{alloc::AllocError, pin::Pin, convert::Infallible};
371
/// # #[derive(Debug)]
372
/// # struct FooError;
373
/// # impl From<AllocError> for FooError { fn from(_: AllocError) -> Self { Self } }
374
/// # impl From<Infallible> for FooError { fn from(_: Infallible) -> Self { Self } }
375
/// #[pin_data]
376
/// struct Foo {
377
///     #[pin]
378
///     a: CMutex<usize>,
379
///     b: Box<Bar>,
380
/// }
381
///
382
/// struct Bar {
383
///     x: u32,
384
/// }
385
///
386
/// stack_try_pin_init!(let foo: Foo =? try_pin_init!(Foo {
387
///     a <- CMutex::new(42),
388
///     b: Box::try_new(Bar {
389
///         x: 64,
390
///     })?,
391
/// }? FooError));
392
/// println!("a: {}", &*foo.a.lock());
393
/// # Ok::<_, FooError>(())
394
/// ```
395
///
396
/// # Syntax
397
///
398
/// A normal `let` binding with optional type annotation. The expression is expected to implement
399
/// [`PinInit`]/[`Init`]. This macro assigns a result to the given variable, adding a `?` after the
400
/// `=` will propagate this error.
401
#[macro_export]
402
macro_rules! stack_try_pin_init {
403
    (let $var:ident $(: $t:ty)? = $val:expr) => {
404
        let val = $val;
405
        let mut $var = ::core::pin::pin!($crate::__internal::StackInit$(::<$t>)?::uninit());
406
        let mut $var = $crate::__internal::StackInit::init($var, val);
407
    };
408
    (let $var:ident $(: $t:ty)? =? $val:expr) => {
409
        let val = $val;
410
        let mut $var = ::core::pin::pin!($crate::__internal::StackInit$(::<$t>)?::uninit());
411
        let mut $var = $crate::__internal::StackInit::init($var, val)?;
412
    };
413
}
414
415
/// Construct an in-place, pinned initializer for `struct`s.
416
///
417
/// This macro defaults the error to [`Infallible`]. If you need a different error, then use
418
/// [`try_pin_init!`].
419
///
420
/// The syntax is almost identical to that of a normal `struct` initializer:
421
///
422
/// ```rust
423
/// # #![feature(allocator_api, no_coverage)]
424
/// # #![allow(clippy::disallowed_names, clippy::new_ret_no_self)]
425
/// # use pinned_init::*;
426
/// # use core::pin::Pin;
427
/// #[pin_data]
428
/// struct Foo {
429
///     a: usize,
430
///     b: Bar,
431
/// }
432
///
433
/// #[pin_data]
434
/// struct Bar {
435
///     x: u32,
436
/// }
437
///
438
/// # fn demo() -> impl PinInit<Foo> {
439
/// let a = 42;
440
///
441
/// let initializer = pin_init!(Foo {
442
///     a,
443
///     b: Bar {
444
///         x: 64,
445
///     },
446
/// });
447
/// # initializer }
448
/// # Box::pin_init(demo()).unwrap();
449
/// ```
450
///
451
/// Arbitrary Rust expressions can be used to set the value of a variable.
452
///
453
/// The fields are initialized in the order that they appear in the initializer. So it is possible
454
/// to read already initialized fields using raw pointers.
455
///
456
/// IMPORTANT: You are not allowed to create references to fields of the struct inside of the
457
/// initializer.
458
///
459
/// # Init-functions
460
///
461
/// When working with this library it is often desired to let others construct your types without
462
/// giving access to all fields. This is where you would normally write a plain function `new`
463
/// that would return a new instance of your type. With this library that is also possible.
464
/// However, there are a few extra things to keep in mind.
465
///
466
/// To create an initializer function, simply declare it like this:
467
///
468
/// ```rust
469
/// # #![feature(allocator_api, no_coverage)]
470
/// # #![allow(clippy::disallowed_names, clippy::new_ret_no_self)]
471
/// # use pinned_init::*;
472
/// # use core::pin::Pin;
473
/// # #[pin_data]
474
/// # struct Foo {
475
/// #     a: usize,
476
/// #     b: Bar,
477
/// # }
478
/// # #[pin_data]
479
/// # struct Bar {
480
/// #     x: u32,
481
/// # }
482
/// impl Foo {
483
///     fn new() -> impl PinInit<Self> {
484
///         pin_init!(Self {
485
///             a: 42,
486
///             b: Bar {
487
///                 x: 64,
488
///             },
489
///         })
490
///     }
491
/// }
492
/// # let _ = Box::pin_init(Foo::new());
493
/// ```
494
///
495
/// Users of `Foo` can now create it like this:
496
///
497
/// ```rust
498
/// # #![feature(allocator_api, no_coverage)]
499
/// # #![allow(clippy::disallowed_names, clippy::new_ret_no_self)]
500
/// # use pinned_init::*;
501
/// # use core::pin::Pin;
502
/// # #[pin_data]
503
/// # struct Foo {
504
/// #     a: usize,
505
/// #     b: Bar,
506
/// # }
507
/// # #[pin_data]
508
/// # struct Bar {
509
/// #     x: u32,
510
/// # }
511
/// # impl Foo {
512
/// #     fn new() -> impl PinInit<Self> {
513
/// #         pin_init!(Self {
514
/// #             a: 42,
515
/// #             b: Bar {
516
/// #                 x: 64,
517
/// #             },
518
/// #         })
519
/// #     }
520
/// # }
521
/// let foo = Box::pin_init(Foo::new());
522
/// ```
523
///
524
/// They can also easily embed it into their own `struct`s:
525
///
526
/// ```rust
527
/// # #![feature(allocator_api, no_coverage)]
528
/// # #![allow(clippy::disallowed_names, clippy::new_ret_no_self)]
529
/// # use pinned_init::*;
530
/// # use core::pin::Pin;
531
/// # #[pin_data]
532
/// # struct Foo {
533
/// #     a: usize,
534
/// #     b: Bar,
535
/// # }
536
/// # #[pin_data]
537
/// # struct Bar {
538
/// #     x: u32,
539
/// # }
540
/// # impl Foo {
541
/// #     fn new() -> impl PinInit<Self> {
542
/// #         pin_init!(Self {
543
/// #             a: 42,
544
/// #             b: Bar {
545
/// #                 x: 64,
546
/// #             },
547
/// #         })
548
/// #     }
549
/// # }
550
/// #[pin_data]
551
/// struct FooContainer {
552
///     #[pin]
553
///     foo1: Foo,
554
///     #[pin]
555
///     foo2: Foo,
556
///     other: u32,
557
/// }
558
///
559
/// impl FooContainer {
560
///     fn new(other: u32) -> impl PinInit<Self> {
561
///         pin_init!(Self {
562
///             foo1 <- Foo::new(),
563
///             foo2 <- Foo::new(),
564
///             other,
565
///         })
566
///     }
567
/// }
568
/// # let _ = Box::pin_init(FooContainer::new(0));
569
/// ```
570
///
571
/// Here we see that when using `pin_init!` with `PinInit`, one needs to write `<-` instead of `:`.
572
/// This signifies that the given field is initialized in-place. As with `struct` initializers, just
573
/// writing the field (in this case `other`) without `:` or `<-` means `other: other,`.
574
///
575
/// # Syntax
576
///
577
/// As already mentioned in the examples above, inside of `pin_init!` a `struct` initializer with
578
/// the following modifications is expected:
579
/// - Fields that you want to initialize in-place have to use `<-` instead of `:`.
580
/// - In front of the initializer you can write `&this in` to have access to a [`NonNull<Self>`]
581
///   pointer named `this` inside of the initializer.
582
/// - Using struct update syntax one can place `..Zeroable::zeroed()` at the very end of the
583
///   struct, this initializes every field with 0 and then runs all initializers specified in the
584
///   body. This can only be done if [`Zeroable`] is implemented for the struct.
585
///
586
/// For instance:
587
///
588
/// ```rust
589
/// # #![feature(allocator_api, no_coverage)]
590
/// # use pinned_init::*;
591
/// # use core::{ptr::addr_of_mut, marker::PhantomPinned};
592
/// #[pin_data]
593
/// struct Buf {
594
///     // `ptr` points into `buf`.
595
///     ptr: *mut u8,
596
///     buf: [u8; 64],
597
///     #[pin]
598
///     pin: PhantomPinned,
599
/// }
600
///
601
/// let init = pin_init!(&this in Buf {
602
///     buf: [0; 64],
603
///     ptr: unsafe { addr_of_mut!((*this.as_ptr()).buf).cast() },
604
///     pin: PhantomPinned,
605
/// });
606
/// # let _ = Box::pin_init(init);
607
/// ```
608
///
609
/// [`NonNull<Self>`]: core::ptr::NonNull
610
// For a detailed example of how this macro works, see the module documentation of the hidden
611
// module `__internal` inside of `__internal.rs`.
612
#[macro_export]
613
macro_rules! pin_init {
614
    ($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? {
615
        $($fields:tt)*
616
    }) => {
617
        $crate::__init_internal!(
618
            @this($($this)?),
619
            @typ($t $(::<$($generics),*>)?),
620
            @fields($($fields)*),
621
            @error(::core::convert::Infallible),
622
            @data(PinData, use_data),
623
            @has_data(HasPinData, __pin_data),
624
            @construct_closure(pin_init_from_closure),
625
            @munch_fields($($fields)*),
626
        )
627
    };
628
}
629
630
/// Construct an in-place, fallible pinned initializer for `struct`s.
631
///
632
/// If the initialization can complete without error (or [`Infallible`]), then use [`pin_init!`].
633
///
634
/// You can use the `?` operator or use `return Err(err)` inside the initializer to stop
635
/// initialization and return the error.
636
///
637
/// IMPORTANT: if you have `unsafe` code inside of the initializer you have to ensure that when
638
/// initialization fails, the memory can be safely deallocated without any further modifications.
639
///
640
/// This macro defaults the error to [`AllocError`].
641
///
642
/// The syntax is identical to [`pin_init!`] with the following exception: you can append `? $type`
643
/// after the `struct` initializer to specify the error type you want to use.
644
///
645
/// # Examples
646
///
647
/// ```rust
648
/// # #![feature(allocator_api, new_uninit, no_coverage)]
649
/// # use core::alloc::AllocError;
650
/// use pinned_init::*;
651
/// #[pin_data]
652
/// struct BigBuf {
653
///     big: Box<[u8; 1024 * 1024 * 1024]>,
654
///     small: [u8; 1024 * 1024],
655
///     ptr: *mut u8,
656
/// }
657
///
658
/// impl BigBuf {
659
///     fn new() -> impl PinInit<Self, AllocError> {
660
///         try_pin_init!(Self {
661
///             big: Box::init(zeroed())?,
662
///             small: [0; 1024 * 1024],
663
///             ptr: core::ptr::null_mut(),
664
///         })
665
///     }
666
/// }
667
/// # let _ = Box::pin_init(BigBuf::new());
668
/// ```
669
// For a detailed example of how this macro works, see the module documentation of the hidden
670
// module `__internal` inside of `__internal.rs`.
671
#[macro_export]
672
macro_rules! try_pin_init {
673
    ($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? {
674
        $($fields:tt)*
675
    }) => {
676
        $crate::__init_internal!(
677
            @this($($this)?),
678
            @typ($t $(::<$($generics),*>)? ),
679
            @fields($($fields)*),
680
            @error(::core::alloc::AllocError),
681
            @data(PinData, use_data),
682
            @has_data(HasPinData, __pin_data),
683
            @construct_closure(pin_init_from_closure),
684
            @munch_fields($($fields)*),
685
        )
686
    };
687
    ($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? {
688
        $($fields:tt)*
689
    }? $err:ty) => {
690
        $crate::__init_internal!(
691
            @this($($this)?),
692
            @typ($t $(::<$($generics),*>)? ),
693
            @fields($($fields)*),
694
            @error($err),
695
            @data(PinData, use_data),
696
            @has_data(HasPinData, __pin_data),
697
            @construct_closure(pin_init_from_closure),
698
            @munch_fields($($fields)*),
699
        )
700
    };
701
}
702
703
/// Construct an in-place initializer for `struct`s.
704
///
705
/// This macro defaults the error to [`Infallible`]. If you need a different error, then use
706
/// [`try_init!`].
707
///
708
/// The syntax is identical to [`pin_init!`] and its safety caveats also apply:
709
/// - `unsafe` code must guarantee either full initialization or return an error and allow
710
///   deallocation of the memory.
711
/// - the fields are initialized in the order given in the initializer.
712
/// - no references to fields are allowed to be created inside of the initializer.
713
///
714
/// This initializer is for initializing data in-place that might later be moved. If you want to
715
/// pin-initialize, use [`pin_init!`].
716
/// # Examples
717
///
718
/// ```rust
719
/// # #![feature(allocator_api, no_coverage)]
720
/// # use core::alloc::AllocError;
721
/// use pinned_init::*;
722
/// struct BigBuf {
723
///     big: Box<[u8; 1024 * 1024 * 1024]>,
724
///     small: [u8; 1024 * 1024],
725
/// }
726
///
727
/// impl BigBuf {
728
///     fn new() -> impl Init<Self, AllocError> {
729
///         try_init!(Self {
730
///             small <- zeroed(),
731
///             big: Box::init(zeroed())?,
732
///         }? AllocError)
733
///     }
734
/// }
735
/// # let _ = Box::init(BigBuf::new());
736
/// ```
737
// For a detailed example of how this macro works, see the module documentation of the hidden
738
// module `__internal` inside of `__internal.rs`.
739
#[macro_export]
740
macro_rules! init {
741
    ($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? {
742
        $($fields:tt)*
743
    }) => {
744
        $crate::__init_internal!(
745
            @this($($this)?),
746
            @typ($t $(::<$($generics),*>)?),
747
            @fields($($fields)*),
748
            @error(::core::convert::Infallible),
749
            @data(InitData, /*no use_data*/),
750
            @has_data(HasInitData, __init_data),
751
            @construct_closure(init_from_closure),
752
            @munch_fields($($fields)*),
753
        )
754
    }
755
}
756
757
/// Construct an in-place fallible initializer for `struct`s.
758
///
759
/// This macro defaults the error to [`AllocError`]. If you need [`Infallible`], then use
760
/// [`init!`].
761
///
762
/// The syntax is identical to [`try_pin_init!`]. If you want to specify a custom error,
763
/// append `? $type` after the `struct` initializer.
764
/// The safety caveats from [`try_pin_init!`] also apply:
765
/// - `unsafe` code must guarantee either full initialization or return an error and allow
766
///   deallocation of the memory.
767
/// - the fields are initialized in the order given in the initializer.
768
/// - no references to fields are allowed to be created inside of the initializer.
769
///
770
/// # Examples
771
///
772
/// ```rust
773
/// # #![feature(allocator_api, no_coverage)]
774
/// # use core::alloc::AllocError;
775
/// use pinned_init::*;
776
/// struct BigBuf {
777
///     big: Box<[u8; 1024 * 1024 * 1024]>,
778
///     small: [u8; 1024 * 1024],
779
/// }
780
///
781
/// impl BigBuf {
782
///     fn new() -> impl Init<Self, AllocError> {
783
///         try_init!(Self {
784
///             big: Box::init(zeroed())?,
785
///             small: [0; 1024 * 1024],
786
///         }? AllocError)
787
///     }
788
/// }
789
/// # let _ = Box::init(BigBuf::new());
790
/// ```
791
// For a detailed example of how this macro works, see the module documentation of the hidden
792
// module `__internal` inside of `__internal.rs`.
793
#[macro_export]
794
macro_rules! try_init {
795
    ($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? {
796
        $($fields:tt)*
797
    }) => {
798
        $crate::__init_internal!(
799
            @this($($this)?),
800
            @typ($t $(::<$($generics),*>)?),
801
            @fields($($fields)*),
802
            @error(::core::alloc::AllocError),
803
            @data(InitData, /*no use_data*/),
804
            @has_data(HasInitData, __init_data),
805
            @construct_closure(init_from_closure),
806
            @munch_fields($($fields)*),
807
        )
808
    };
809
    ($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? {
810
        $($fields:tt)*
811
    }? $err:ty) => {
812
        $crate::__init_internal!(
813
            @this($($this)?),
814
            @typ($t $(::<$($generics),*>)?),
815
            @fields($($fields)*),
816
            @error($err),
817
            @data(InitData, /*no use_data*/),
818
            @has_data(HasInitData, __init_data),
819
            @construct_closure(init_from_closure),
820
            @munch_fields($($fields)*),
821
        )
822
    };
823
}
824
825
/// A pin-initializer for the type `T`.
826
///
827
/// To use this initializer, you will need a suitable memory location that can hold a `T`. This can
828
/// be [`Box<T>`], [`Arc<T>`] or even the stack (see [`stack_pin_init!`]). Use the
829
/// [`InPlaceInit::pin_init`] function of a smart pointer like [`Arc<T>`] on this.
830
///
831
/// Also see the [module description](self).
832
///
833
/// # Safety
834
///
835
/// When implementing this type you will need to take great care. Also there are probably very few
836
/// cases where a manual implementation is necessary. Use [`pin_init_from_closure`] where possible.
837
///
838
/// The [`PinInit::__pinned_init`] function
839
/// - returns `Ok(())` if it initialized every field of `slot`,
840
/// - returns `Err(err)` if it encountered an error and then cleaned `slot`, this means:
841
///     - `slot` can be deallocated without UB occurring,
842
///     - `slot` does not need to be dropped,
843
///     - `slot` is not partially initialized.
844
/// - while constructing the `T` at `slot` it upholds the pinning invariants of `T`.
845
///
846
/// [`Arc<T>`]: alloc::sync::Arc
847
#[must_use = "An initializer must be used in order to create its value."]
848
pub unsafe trait PinInit<T: ?Sized, E = Infallible>: Sized {
849
    /// Initializes `slot`.
850
    ///
851
    /// # Safety
852
    ///
853
    /// - `slot` is a valid pointer to uninitialized memory.
854
    /// - the caller does not touch `slot` when `Err` is returned, they are only permitted to
855
    ///   deallocate.
856
    /// - `slot` will not move until it is dropped, i.e. it will be pinned.
857
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E>;
858
859
    /// First initializes the value using `self` then calls the function `f` with the initialized
860
    /// value.
861
    ///
862
    /// # Examples
863
    ///
864
    /// ```rust
865
    /// # #![allow(clippy::disallowed_names)]
866
    /// use pinned_init::*;
867
    /// use core::{mem::MaybeUninit, pin::Pin, convert::Infallible};
868
    /// #[repr(C)]
869
    /// struct RawFoo([u8; 16]);
870
    /// extern {
871
    ///     fn init_foo(_: *mut RawFoo);
872
    /// }
873
    ///
874
    /// #[pin_data]
875
    /// struct Foo {
876
    ///     #[pin]
877
    ///     raw: MaybeUninit<RawFoo>,
878
    /// }
879
    ///
880
    /// impl Foo {
881
    ///     fn setup(self: Pin<&mut Self>) {
882
    ///         println!("Setting up foo");
883
    ///     }
884
    /// }
885
    ///
886
    /// let foo = pin_init!(Foo {
887
    ///     raw <- unsafe {
888
    ///         pin_init_from_closure(|slot: *mut MaybeUninit<RawFoo>| {
889
    ///             init_foo(slot.cast::<RawFoo>());
890
    ///             Ok::<_, Infallible>(())
891
    ///         })
892
    ///     },
893
    /// }).pin_chain(|foo| {
894
    ///     foo.setup();
895
    ///     Ok(())
896
    /// });
897
    /// ```
898
0
    fn pin_chain<F>(self, f: F) -> ChainPinInit<Self, F, T, E>
899
0
    where
900
0
        F: FnOnce(Pin<&mut T>) -> Result<(), E>,
901
0
    {
902
0
        ChainPinInit(self, f, PhantomData)
903
0
    }
Unexecuted instantiation: <_ as pinned_init::PinInit<_, _>>::pin_chain::<_>
Unexecuted instantiation: <_ as pinned_init::PinInit<_, _>>::pin_chain::<_>
904
}
905
906
/// An initializer returned by [`PinInit::pin_chain`].
907
pub struct ChainPinInit<I, F, T: ?Sized, E>(I, F, __internal::Invariant<(E, T)>);
908
909
// SAFETY: the `__pinned_init` function is implemented such that it
910
// - returns `Ok(())` on successful initialization,
911
// - returns `Err(err)` on error and in this case `slot` will be dropped.
912
// - considers `slot` pinned.
913
unsafe impl<T: ?Sized, E, I, F> PinInit<T, E> for ChainPinInit<I, F, T, E>
914
where
915
    I: PinInit<T, E>,
916
    F: FnOnce(Pin<&mut T>) -> Result<(), E>,
917
{
918
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
919
        // SAFETY: all requirements fulfilled since this function is `__pinned_init`.
920
0
        unsafe { self.0.__pinned_init(slot)? };
921
        // SAFETY: The above call initialized `slot` and we still have unique access.
922
0
        let val = unsafe { &mut *slot };
923
0
        // SAFETY: `slot` is considered pinned
924
0
        let val = unsafe { Pin::new_unchecked(val) };
925
0
        (self.1)(val).map_err(|e| {
926
0
            // SAFETY: `slot` was initialized above.
927
0
            unsafe { core::ptr::drop_in_place(slot) };
928
0
            e
929
0
        })
Unexecuted instantiation: <pinned_init::ChainPinInit<_, _, _, _> as pinned_init::PinInit<_, _>>::__pinned_init::{closure#0}
Unexecuted instantiation: <pinned_init::ChainPinInit<_, _, _, _> as pinned_init::PinInit<_, _>>::__pinned_init::{closure#0}
930
0
    }
Unexecuted instantiation: <pinned_init::ChainPinInit<_, _, _, _> as pinned_init::PinInit<_, _>>::__pinned_init
Unexecuted instantiation: <pinned_init::ChainPinInit<_, _, _, _> as pinned_init::PinInit<_, _>>::__pinned_init
931
}
932
933
/// An initializer for `T`.
934
///
935
/// To use this initializer, you will need a suitable memory location that can hold a `T`. This can
936
/// be [`Box<T>`], [`Arc<T>`] or even the stack (see [`stack_pin_init!`]). Use the
937
/// [`InPlaceInit::init`] function of a smart pointer like [`Arc<T>`] on this. Because
938
/// [`PinInit<T, E>`] is a super trait, you can use every function that takes it as well.
939
///
940
/// Also see the [module description](self).
941
///
942
/// # Safety
943
///
944
/// When implementing this type you will need to take great care. Also there are probably very few
945
/// cases where a manual implementation is necessary. Use [`init_from_closure`] where possible.
946
///
947
/// The [`Init::__init`] function
948
/// - returns `Ok(())` if it initialized every field of `slot`,
949
/// - returns `Err(err)` if it encountered an error and then cleaned `slot`, this means:
950
///     - `slot` can be deallocated without UB occurring,
951
///     - `slot` does not need to be dropped,
952
///     - `slot` is not partially initialized.
953
/// - while constructing the `T` at `slot` it upholds the pinning invariants of `T`.
954
///
955
/// The `__pinned_init` function from the supertrait [`PinInit`] needs to execute the exact same
956
/// code as `__init`.
957
///
958
/// Contrary to its supertype [`PinInit<T, E>`] the caller is allowed to
959
/// move the pointee after initialization.
960
///
961
/// [`Arc<T>`]: alloc::sync::Arc
962
#[must_use = "An initializer must be used in order to create its value."]
963
pub unsafe trait Init<T: ?Sized, E = Infallible>: PinInit<T, E> {
964
    /// Initializes `slot`.
965
    ///
966
    /// # Safety
967
    ///
968
    /// - `slot` is a valid pointer to uninitialized memory.
969
    /// - the caller does not touch `slot` when `Err` is returned, they are only permitted to
970
    ///   deallocate.
971
    unsafe fn __init(self, slot: *mut T) -> Result<(), E>;
972
973
    /// First initializes the value using `self` then calls the function `f` with the initialized
974
    /// value.
975
    ///
976
    /// # Examples
977
    ///
978
    /// ```rust
979
    /// # #![allow(clippy::disallowed_names)]
980
    /// use pinned_init::*;
981
    /// use core::convert::Infallible;
982
    /// struct Foo {
983
    ///     buf: [u8; 1_000_000],
984
    /// }
985
    ///
986
    /// impl Foo {
987
    ///     fn setup(&mut self) {
988
    ///         println!("Setting up foo");
989
    ///     }
990
    /// }
991
    ///
992
    /// let foo = init!(Foo {
993
    ///     buf <- zeroed::<_, Infallible>()
994
    /// }).chain(|foo| {
995
    ///     foo.setup();
996
    ///     Ok(())
997
    /// });
998
    /// ```
999
0
    fn chain<F>(self, f: F) -> ChainInit<Self, F, T, E>
1000
0
    where
1001
0
        F: FnOnce(&mut T) -> Result<(), E>,
1002
0
    {
1003
0
        ChainInit(self, f, PhantomData)
1004
0
    }
Unexecuted instantiation: <_ as pinned_init::Init<_, _>>::chain::<_>
Unexecuted instantiation: <_ as pinned_init::Init<_, _>>::chain::<_>
1005
}
1006
1007
/// An initializer returned by [`Init::chain`].
1008
pub struct ChainInit<I, F, T: ?Sized, E>(I, F, __internal::Invariant<(E, T)>);
1009
1010
// SAFETY: the `__init` function is implemented such that it
1011
// - returns `Ok(())` on successful initialization,
1012
// - returns `Err(err)` on error and in this case `slot` will be dropped.
1013
unsafe impl<T: ?Sized, E, I, F> Init<T, E> for ChainInit<I, F, T, E>
1014
where
1015
    I: Init<T, E>,
1016
    F: FnOnce(&mut T) -> Result<(), E>,
1017
{
1018
    unsafe fn __init(self, slot: *mut T) -> Result<(), E> {
1019
        // SAFETY: all requirements fulfilled since this function is `__init`.
1020
0
        unsafe { self.0.__pinned_init(slot)? };
1021
        // SAFETY: The above call initialized `slot` and we still have unique access.
1022
0
        (self.1)(unsafe { &mut *slot }).map_err(|e| {
1023
0
            // SAFETY: `slot` was initialized above.
1024
0
            unsafe { core::ptr::drop_in_place(slot) };
1025
0
            e
1026
0
        })
Unexecuted instantiation: <pinned_init::ChainInit<_, _, _, _> as pinned_init::Init<_, _>>::__init::{closure#0}
Unexecuted instantiation: <pinned_init::ChainInit<_, _, _, _> as pinned_init::Init<_, _>>::__init::{closure#0}
1027
0
    }
Unexecuted instantiation: <pinned_init::ChainInit<_, _, _, _> as pinned_init::Init<_, _>>::__init
Unexecuted instantiation: <pinned_init::ChainInit<_, _, _, _> as pinned_init::Init<_, _>>::__init
1028
}
1029
1030
// SAFETY: `__pinned_init` behaves exactly the same as `__init`.
1031
unsafe impl<T: ?Sized, E, I, F> PinInit<T, E> for ChainInit<I, F, T, E>
1032
where
1033
    I: Init<T, E>,
1034
    F: FnOnce(&mut T) -> Result<(), E>,
1035
{
1036
0
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
1037
0
        // SAFETY: `__init` has less strict requirements compared to `__pinned_init`.
1038
0
        unsafe { self.__init(slot) }
1039
0
    }
Unexecuted instantiation: <pinned_init::ChainInit<_, _, _, _> as pinned_init::PinInit<_, _>>::__pinned_init
Unexecuted instantiation: <pinned_init::ChainInit<_, _, _, _> as pinned_init::PinInit<_, _>>::__pinned_init
1040
}
1041
1042
/// Creates a new [`PinInit<T, E>`] from the given closure.
1043
///
1044
/// # Safety
1045
///
1046
/// The closure:
1047
/// - returns `Ok(())` if it initialized every field of `slot`,
1048
/// - returns `Err(err)` if it encountered an error and then cleaned `slot`, this means:
1049
///     - `slot` can be deallocated without UB occurring,
1050
///     - `slot` does not need to be dropped,
1051
///     - `slot` is not partially initialized.
1052
/// - may assume that the `slot` does not move if `T: !Unpin`,
1053
/// - while constructing the `T` at `slot` it upholds the pinning invariants of `T`.
1054
#[inline]
1055
93.7k
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
93.7k
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
93.7k
) -> impl PinInit<T, E> {
1058
93.7k
    __internal::InitClosure(f, PhantomData)
1059
93.7k
}
pinned_init::pin_init_from_closure::<core::cell::UnsafeCell<usize>, core::convert::Infallible, <alloc_fail::ring_buf::mutex::CMutex<usize>>::new<usize>::{closure#0}::{closure#1}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<alloc_fail::ring_buf::mutex::linked_list::ListHead, core::alloc::AllocError, <alloc::boxed::Box<alloc_fail::ring_buf::mutex::linked_list::ListHead> as pinned_init::InPlaceInit<alloc_fail::ring_buf::mutex::linked_list::ListHead>>::pin_init<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::mutex::linked_list::ListHead>::insert_next::{closure#1}, alloc_fail::ring_buf::mutex::linked_list::ListHead, core::convert::Infallible>>::{closure#0}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<alloc_fail::ring_buf::mutex::CMutex<usize>, core::alloc::AllocError, <alloc::sync::Arc<alloc_fail::ring_buf::mutex::CMutex<usize>> as pinned_init::InPlaceInit<alloc_fail::ring_buf::mutex::CMutex<usize>>>::pin_init<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::mutex::CMutex<usize>>::new<usize>::{closure#1}, alloc_fail::ring_buf::mutex::CMutex<usize>, core::convert::Infallible>>::{closure#0}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<alloc_fail::ring_buf::mutex::WaitEntry, core::convert::Infallible, <alloc_fail::ring_buf::mutex::WaitEntry>::insert_new::{closure#1}>
Line
Count
Source
1055
9.60k
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
9.60k
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
9.60k
) -> impl PinInit<T, E> {
1058
9.60k
    __internal::InitClosure(f, PhantomData)
1059
9.60k
}
pinned_init::pin_init_from_closure::<alloc_fail::ring_buf::mutex::linked_list::ListHead, core::alloc::AllocError, <alloc::boxed::Box<alloc_fail::ring_buf::mutex::linked_list::ListHead> as pinned_init::InPlaceInit<alloc_fail::ring_buf::mutex::linked_list::ListHead>>::pin_init<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::mutex::linked_list::ListHead>::new::{closure#1}, alloc_fail::ring_buf::mutex::linked_list::ListHead, core::convert::Infallible>>::{closure#0}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<alloc_fail::ring_buf::RingBuffer<u8, 64usize>, core::convert::Infallible, <alloc_fail::ring_buf::RingBuffer<u8, 64usize>>::new::{closure#1}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<alloc_fail::ring_buf::mutex::linked_list::ListHead, core::convert::Infallible, <alloc_fail::ring_buf::mutex::linked_list::ListHead>::new::{closure#1}>
Line
Count
Source
1055
3
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
3
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
3
) -> impl PinInit<T, E> {
1058
3
    __internal::InitClosure(f, PhantomData)
1059
3
}
pinned_init::pin_init_from_closure::<alloc_fail::ring_buf::mutex::CMutex<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>, core::convert::Infallible, <alloc_fail::ring_buf::mutex::CMutex<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>>::new<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>::new::{closure#1}, alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>, core::convert::Infallible>>::{closure#1}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>, core::convert::Infallible, <alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>::new::{closure#1}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::EvenU64, 4usize>, core::convert::Infallible, <alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::EvenU64, 4usize>>::new::{closure#1}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<core::cell::UnsafeCell<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>, core::convert::Infallible, <alloc_fail::ring_buf::mutex::CMutex<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>>::new<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>::new::{closure#1}, alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>, core::convert::Infallible>>::{closure#0}::{closure#1}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<alloc_fail::ring_buf::mutex::CMutex<usize>, core::convert::Infallible, <alloc_fail::ring_buf::mutex::CMutex<usize>>::new<usize>::{closure#1}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>, core::alloc::AllocError, <alloc::boxed::Box<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>> as pinned_init::InPlaceInit<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>>>::pin_init<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>>::new::{closure#1}, alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>, core::convert::Infallible>>::{closure#0}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::EvenU64, 4usize>, core::alloc::AllocError, <alloc::boxed::Box<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::EvenU64, 4usize>> as pinned_init::InPlaceInit<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::EvenU64, 4usize>>>::pin_init<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::EvenU64, 4usize>>::new::{closure#1}, alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::EvenU64, 4usize>, core::convert::Infallible>>::{closure#0}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<alloc_fail::ring_buf::mutex::linked_list::ListHead, core::convert::Infallible, <alloc_fail::ring_buf::mutex::linked_list::ListHead>::insert_next::{closure#1}>
Line
Count
Source
1055
4
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
4
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
4
) -> impl PinInit<T, E> {
1058
4
    __internal::InitClosure(f, PhantomData)
1059
4
}
pinned_init::pin_init_from_closure::<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>, core::alloc::AllocError, <alloc::sync::Arc<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>> as pinned_init::InPlaceInit<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>>>::pin_init<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>>::new::{closure#1}, alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>, core::convert::Infallible>>::{closure#0}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>, core::convert::Infallible, <alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>>::new::{closure#1}>
Line
Count
Source
1055
2
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
2
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
2
) -> impl PinInit<T, E> {
1058
2
    __internal::InitClosure(f, PhantomData)
1059
2
}
pinned_init::pin_init_from_closure::<alloc_fail::ring_buf::mutex::CMutex<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>, core::alloc::AllocError, <alloc::sync::Arc<alloc_fail::ring_buf::mutex::CMutex<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>> as pinned_init::InPlaceInit<alloc_fail::ring_buf::mutex::CMutex<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>>>::pin_init<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::mutex::CMutex<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>>::new<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>::new::{closure#1}, alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>, core::convert::Infallible>>::{closure#1}, alloc_fail::ring_buf::mutex::CMutex<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>, core::convert::Infallible>>::{closure#0}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<alloc_fail::ring_buf::mutex::linked_list::ListHead, core::convert::Infallible, <alloc_fail::ring_buf::mutex::linked_list::ListHead>::insert_prev::{closure#1}>
Line
Count
Source
1055
9.60k
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
9.60k
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
9.60k
) -> impl PinInit<T, E> {
1058
9.60k
    __internal::InitClosure(f, PhantomData)
1059
9.60k
}
Unexecuted instantiation: pinned_init::pin_init_from_closure::<_, _, _>
Unexecuted instantiation: pinned_init::pin_init_from_closure::<_, _, _>
pinned_init::pin_init_from_closure::<ring_buf::mutex::CMutex<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>, core::convert::Infallible, <ring_buf::mutex::CMutex<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>>::new<pinned_init::__internal::InitClosure<<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>::new::{closure#1}, ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>, core::convert::Infallible>>::{closure#1}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>, core::convert::Infallible, <ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>::new::{closure#1}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<core::cell::UnsafeCell<usize>, core::convert::Infallible, <ring_buf::mutex::CMutex<usize>>::new<usize>::{closure#0}::{closure#1}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<ring_buf::mutex::linked_list::ListHead, core::alloc::AllocError, <alloc::boxed::Box<ring_buf::mutex::linked_list::ListHead> as pinned_init::InPlaceInit<ring_buf::mutex::linked_list::ListHead>>::pin_init<pinned_init::__internal::InitClosure<<ring_buf::mutex::linked_list::ListHead>::insert_next::{closure#1}, ring_buf::mutex::linked_list::ListHead, core::convert::Infallible>>::{closure#0}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<ring_buf::RingBuffer<ring_buf::EvenU64, 4usize>, core::convert::Infallible, <ring_buf::RingBuffer<ring_buf::EvenU64, 4usize>>::new::{closure#1}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<ring_buf::mutex::CMutex<usize>, core::convert::Infallible, <ring_buf::mutex::CMutex<usize>>::new<usize>::{closure#1}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<ring_buf::mutex::linked_list::ListHead, core::convert::Infallible, <ring_buf::mutex::linked_list::ListHead>::insert_prev::{closure#1}>
Line
Count
Source
1055
14.4k
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
14.4k
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
14.4k
) -> impl PinInit<T, E> {
1058
14.4k
    __internal::InitClosure(f, PhantomData)
1059
14.4k
}
pinned_init::pin_init_from_closure::<ring_buf::mutex::WaitEntry, core::convert::Infallible, <ring_buf::mutex::WaitEntry>::insert_new::{closure#1}>
Line
Count
Source
1055
14.4k
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
14.4k
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
14.4k
) -> impl PinInit<T, E> {
1058
14.4k
    __internal::InitClosure(f, PhantomData)
1059
14.4k
}
pinned_init::pin_init_from_closure::<ring_buf::mutex::linked_list::ListHead, core::convert::Infallible, <ring_buf::mutex::linked_list::ListHead>::insert_next::{closure#1}>
Line
Count
Source
1055
4
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
4
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
4
) -> impl PinInit<T, E> {
1058
4
    __internal::InitClosure(f, PhantomData)
1059
4
}
pinned_init::pin_init_from_closure::<ring_buf::mutex::CMutex<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>, core::alloc::AllocError, <alloc::sync::Arc<ring_buf::mutex::CMutex<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>> as pinned_init::InPlaceInit<ring_buf::mutex::CMutex<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>>>::pin_init<pinned_init::__internal::InitClosure<<ring_buf::mutex::CMutex<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>>::new<pinned_init::__internal::InitClosure<<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>::new::{closure#1}, ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>, core::convert::Infallible>>::{closure#1}, ring_buf::mutex::CMutex<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>, core::convert::Infallible>>::{closure#0}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<ring_buf::RingBuffer<ring_buf::EvenU64, 4usize>, core::alloc::AllocError, <alloc::boxed::Box<ring_buf::RingBuffer<ring_buf::EvenU64, 4usize>> as pinned_init::InPlaceInit<ring_buf::RingBuffer<ring_buf::EvenU64, 4usize>>>::pin_init<pinned_init::__internal::InitClosure<<ring_buf::RingBuffer<ring_buf::EvenU64, 4usize>>::new::{closure#1}, ring_buf::RingBuffer<ring_buf::EvenU64, 4usize>, core::convert::Infallible>>::{closure#0}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<ring_buf::RingBuffer<u8, 64usize>, core::convert::Infallible, <ring_buf::RingBuffer<u8, 64usize>>::new::{closure#1}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<ring_buf::mutex::CMutex<usize>, core::alloc::AllocError, <alloc::sync::Arc<ring_buf::mutex::CMutex<usize>> as pinned_init::InPlaceInit<ring_buf::mutex::CMutex<usize>>>::pin_init<pinned_init::__internal::InitClosure<<ring_buf::mutex::CMutex<usize>>::new<usize>::{closure#1}, ring_buf::mutex::CMutex<usize>, core::convert::Infallible>>::{closure#0}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<ring_buf::mutex::linked_list::ListHead, core::alloc::AllocError, <alloc::boxed::Box<ring_buf::mutex::linked_list::ListHead> as pinned_init::InPlaceInit<ring_buf::mutex::linked_list::ListHead>>::pin_init<pinned_init::__internal::InitClosure<<ring_buf::mutex::linked_list::ListHead>::new::{closure#1}, ring_buf::mutex::linked_list::ListHead, core::convert::Infallible>>::{closure#0}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<ring_buf::mutex::linked_list::ListHead, core::convert::Infallible, <ring_buf::mutex::linked_list::ListHead>::new::{closure#1}>
Line
Count
Source
1055
3
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
3
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
3
) -> impl PinInit<T, E> {
1058
3
    __internal::InitClosure(f, PhantomData)
1059
3
}
pinned_init::pin_init_from_closure::<core::cell::UnsafeCell<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>, core::convert::Infallible, <ring_buf::mutex::CMutex<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>>::new<pinned_init::__internal::InitClosure<<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>::new::{closure#1}, ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>, core::convert::Infallible>>::{closure#0}::{closure#1}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<linked_list::ListHead, core::alloc::AllocError, <alloc::boxed::Box<linked_list::ListHead> as pinned_init::InPlaceInit<linked_list::ListHead>>::pin_init<pinned_init::__internal::InitClosure<<linked_list::ListHead>::new::{closure#1}, linked_list::ListHead, core::convert::Infallible>>::{closure#0}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<linked_list::ListHead, core::alloc::AllocError, <alloc::boxed::Box<linked_list::ListHead> as pinned_init::InPlaceInit<linked_list::ListHead>>::pin_init<pinned_init::__internal::InitClosure<<linked_list::ListHead>::insert_next::{closure#1}, linked_list::ListHead, core::convert::Infallible>>::{closure#0}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<linked_list::ListHead, core::convert::Infallible, <linked_list::ListHead>::new::{closure#1}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<linked_list::ListHead, core::convert::Infallible, <linked_list::ListHead>::insert_next::{closure#1}>
Line
Count
Source
1055
4
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
4
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
4
) -> impl PinInit<T, E> {
1058
4
    __internal::InitClosure(f, PhantomData)
1059
4
}
pinned_init::pin_init_from_closure::<mutex::linked_list::ListHead, core::alloc::AllocError, <alloc::boxed::Box<mutex::linked_list::ListHead> as pinned_init::InPlaceInit<mutex::linked_list::ListHead>>::pin_init<pinned_init::__internal::InitClosure<<mutex::linked_list::ListHead>::insert_next::{closure#1}, mutex::linked_list::ListHead, core::convert::Infallible>>::{closure#0}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<core::cell::UnsafeCell<usize>, core::convert::Infallible, <mutex::CMutex<usize>>::new<usize>::{closure#0}::{closure#1}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<mutex::linked_list::ListHead, core::convert::Infallible, <mutex::linked_list::ListHead>::new::{closure#1}>
Line
Count
Source
1055
2
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
2
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
2
) -> impl PinInit<T, E> {
1058
2
    __internal::InitClosure(f, PhantomData)
1059
2
}
pinned_init::pin_init_from_closure::<mutex::CMutex<usize>, core::convert::Infallible, <mutex::CMutex<usize>>::new<usize>::{closure#1}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<mutex::linked_list::ListHead, core::alloc::AllocError, <alloc::boxed::Box<mutex::linked_list::ListHead> as pinned_init::InPlaceInit<mutex::linked_list::ListHead>>::pin_init<pinned_init::__internal::InitClosure<<mutex::linked_list::ListHead>::new::{closure#1}, mutex::linked_list::ListHead, core::convert::Infallible>>::{closure#0}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<mutex::linked_list::ListHead, core::convert::Infallible, <mutex::linked_list::ListHead>::insert_next::{closure#1}>
Line
Count
Source
1055
4
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
4
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
4
) -> impl PinInit<T, E> {
1058
4
    __internal::InitClosure(f, PhantomData)
1059
4
}
pinned_init::pin_init_from_closure::<mutex::linked_list::ListHead, core::convert::Infallible, <mutex::linked_list::ListHead>::insert_prev::{closure#1}>
Line
Count
Source
1055
10.1k
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
10.1k
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
10.1k
) -> impl PinInit<T, E> {
1058
10.1k
    __internal::InitClosure(f, PhantomData)
1059
10.1k
}
pinned_init::pin_init_from_closure::<mutex::WaitEntry, core::convert::Infallible, <mutex::WaitEntry>::insert_new::{closure#1}>
Line
Count
Source
1055
10.1k
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
10.1k
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
10.1k
) -> impl PinInit<T, E> {
1058
10.1k
    __internal::InitClosure(f, PhantomData)
1059
10.1k
}
pinned_init::pin_init_from_closure::<mutex::CMutex<usize>, core::alloc::AllocError, <alloc::sync::Arc<mutex::CMutex<usize>> as pinned_init::InPlaceInit<mutex::CMutex<usize>>>::pin_init<pinned_init::__internal::InitClosure<<mutex::CMutex<usize>>::new<usize>::{closure#1}, mutex::CMutex<usize>, core::convert::Infallible>>::{closure#0}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<core::cell::UnsafeCell<libc::unix::linux_like::linux::pthread_mutex_t>, pthread_mutex::pthread_mtx::Error, <pthread_mutex::pthread_mtx::PThreadMutex<_>>::new::init_raw::{closure#0}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<pthread_mutex::pthread_mtx::PThreadMutex<usize>, pthread_mutex::pthread_mtx::Error, <pthread_mutex::pthread_mtx::PThreadMutex<usize>>::new::{closure#1}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<static_init::mutex::CMutex<usize>, core::alloc::AllocError, <alloc::sync::Arc<static_init::mutex::CMutex<usize>> as pinned_init::InPlaceInit<static_init::mutex::CMutex<usize>>>::pin_init<pinned_init::__internal::InitClosure<<static_init::mutex::CMutex<usize>>::new<usize>::{closure#1}, static_init::mutex::CMutex<usize>, core::convert::Infallible>>::{closure#0}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<static_init::mutex::WaitEntry, core::convert::Infallible, <static_init::mutex::WaitEntry>::insert_new::{closure#1}>
Line
Count
Source
1055
12.6k
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
12.6k
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
12.6k
) -> impl PinInit<T, E> {
1058
12.6k
    __internal::InitClosure(f, PhantomData)
1059
12.6k
}
pinned_init::pin_init_from_closure::<static_init::mutex::linked_list::ListHead, core::convert::Infallible, <static_init::mutex::linked_list::ListHead>::new::{closure#1}>
Line
Count
Source
1055
2
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
2
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
2
) -> impl PinInit<T, E> {
1058
2
    __internal::InitClosure(f, PhantomData)
1059
2
}
pinned_init::pin_init_from_closure::<static_init::mutex::linked_list::ListHead, core::convert::Infallible, <static_init::mutex::linked_list::ListHead>::insert_next::{closure#1}>
Line
Count
Source
1055
4
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
4
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
4
) -> impl PinInit<T, E> {
1058
4
    __internal::InitClosure(f, PhantomData)
1059
4
}
pinned_init::pin_init_from_closure::<static_init::mutex::linked_list::ListHead, core::convert::Infallible, <static_init::mutex::linked_list::ListHead>::insert_prev::{closure#1}>
Line
Count
Source
1055
12.6k
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
12.6k
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
12.6k
) -> impl PinInit<T, E> {
1058
12.6k
    __internal::InitClosure(f, PhantomData)
1059
12.6k
}
pinned_init::pin_init_from_closure::<static_init::mutex::linked_list::ListHead, core::alloc::AllocError, <alloc::boxed::Box<static_init::mutex::linked_list::ListHead> as pinned_init::InPlaceInit<static_init::mutex::linked_list::ListHead>>::pin_init<pinned_init::__internal::InitClosure<<static_init::mutex::linked_list::ListHead>::insert_next::{closure#1}, static_init::mutex::linked_list::ListHead, core::convert::Infallible>>::{closure#0}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<static_init::mutex::CMutex<usize>, core::convert::Infallible, <static_init::mutex::CMutex<usize>>::new<usize>::{closure#1}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<core::cell::UnsafeCell<usize>, core::convert::Infallible, <static_init::mutex::CMutex<usize>>::new<usize>::{closure#0}::{closure#1}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
pinned_init::pin_init_from_closure::<static_init::mutex::linked_list::ListHead, core::alloc::AllocError, <alloc::boxed::Box<static_init::mutex::linked_list::ListHead> as pinned_init::InPlaceInit<static_init::mutex::linked_list::ListHead>>::pin_init<pinned_init::__internal::InitClosure<<static_init::mutex::linked_list::ListHead>::new::{closure#1}, static_init::mutex::linked_list::ListHead, core::convert::Infallible>>::{closure#0}>
Line
Count
Source
1055
1
pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
1056
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1057
1
) -> impl PinInit<T, E> {
1058
1
    __internal::InitClosure(f, PhantomData)
1059
1
}
1060
1061
/// Creates a new [`Init<T, E>`] from the given closure.
1062
///
1063
/// # Safety
1064
///
1065
/// The closure:
1066
/// - returns `Ok(())` if it initialized every field of `slot`,
1067
/// - returns `Err(err)` if it encountered an error and then cleaned `slot`, this means:
1068
///     - `slot` can be deallocated without UB occurring,
1069
///     - `slot` does not need to be dropped,
1070
///     - `slot` is not partially initialized.
1071
/// - the `slot` may move after initialization.
1072
/// - while constructing the `T` at `slot` it upholds the pinning invariants of `T`.
1073
#[inline]
1074
686
pub const unsafe fn init_from_closure<T: ?Sized, E>(
1075
686
    f: impl FnOnce(*mut T) -> Result<(), E>,
1076
686
) -> impl Init<T, E> {
1077
686
    __internal::InitClosure(f, PhantomData)
1078
686
}
pinned_init::init_from_closure::<alloc_fail::ring_buf::EvenU64, core::alloc::AllocError, <alloc_fail::ring_buf::EvenU64>::new2::{closure#1}>
Line
Count
Source
1074
4
pub const unsafe fn init_from_closure<T: ?Sized, E>(
1075
4
    f: impl FnOnce(*mut T) -> Result<(), E>,
1076
4
) -> impl Init<T, E> {
1077
4
    __internal::InitClosure(f, PhantomData)
1078
4
}
pinned_init::init_from_closure::<[u8; 1099511627776usize], core::alloc::AllocError, <alloc::sync::Arc<[u8; 1099511627776usize]> as pinned_init::InPlaceInit<[u8; 1099511627776usize]>>::init<pinned_init::__internal::InitClosure<pinned_init::zeroed<[u8; 1099511627776usize], core::convert::Infallible>::{closure#0}, [u8; 1099511627776usize], core::convert::Infallible>>::{closure#0}>
Line
Count
Source
1074
1
pub const unsafe fn init_from_closure<T: ?Sized, E>(
1075
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1076
1
) -> impl Init<T, E> {
1077
1
    __internal::InitClosure(f, PhantomData)
1078
1
}
pinned_init::init_from_closure::<u8, core::convert::Infallible, <alloc_fail::ring_buf::RingBuffer<u8, 64usize>>::pop_no_stack::{closure#0}>
Line
Count
Source
1074
63
pub const unsafe fn init_from_closure<T: ?Sized, E>(
1075
63
    f: impl FnOnce(*mut T) -> Result<(), E>,
1076
63
) -> impl Init<T, E> {
1077
63
    __internal::InitClosure(f, PhantomData)
1078
63
}
pinned_init::init_from_closure::<alloc_fail::ring_buf::BigStruct, core::alloc::AllocError, <alloc::sync::Arc<alloc_fail::ring_buf::BigStruct> as pinned_init::InPlaceInit<alloc_fail::ring_buf::BigStruct>>::init<pinned_init::__internal::InitClosure<alloc_fail::ring_buf::big_struct::{closure#1}, alloc_fail::ring_buf::BigStruct, core::convert::Infallible>>::{closure#0}>
Line
Count
Source
1074
1
pub const unsafe fn init_from_closure<T: ?Sized, E>(
1075
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1076
1
) -> impl Init<T, E> {
1077
1
    __internal::InitClosure(f, PhantomData)
1078
1
}
pinned_init::init_from_closure::<[u8; 1099511627776usize], core::alloc::AllocError, <alloc::boxed::Box<[u8; 1099511627776usize]> as pinned_init::InPlaceInit<[u8; 1099511627776usize]>>::init<pinned_init::__internal::InitClosure<pinned_init::zeroed<[u8; 1099511627776usize], core::convert::Infallible>::{closure#0}, [u8; 1099511627776usize], core::convert::Infallible>>::{closure#0}>
Line
Count
Source
1074
1
pub const unsafe fn init_from_closure<T: ?Sized, E>(
1075
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1076
1
) -> impl Init<T, E> {
1077
1
    __internal::InitClosure(f, PhantomData)
1078
1
}
Unexecuted instantiation: pinned_init::init_from_closure::<[core::mem::maybe_uninit::MaybeUninit<u8>; 1099511627776usize], core::convert::Infallible, <alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>>::new::{closure#0}::{closure#1}>
pinned_init::init_from_closure::<[core::mem::maybe_uninit::MaybeUninit<alloc_fail::ring_buf::EvenU64>; 4usize], core::convert::Infallible, <alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::EvenU64, 4usize>>::new::{closure#0}::{closure#1}>
Line
Count
Source
1074
1
pub const unsafe fn init_from_closure<T: ?Sized, E>(
1075
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1076
1
) -> impl Init<T, E> {
1077
1
    __internal::InitClosure(f, PhantomData)
1078
1
}
pinned_init::init_from_closure::<alloc_fail::ring_buf::BigStruct, core::convert::Infallible, alloc_fail::ring_buf::big_struct::{closure#1}>
Line
Count
Source
1074
1
pub const unsafe fn init_from_closure<T: ?Sized, E>(
1075
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1076
1
) -> impl Init<T, E> {
1077
1
    __internal::InitClosure(f, PhantomData)
1078
1
}
pinned_init::init_from_closure::<alloc_fail::ring_buf::BigStruct, core::convert::Infallible, alloc_fail::ring_buf::with_big_struct::{closure#1}>
Line
Count
Source
1074
63
pub const unsafe fn init_from_closure<T: ?Sized, E>(
1075
63
    f: impl FnOnce(*mut T) -> Result<(), E>,
1076
63
) -> impl Init<T, E> {
1077
63
    __internal::InitClosure(f, PhantomData)
1078
63
}
pinned_init::init_from_closure::<core::mem::maybe_uninit::MaybeUninit<u8>, core::convert::Infallible, pinned_init::uninit<u8, core::convert::Infallible>::{closure#0}>
Line
Count
Source
1074
63
pub const unsafe fn init_from_closure<T: ?Sized, E>(
1075
63
    f: impl FnOnce(*mut T) -> Result<(), E>,
1076
63
) -> impl Init<T, E> {
1077
63
    __internal::InitClosure(f, PhantomData)
1078
63
}
pinned_init::init_from_closure::<core::mem::maybe_uninit::MaybeUninit<u8>, core::convert::Infallible, pinned_init::zeroed<core::mem::maybe_uninit::MaybeUninit<u8>, core::convert::Infallible>::{closure#0}>
Line
Count
Source
1074
2
pub const unsafe fn init_from_closure<T: ?Sized, E>(
1075
2
    f: impl FnOnce(*mut T) -> Result<(), E>,
1076
2
) -> impl Init<T, E> {
1077
2
    __internal::InitClosure(f, PhantomData)
1078
2
}
pinned_init::init_from_closure::<[core::mem::maybe_uninit::MaybeUninit<alloc_fail::ring_buf::BigStruct>; 64usize], core::convert::Infallible, <alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>::new::{closure#0}::{closure#1}>
Line
Count
Source
1074
1
pub const unsafe fn init_from_closure<T: ?Sized, E>(
1075
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1076
1
) -> impl Init<T, E> {
1077
1
    __internal::InitClosure(f, PhantomData)
1078
1
}
pinned_init::init_from_closure::<[u8; 1099511627776usize], core::convert::Infallible, pinned_init::zeroed<[u8; 1099511627776usize], core::convert::Infallible>::{closure#0}>
Line
Count
Source
1074
2
pub const unsafe fn init_from_closure<T: ?Sized, E>(
1075
2
    f: impl FnOnce(*mut T) -> Result<(), E>,
1076
2
) -> impl Init<T, E> {
1077
2
    __internal::InitClosure(f, PhantomData)
1078
2
}
pinned_init::init_from_closure::<alloc_fail::ring_buf::BigStruct, core::convert::Infallible, alloc_fail::ring_buf::big_struct::{closure#3}>
Line
Count
Source
1074
1
pub const unsafe fn init_from_closure<T: ?Sized, E>(
1075
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1076
1
) -> impl Init<T, E> {
1077
1
    __internal::InitClosure(f, PhantomData)
1078
1
}
pinned_init::init_from_closure::<alloc_fail::ring_buf::BigStruct, core::convert::Infallible, <alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>::pop_no_stack::{closure#0}>
Line
Count
Source
1074
63
pub const unsafe fn init_from_closure<T: ?Sized, E>(
1075
63
    f: impl FnOnce(*mut T) -> Result<(), E>,
1076
63
) -> impl Init<T, E> {
1077
63
    __internal::InitClosure(f, PhantomData)
1078
63
}
pinned_init::init_from_closure::<alloc_fail::ring_buf::EvenU64, (), <alloc_fail::ring_buf::EvenU64>::new::{closure#1}>
Line
Count
Source
1074
9
pub const unsafe fn init_from_closure<T: ?Sized, E>(
1075
9
    f: impl FnOnce(*mut T) -> Result<(), E>,
1076
9
) -> impl Init<T, E> {
1077
9
    __internal::InitClosure(f, PhantomData)
1078
9
}
pinned_init::init_from_closure::<[core::mem::maybe_uninit::MaybeUninit<u8>; 64usize], core::convert::Infallible, <alloc_fail::ring_buf::RingBuffer<u8, 64usize>>::new::{closure#0}::{closure#1}>
Line
Count
Source
1074
1
pub const unsafe fn init_from_closure<T: ?Sized, E>(
1075
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1076
1
) -> impl Init<T, E> {
1077
1
    __internal::InitClosure(f, PhantomData)
1078
1
}
pinned_init::init_from_closure::<alloc_fail::ring_buf::BigStruct, core::convert::Infallible, alloc_fail::ring_buf::with_big_struct::{closure#3}>
Line
Count
Source
1074
1
pub const unsafe fn init_from_closure<T: ?Sized, E>(
1075
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1076
1
) -> impl Init<T, E> {
1077
1
    __internal::InitClosure(f, PhantomData)
1078
1
}
pinned_init::init_from_closure::<alloc_fail::ring_buf::BigStruct, core::alloc::AllocError, <alloc::boxed::Box<alloc_fail::ring_buf::BigStruct> as pinned_init::InPlaceInit<alloc_fail::ring_buf::BigStruct>>::init<pinned_init::__internal::InitClosure<alloc_fail::ring_buf::big_struct::{closure#3}, alloc_fail::ring_buf::BigStruct, core::convert::Infallible>>::{closure#0}>
Line
Count
Source
1074
1
pub const unsafe fn init_from_closure<T: ?Sized, E>(
1075
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1076
1
) -> impl Init<T, E> {
1077
1
    __internal::InitClosure(f, PhantomData)
1078
1
}
pinned_init::init_from_closure::<[u8; 1048576usize], core::convert::Infallible, pinned_init::zeroed<[u8; 1048576usize], core::convert::Infallible>::{closure#0}>
Line
Count
Source
1074
65
pub const unsafe fn init_from_closure<T: ?Sized, E>(
1075
65
    f: impl FnOnce(*mut T) -> Result<(), E>,
1076
65
) -> impl Init<T, E> {
1077
65
    __internal::InitClosure(f, PhantomData)
1078
65
}
Unexecuted instantiation: pinned_init::init_from_closure::<_, _, _>
pinned_init::init_from_closure::<pinned_init::__internal::stack_init_reuse::Foo, core::convert::Infallible, pinned_init::__internal::stack_init_reuse::{closure#3}>
Line
Count
Source
1074
1
pub const unsafe fn init_from_closure<T: ?Sized, E>(
1075
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1076
1
) -> impl Init<T, E> {
1077
1
    __internal::InitClosure(f, PhantomData)
1078
1
}
pinned_init::init_from_closure::<pinned_init::__internal::stack_init_reuse::Foo, core::convert::Infallible, pinned_init::__internal::stack_init_reuse::{closure#1}>
Line
Count
Source
1074
1
pub const unsafe fn init_from_closure<T: ?Sized, E>(
1075
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1076
1
) -> impl Init<T, E> {
1077
1
    __internal::InitClosure(f, PhantomData)
1078
1
}
pinned_init::init_from_closure::<ring_buf::BigStruct, core::alloc::AllocError, <alloc::boxed::Box<ring_buf::BigStruct> as pinned_init::InPlaceInit<ring_buf::BigStruct>>::init<pinned_init::__internal::InitClosure<ring_buf::big_struct::{closure#3}, ring_buf::BigStruct, core::convert::Infallible>>::{closure#0}>
Line
Count
Source
1074
1
pub const unsafe fn init_from_closure<T: ?Sized, E>(
1075
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1076
1
) -> impl Init<T, E> {
1077
1
    __internal::InitClosure(f, PhantomData)
1078
1
}
pinned_init::init_from_closure::<ring_buf::BigStruct, core::convert::Infallible, <ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>::pop_no_stack::{closure#0}>
Line
Count
Source
1074
63
pub const unsafe fn init_from_closure<T: ?Sized, E>(
1075
63
    f: impl FnOnce(*mut T) -> Result<(), E>,
1076
63
) -> impl Init<T, E> {
1077
63
    __internal::InitClosure(f, PhantomData)
1078
63
}
pinned_init::init_from_closure::<ring_buf::BigStruct, core::convert::Infallible, ring_buf::with_big_struct::{closure#3}>
Line
Count
Source
1074
1
pub const unsafe fn init_from_closure<T: ?Sized, E>(
1075
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1076
1
) -> impl Init<T, E> {
1077
1
    __internal::InitClosure(f, PhantomData)
1078
1
}
pinned_init::init_from_closure::<ring_buf::BigStruct, core::convert::Infallible, ring_buf::with_big_struct::{closure#1}>
Line
Count
Source
1074
63
pub const unsafe fn init_from_closure<T: ?Sized, E>(
1075
63
    f: impl FnOnce(*mut T) -> Result<(), E>,
1076
63
) -> impl Init<T, E> {
1077
63
    __internal::InitClosure(f, PhantomData)
1078
63
}
pinned_init::init_from_closure::<[u8; 1048576usize], core::convert::Infallible, pinned_init::zeroed<[u8; 1048576usize], core::convert::Infallible>::{closure#0}>
Line
Count
Source
1074
65
pub const unsafe fn init_from_closure<T: ?Sized, E>(
1075
65
    f: impl FnOnce(*mut T) -> Result<(), E>,
1076
65
) -> impl Init<T, E> {
1077
65
    __internal::InitClosure(f, PhantomData)
1078
65
}
pinned_init::init_from_closure::<[core::mem::maybe_uninit::MaybeUninit<ring_buf::EvenU64>; 4usize], core::convert::Infallible, <ring_buf::RingBuffer<ring_buf::EvenU64, 4usize>>::new::{closure#0}::{closure#1}>
Line
Count
Source
1074
1
pub const unsafe fn init_from_closure<T: ?Sized, E>(
1075
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1076
1
) -> impl Init<T, E> {
1077
1
    __internal::InitClosure(f, PhantomData)
1078
1
}
pinned_init::init_from_closure::<[core::mem::maybe_uninit::MaybeUninit<ring_buf::BigStruct>; 64usize], core::convert::Infallible, <ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>::new::{closure#0}::{closure#1}>
Line
Count
Source
1074
1
pub const unsafe fn init_from_closure<T: ?Sized, E>(
1075
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1076
1
) -> impl Init<T, E> {
1077
1
    __internal::InitClosure(f, PhantomData)
1078
1
}
pinned_init::init_from_closure::<ring_buf::EvenU64, core::alloc::AllocError, <ring_buf::EvenU64>::new2::{closure#1}>
Line
Count
Source
1074
4
pub const unsafe fn init_from_closure<T: ?Sized, E>(
1075
4
    f: impl FnOnce(*mut T) -> Result<(), E>,
1076
4
) -> impl Init<T, E> {
1077
4
    __internal::InitClosure(f, PhantomData)
1078
4
}
pinned_init::init_from_closure::<core::mem::maybe_uninit::MaybeUninit<u8>, core::convert::Infallible, pinned_init::uninit<u8, core::convert::Infallible>::{closure#0}>
Line
Count
Source
1074
63
pub const unsafe fn init_from_closure<T: ?Sized, E>(
1075
63
    f: impl FnOnce(*mut T) -> Result<(), E>,
1076
63
) -> impl Init<T, E> {
1077
63
    __internal::InitClosure(f, PhantomData)
1078
63
}
pinned_init::init_from_closure::<core::mem::maybe_uninit::MaybeUninit<u8>, core::convert::Infallible, pinned_init::zeroed<core::mem::maybe_uninit::MaybeUninit<u8>, core::convert::Infallible>::{closure#0}>
Line
Count
Source
1074
2
pub const unsafe fn init_from_closure<T: ?Sized, E>(
1075
2
    f: impl FnOnce(*mut T) -> Result<(), E>,
1076
2
) -> impl Init<T, E> {
1077
2
    __internal::InitClosure(f, PhantomData)
1078
2
}
pinned_init::init_from_closure::<u8, core::convert::Infallible, <ring_buf::RingBuffer<u8, 64usize>>::pop_no_stack::{closure#0}>
Line
Count
Source
1074
63
pub const unsafe fn init_from_closure<T: ?Sized, E>(
1075
63
    f: impl FnOnce(*mut T) -> Result<(), E>,
1076
63
) -> impl Init<T, E> {
1077
63
    __internal::InitClosure(f, PhantomData)
1078
63
}
pinned_init::init_from_closure::<[core::mem::maybe_uninit::MaybeUninit<u8>; 64usize], core::convert::Infallible, <ring_buf::RingBuffer<u8, 64usize>>::new::{closure#0}::{closure#1}>
Line
Count
Source
1074
1
pub const unsafe fn init_from_closure<T: ?Sized, E>(
1075
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1076
1
) -> impl Init<T, E> {
1077
1
    __internal::InitClosure(f, PhantomData)
1078
1
}
pinned_init::init_from_closure::<ring_buf::EvenU64, (), <ring_buf::EvenU64>::new::{closure#1}>
Line
Count
Source
1074
9
pub const unsafe fn init_from_closure<T: ?Sized, E>(
1075
9
    f: impl FnOnce(*mut T) -> Result<(), E>,
1076
9
) -> impl Init<T, E> {
1077
9
    __internal::InitClosure(f, PhantomData)
1078
9
}
pinned_init::init_from_closure::<ring_buf::BigStruct, core::convert::Infallible, ring_buf::big_struct::{closure#1}>
Line
Count
Source
1074
1
pub const unsafe fn init_from_closure<T: ?Sized, E>(
1075
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1076
1
) -> impl Init<T, E> {
1077
1
    __internal::InitClosure(f, PhantomData)
1078
1
}
pinned_init::init_from_closure::<ring_buf::BigStruct, core::alloc::AllocError, <alloc::sync::Arc<ring_buf::BigStruct> as pinned_init::InPlaceInit<ring_buf::BigStruct>>::init<pinned_init::__internal::InitClosure<ring_buf::big_struct::{closure#1}, ring_buf::BigStruct, core::convert::Infallible>>::{closure#0}>
Line
Count
Source
1074
1
pub const unsafe fn init_from_closure<T: ?Sized, E>(
1075
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1076
1
) -> impl Init<T, E> {
1077
1
    __internal::InitClosure(f, PhantomData)
1078
1
}
pinned_init::init_from_closure::<ring_buf::BigStruct, core::convert::Infallible, ring_buf::big_struct::{closure#3}>
Line
Count
Source
1074
1
pub const unsafe fn init_from_closure<T: ?Sized, E>(
1075
1
    f: impl FnOnce(*mut T) -> Result<(), E>,
1076
1
) -> impl Init<T, E> {
1077
1
    __internal::InitClosure(f, PhantomData)
1078
1
}
1079
1080
/// An initializer that leaves the memory uninitialized.
1081
///
1082
/// The initializer is a no-op. The `slot` memory is not changed.
1083
#[inline]
1084
126
pub fn uninit<T, E>() -> impl Init<MaybeUninit<T>, E> {
1085
126
    // SAFETY: The memory is allowed to be uninitialized.
1086
126
    unsafe { init_from_closure(|_| Ok(())) }
pinned_init::uninit::<u8, core::convert::Infallible>::{closure#0}
Line
Count
Source
1086
63
    unsafe { init_from_closure(|_| Ok(())) }
Unexecuted instantiation: pinned_init::uninit::<_, _>::{closure#0}
Unexecuted instantiation: pinned_init::uninit::<_, _>::{closure#0}
pinned_init::uninit::<u8, core::convert::Infallible>::{closure#0}
Line
Count
Source
1086
63
    unsafe { init_from_closure(|_| Ok(())) }
1087
126
}
pinned_init::uninit::<u8, core::convert::Infallible>
Line
Count
Source
1084
63
pub fn uninit<T, E>() -> impl Init<MaybeUninit<T>, E> {
1085
63
    // SAFETY: The memory is allowed to be uninitialized.
1086
63
    unsafe { init_from_closure(|_| Ok(())) }
1087
63
}
Unexecuted instantiation: pinned_init::uninit::<_, _>
Unexecuted instantiation: pinned_init::uninit::<_, _>
pinned_init::uninit::<u8, core::convert::Infallible>
Line
Count
Source
1084
63
pub fn uninit<T, E>() -> impl Init<MaybeUninit<T>, E> {
1085
63
    // SAFETY: The memory is allowed to be uninitialized.
1086
63
    unsafe { init_from_closure(|_| Ok(())) }
1087
63
}
1088
1089
/// Initializes an array by initializing each element via the provided initializer.
1090
///
1091
/// # Examples
1092
///
1093
/// ```rust
1094
/// # use pinned_init::*;
1095
/// let array: Box<[usize; 1000]>= Box::init(init_array_from_fn(|i| i)).unwrap();
1096
/// println!("{array:?}");
1097
/// ```
1098
0
pub fn init_array_from_fn<I, const N: usize, T, E>(
1099
0
    mut make_init: impl FnMut(usize) -> I,
1100
0
) -> impl Init<[T; N], E>
1101
0
where
1102
0
    I: Init<T, E>,
1103
0
{
1104
0
    let init = move |slot: *mut [T; N]| {
1105
0
        let slot = slot.cast::<T>();
1106
0
        for i in 0..N {
1107
0
            let init = make_init(i);
1108
0
            // SAFETY: since 0 <= `i` < N, it is still in bounds of `[T; N]`.
1109
0
            let ptr = unsafe { slot.add(i) };
1110
0
            // SAFETY: The pointer is derived from `slot` and thus satisfies the `__init`
1111
0
            // requirements.
1112
0
            match unsafe { init.__init(ptr) } {
1113
0
                Ok(()) => {}
1114
0
                Err(e) => {
1115
0
                    // We now free every element that has been initialized before:
1116
0
                    // SAFETY: The loop initialized exactly the values from 0..i and since we
1117
0
                    // return `Err` below, the caller will consider the memory at `slot` as
1118
0
                    // uninitialized.
1119
0
                    unsafe { ptr::drop_in_place(ptr::slice_from_raw_parts_mut(slot, i)) };
1120
0
                    return Err(e);
1121
                }
1122
            }
1123
        }
1124
0
        Ok(())
1125
0
    };
Unexecuted instantiation: pinned_init::init_array_from_fn::<_, _, _, _, _>::{closure#0}
Unexecuted instantiation: pinned_init::init_array_from_fn::<_, _, _, _, _>::{closure#0}
1126
    // SAFETY: The initializer above initializes every element of the array. On failure it drops
1127
    // any initialized elements and returns `Err`.
1128
0
    unsafe { init_from_closure(init) }
1129
0
}
Unexecuted instantiation: pinned_init::init_array_from_fn::<_, _, _, _, _>
Unexecuted instantiation: pinned_init::init_array_from_fn::<_, _, _, _, _>
1130
1131
/// Initializes an array by initializing each element via the provided initializer.
1132
///
1133
/// # Examples
1134
///
1135
/// ```rust
1136
/// # #![allow(clippy::disallowed_names, clippy::new_ret_no_self)]
1137
/// # #![feature(allocator_api, no_coverage)]
1138
/// # use pinned_init::*;
1139
/// # use core::pin::Pin;
1140
/// # #[path = "../examples/mutex.rs"] mod mutex; use mutex::*;
1141
/// # extern crate alloc;
1142
/// # use alloc::sync::Arc;
1143
/// # use core::convert::Infallible;
1144
/// let array: Pin<Arc<[CMutex<usize>; 1000]>>=
1145
///     Arc::pin_init(pin_init_array_from_fn(|i| CMutex::new(i))).unwrap();
1146
/// println!("{array:?}");
1147
/// ```
1148
0
pub fn pin_init_array_from_fn<I, const N: usize, T, E>(
1149
0
    mut make_init: impl FnMut(usize) -> I,
1150
0
) -> impl PinInit<[T; N], E>
1151
0
where
1152
0
    I: PinInit<T, E>,
1153
0
{
1154
0
    let init = move |slot: *mut [T; N]| {
1155
0
        let slot = slot.cast::<T>();
1156
0
        for i in 0..N {
1157
0
            let init = make_init(i);
1158
0
            // SAFETY: since 0 <= `i` < N, it is still in bounds of `[T; N]`.
1159
0
            let ptr = unsafe { slot.add(i) };
1160
0
            // SAFETY: The pointer is derived from `slot` and thus satisfies the `__pinned_init`
1161
0
            // requirements.
1162
0
            match unsafe { init.__pinned_init(ptr) } {
1163
0
                Ok(()) => {}
1164
0
                Err(e) => {
1165
0
                    // We now have to free every element that has been initialized before, since we
1166
0
                    // have to abide by the drop guarantee.
1167
0
                    // SAFETY: The loop initialized exactly the values from 0..i and since we
1168
0
                    // return `Err` below, the caller will consider the memory at `slot` as
1169
0
                    // uninitialized.
1170
0
                    unsafe { ptr::drop_in_place(ptr::slice_from_raw_parts_mut(slot, i)) };
1171
0
                    return Err(e);
1172
                }
1173
            }
1174
        }
1175
0
        Ok(())
1176
0
    };
Unexecuted instantiation: pinned_init::pin_init_array_from_fn::<_, _, _, _, _>::{closure#0}
Unexecuted instantiation: pinned_init::pin_init_array_from_fn::<_, _, _, _, _>::{closure#0}
1177
    // SAFETY: The initializer above initializes every element of the array. On failure it drops
1178
    // any initialized elements and returns `Err`.
1179
0
    unsafe { pin_init_from_closure(init) }
1180
0
}
Unexecuted instantiation: pinned_init::pin_init_array_from_fn::<_, _, _, _, _>
Unexecuted instantiation: pinned_init::pin_init_array_from_fn::<_, _, _, _, _>
1181
1182
// SAFETY: Every type can be initialized by-value.
1183
unsafe impl<T, E> Init<T, E> for T {
1184
140
    unsafe fn __init(self, slot: *mut T) -> Result<(), E> {
1185
140
        unsafe { slot.write(self) };
1186
140
        Ok(())
1187
140
    }
<u8 as pinned_init::Init<u8>>::__init
Line
Count
Source
1184
68
    unsafe fn __init(self, slot: *mut T) -> Result<(), E> {
1185
68
        unsafe { slot.write(self) };
1186
68
        Ok(())
1187
68
    }
<usize as pinned_init::Init<usize>>::__init
Line
Count
Source
1184
1
    unsafe fn __init(self, slot: *mut T) -> Result<(), E> {
1185
1
        unsafe { slot.write(self) };
1186
1
        Ok(())
1187
1
    }
Unexecuted instantiation: <_ as pinned_init::Init<_, _>>::__init
Unexecuted instantiation: <_ as pinned_init::Init<_, _>>::__init
<u8 as pinned_init::Init<u8>>::__init
Line
Count
Source
1184
68
    unsafe fn __init(self, slot: *mut T) -> Result<(), E> {
1185
68
        unsafe { slot.write(self) };
1186
68
        Ok(())
1187
68
    }
<usize as pinned_init::Init<usize>>::__init
Line
Count
Source
1184
1
    unsafe fn __init(self, slot: *mut T) -> Result<(), E> {
1185
1
        unsafe { slot.write(self) };
1186
1
        Ok(())
1187
1
    }
<usize as pinned_init::Init<usize>>::__init
Line
Count
Source
1184
1
    unsafe fn __init(self, slot: *mut T) -> Result<(), E> {
1185
1
        unsafe { slot.write(self) };
1186
1
        Ok(())
1187
1
    }
<usize as pinned_init::Init<usize>>::__init
Line
Count
Source
1184
1
    unsafe fn __init(self, slot: *mut T) -> Result<(), E> {
1185
1
        unsafe { slot.write(self) };
1186
1
        Ok(())
1187
1
    }
1188
}
1189
// SAFETY: Every type can be initialized by-value. `__pinned_init` calls `__init`.
1190
unsafe impl<T, E> PinInit<T, E> for T {
1191
4
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
1192
4
        unsafe { self.__init(slot) }
1193
4
    }
<usize as pinned_init::PinInit<usize>>::__pinned_init
Line
Count
Source
1191
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
1192
1
        unsafe { self.__init(slot) }
1193
1
    }
Unexecuted instantiation: <_ as pinned_init::PinInit<_, _>>::__pinned_init
Unexecuted instantiation: <_ as pinned_init::PinInit<_, _>>::__pinned_init
<usize as pinned_init::PinInit<usize>>::__pinned_init
Line
Count
Source
1191
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
1192
1
        unsafe { self.__init(slot) }
1193
1
    }
<usize as pinned_init::PinInit<usize>>::__pinned_init
Line
Count
Source
1191
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
1192
1
        unsafe { self.__init(slot) }
1193
1
    }
<usize as pinned_init::PinInit<usize>>::__pinned_init
Line
Count
Source
1191
1
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
1192
1
        unsafe { self.__init(slot) }
1193
1
    }
1194
}
1195
1196
/// Smart pointer that can initialize memory in-place.
1197
pub trait InPlaceInit<T>: Sized {
1198
    /// Use the given pin-initializer to pin-initialize a `T` inside of a new smart pointer of this
1199
    /// type.
1200
    ///
1201
    /// If `T: !Unpin` it will not be able to move afterwards.
1202
    fn try_pin_init<E>(init: impl PinInit<T, E>) -> Result<Pin<Self>, E>
1203
    where
1204
        E: From<AllocError>;
1205
1206
    /// Use the given pin-initializer to pin-initialize a `T` inside of a new smart pointer of this
1207
    /// type.
1208
    ///
1209
    /// If `T: !Unpin` it will not be able to move afterwards.
1210
20
    fn pin_init(init: impl PinInit<T>) -> Result<Pin<Self>, AllocError> {
1211
20
        // SAFETY: We delegate to `init` and only change the error type.
1212
20
        let init = unsafe {
1213
20
            pin_init_from_closure(|slot| {
1214
18
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
20
            })
<alloc::sync::Arc<alloc_fail::ring_buf::mutex::CMutex<usize>> as pinned_init::InPlaceInit<alloc_fail::ring_buf::mutex::CMutex<usize>>>::pin_init::<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::mutex::CMutex<usize>>::new<usize>::{closure#1}, alloc_fail::ring_buf::mutex::CMutex<usize>, core::convert::Infallible>>::{closure#0}
Line
Count
Source
1213
1
            pin_init_from_closure(|slot| {
1214
1
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
1
            })
<alloc::boxed::Box<alloc_fail::ring_buf::mutex::linked_list::ListHead> as pinned_init::InPlaceInit<alloc_fail::ring_buf::mutex::linked_list::ListHead>>::pin_init::<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::mutex::linked_list::ListHead>::new::{closure#1}, alloc_fail::ring_buf::mutex::linked_list::ListHead, core::convert::Infallible>>::{closure#0}
Line
Count
Source
1213
1
            pin_init_from_closure(|slot| {
1214
1
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
1
            })
<alloc::boxed::Box<alloc_fail::ring_buf::mutex::linked_list::ListHead> as pinned_init::InPlaceInit<alloc_fail::ring_buf::mutex::linked_list::ListHead>>::pin_init::<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::mutex::linked_list::ListHead>::insert_next::{closure#1}, alloc_fail::ring_buf::mutex::linked_list::ListHead, core::convert::Infallible>>::{closure#0}
Line
Count
Source
1213
1
            pin_init_from_closure(|slot| {
1214
1
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
1
            })
Unexecuted instantiation: <alloc::sync::Arc<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>> as pinned_init::InPlaceInit<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>>>::pin_init::<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>>::new::{closure#1}, alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>, core::convert::Infallible>>::{closure#0}
<alloc::boxed::Box<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::EvenU64, 4usize>> as pinned_init::InPlaceInit<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::EvenU64, 4usize>>>::pin_init::<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::EvenU64, 4usize>>::new::{closure#1}, alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::EvenU64, 4usize>, core::convert::Infallible>>::{closure#0}
Line
Count
Source
1213
1
            pin_init_from_closure(|slot| {
1214
1
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
1
            })
<alloc::sync::Arc<alloc_fail::ring_buf::mutex::CMutex<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>> as pinned_init::InPlaceInit<alloc_fail::ring_buf::mutex::CMutex<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>>>::pin_init::<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::mutex::CMutex<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>>::new<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>::new::{closure#1}, alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>, core::convert::Infallible>>::{closure#1}, alloc_fail::ring_buf::mutex::CMutex<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>, core::convert::Infallible>>::{closure#0}
Line
Count
Source
1213
1
            pin_init_from_closure(|slot| {
1214
1
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
1
            })
Unexecuted instantiation: <alloc::boxed::Box<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>> as pinned_init::InPlaceInit<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>>>::pin_init::<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>>::new::{closure#1}, alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>, core::convert::Infallible>>::{closure#0}
Unexecuted instantiation: <_ as pinned_init::InPlaceInit<_>>::pin_init::<_>::{closure#0}
Unexecuted instantiation: <_ as pinned_init::InPlaceInit<_>>::pin_init::<_>::{closure#0}
<alloc::boxed::Box<ring_buf::mutex::linked_list::ListHead> as pinned_init::InPlaceInit<ring_buf::mutex::linked_list::ListHead>>::pin_init::<pinned_init::__internal::InitClosure<<ring_buf::mutex::linked_list::ListHead>::insert_next::{closure#1}, ring_buf::mutex::linked_list::ListHead, core::convert::Infallible>>::{closure#0}
Line
Count
Source
1213
1
            pin_init_from_closure(|slot| {
1214
1
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
1
            })
<alloc::sync::Arc<ring_buf::mutex::CMutex<usize>> as pinned_init::InPlaceInit<ring_buf::mutex::CMutex<usize>>>::pin_init::<pinned_init::__internal::InitClosure<<ring_buf::mutex::CMutex<usize>>::new<usize>::{closure#1}, ring_buf::mutex::CMutex<usize>, core::convert::Infallible>>::{closure#0}
Line
Count
Source
1213
1
            pin_init_from_closure(|slot| {
1214
1
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
1
            })
<alloc::boxed::Box<ring_buf::RingBuffer<ring_buf::EvenU64, 4usize>> as pinned_init::InPlaceInit<ring_buf::RingBuffer<ring_buf::EvenU64, 4usize>>>::pin_init::<pinned_init::__internal::InitClosure<<ring_buf::RingBuffer<ring_buf::EvenU64, 4usize>>::new::{closure#1}, ring_buf::RingBuffer<ring_buf::EvenU64, 4usize>, core::convert::Infallible>>::{closure#0}
Line
Count
Source
1213
1
            pin_init_from_closure(|slot| {
1214
1
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
1
            })
<alloc::boxed::Box<ring_buf::mutex::linked_list::ListHead> as pinned_init::InPlaceInit<ring_buf::mutex::linked_list::ListHead>>::pin_init::<pinned_init::__internal::InitClosure<<ring_buf::mutex::linked_list::ListHead>::new::{closure#1}, ring_buf::mutex::linked_list::ListHead, core::convert::Infallible>>::{closure#0}
Line
Count
Source
1213
1
            pin_init_from_closure(|slot| {
1214
1
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
1
            })
<alloc::sync::Arc<ring_buf::mutex::CMutex<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>> as pinned_init::InPlaceInit<ring_buf::mutex::CMutex<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>>>::pin_init::<pinned_init::__internal::InitClosure<<ring_buf::mutex::CMutex<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>>::new<pinned_init::__internal::InitClosure<<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>::new::{closure#1}, ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>, core::convert::Infallible>>::{closure#1}, ring_buf::mutex::CMutex<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>, core::convert::Infallible>>::{closure#0}
Line
Count
Source
1213
1
            pin_init_from_closure(|slot| {
1214
1
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
1
            })
<alloc::boxed::Box<linked_list::ListHead> as pinned_init::InPlaceInit<linked_list::ListHead>>::pin_init::<pinned_init::__internal::InitClosure<<linked_list::ListHead>::insert_next::{closure#1}, linked_list::ListHead, core::convert::Infallible>>::{closure#0}
Line
Count
Source
1213
1
            pin_init_from_closure(|slot| {
1214
1
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
1
            })
<alloc::boxed::Box<linked_list::ListHead> as pinned_init::InPlaceInit<linked_list::ListHead>>::pin_init::<pinned_init::__internal::InitClosure<<linked_list::ListHead>::new::{closure#1}, linked_list::ListHead, core::convert::Infallible>>::{closure#0}
Line
Count
Source
1213
1
            pin_init_from_closure(|slot| {
1214
1
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
1
            })
<alloc::boxed::Box<mutex::linked_list::ListHead> as pinned_init::InPlaceInit<mutex::linked_list::ListHead>>::pin_init::<pinned_init::__internal::InitClosure<<mutex::linked_list::ListHead>::insert_next::{closure#1}, mutex::linked_list::ListHead, core::convert::Infallible>>::{closure#0}
Line
Count
Source
1213
1
            pin_init_from_closure(|slot| {
1214
1
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
1
            })
<alloc::boxed::Box<mutex::linked_list::ListHead> as pinned_init::InPlaceInit<mutex::linked_list::ListHead>>::pin_init::<pinned_init::__internal::InitClosure<<mutex::linked_list::ListHead>::new::{closure#1}, mutex::linked_list::ListHead, core::convert::Infallible>>::{closure#0}
Line
Count
Source
1213
1
            pin_init_from_closure(|slot| {
1214
1
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
1
            })
<alloc::sync::Arc<mutex::CMutex<usize>> as pinned_init::InPlaceInit<mutex::CMutex<usize>>>::pin_init::<pinned_init::__internal::InitClosure<<mutex::CMutex<usize>>::new<usize>::{closure#1}, mutex::CMutex<usize>, core::convert::Infallible>>::{closure#0}
Line
Count
Source
1213
1
            pin_init_from_closure(|slot| {
1214
1
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
1
            })
<alloc::boxed::Box<static_init::mutex::linked_list::ListHead> as pinned_init::InPlaceInit<static_init::mutex::linked_list::ListHead>>::pin_init::<pinned_init::__internal::InitClosure<<static_init::mutex::linked_list::ListHead>::insert_next::{closure#1}, static_init::mutex::linked_list::ListHead, core::convert::Infallible>>::{closure#0}
Line
Count
Source
1213
1
            pin_init_from_closure(|slot| {
1214
1
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
1
            })
<alloc::sync::Arc<static_init::mutex::CMutex<usize>> as pinned_init::InPlaceInit<static_init::mutex::CMutex<usize>>>::pin_init::<pinned_init::__internal::InitClosure<<static_init::mutex::CMutex<usize>>::new<usize>::{closure#1}, static_init::mutex::CMutex<usize>, core::convert::Infallible>>::{closure#0}
Line
Count
Source
1213
1
            pin_init_from_closure(|slot| {
1214
1
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
1
            })
<alloc::boxed::Box<static_init::mutex::linked_list::ListHead> as pinned_init::InPlaceInit<static_init::mutex::linked_list::ListHead>>::pin_init::<pinned_init::__internal::InitClosure<<static_init::mutex::linked_list::ListHead>::new::{closure#1}, static_init::mutex::linked_list::ListHead, core::convert::Infallible>>::{closure#0}
Line
Count
Source
1213
1
            pin_init_from_closure(|slot| {
1214
1
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
1
            })
1216
20
        };
1217
20
        Self::try_pin_init(init)
1218
20
    }
<alloc::sync::Arc<alloc_fail::ring_buf::mutex::CMutex<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>> as pinned_init::InPlaceInit<alloc_fail::ring_buf::mutex::CMutex<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>>>::pin_init::<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::mutex::CMutex<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>>::new<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>::new::{closure#1}, alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>, core::convert::Infallible>>::{closure#1}, alloc_fail::ring_buf::mutex::CMutex<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>, core::convert::Infallible>>
Line
Count
Source
1210
1
    fn pin_init(init: impl PinInit<T>) -> Result<Pin<Self>, AllocError> {
1211
1
        // SAFETY: We delegate to `init` and only change the error type.
1212
1
        let init = unsafe {
1213
1
            pin_init_from_closure(|slot| {
1214
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
1
            })
1216
1
        };
1217
1
        Self::try_pin_init(init)
1218
1
    }
<alloc::sync::Arc<alloc_fail::ring_buf::mutex::CMutex<usize>> as pinned_init::InPlaceInit<alloc_fail::ring_buf::mutex::CMutex<usize>>>::pin_init::<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::mutex::CMutex<usize>>::new<usize>::{closure#1}, alloc_fail::ring_buf::mutex::CMutex<usize>, core::convert::Infallible>>
Line
Count
Source
1210
1
    fn pin_init(init: impl PinInit<T>) -> Result<Pin<Self>, AllocError> {
1211
1
        // SAFETY: We delegate to `init` and only change the error type.
1212
1
        let init = unsafe {
1213
1
            pin_init_from_closure(|slot| {
1214
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
1
            })
1216
1
        };
1217
1
        Self::try_pin_init(init)
1218
1
    }
<alloc::sync::Arc<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>> as pinned_init::InPlaceInit<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>>>::pin_init::<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>>::new::{closure#1}, alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>, core::convert::Infallible>>
Line
Count
Source
1210
1
    fn pin_init(init: impl PinInit<T>) -> Result<Pin<Self>, AllocError> {
1211
1
        // SAFETY: We delegate to `init` and only change the error type.
1212
1
        let init = unsafe {
1213
1
            pin_init_from_closure(|slot| {
1214
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
1
            })
1216
1
        };
1217
1
        Self::try_pin_init(init)
1218
1
    }
<alloc::boxed::Box<alloc_fail::ring_buf::mutex::linked_list::ListHead> as pinned_init::InPlaceInit<alloc_fail::ring_buf::mutex::linked_list::ListHead>>::pin_init::<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::mutex::linked_list::ListHead>::new::{closure#1}, alloc_fail::ring_buf::mutex::linked_list::ListHead, core::convert::Infallible>>
Line
Count
Source
1210
1
    fn pin_init(init: impl PinInit<T>) -> Result<Pin<Self>, AllocError> {
1211
1
        // SAFETY: We delegate to `init` and only change the error type.
1212
1
        let init = unsafe {
1213
1
            pin_init_from_closure(|slot| {
1214
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
1
            })
1216
1
        };
1217
1
        Self::try_pin_init(init)
1218
1
    }
<alloc::boxed::Box<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::EvenU64, 4usize>> as pinned_init::InPlaceInit<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::EvenU64, 4usize>>>::pin_init::<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::EvenU64, 4usize>>::new::{closure#1}, alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::EvenU64, 4usize>, core::convert::Infallible>>
Line
Count
Source
1210
1
    fn pin_init(init: impl PinInit<T>) -> Result<Pin<Self>, AllocError> {
1211
1
        // SAFETY: We delegate to `init` and only change the error type.
1212
1
        let init = unsafe {
1213
1
            pin_init_from_closure(|slot| {
1214
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
1
            })
1216
1
        };
1217
1
        Self::try_pin_init(init)
1218
1
    }
<alloc::boxed::Box<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>> as pinned_init::InPlaceInit<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>>>::pin_init::<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>>::new::{closure#1}, alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>, core::convert::Infallible>>
Line
Count
Source
1210
1
    fn pin_init(init: impl PinInit<T>) -> Result<Pin<Self>, AllocError> {
1211
1
        // SAFETY: We delegate to `init` and only change the error type.
1212
1
        let init = unsafe {
1213
1
            pin_init_from_closure(|slot| {
1214
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
1
            })
1216
1
        };
1217
1
        Self::try_pin_init(init)
1218
1
    }
<alloc::boxed::Box<alloc_fail::ring_buf::mutex::linked_list::ListHead> as pinned_init::InPlaceInit<alloc_fail::ring_buf::mutex::linked_list::ListHead>>::pin_init::<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::mutex::linked_list::ListHead>::insert_next::{closure#1}, alloc_fail::ring_buf::mutex::linked_list::ListHead, core::convert::Infallible>>
Line
Count
Source
1210
1
    fn pin_init(init: impl PinInit<T>) -> Result<Pin<Self>, AllocError> {
1211
1
        // SAFETY: We delegate to `init` and only change the error type.
1212
1
        let init = unsafe {
1213
1
            pin_init_from_closure(|slot| {
1214
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
1
            })
1216
1
        };
1217
1
        Self::try_pin_init(init)
1218
1
    }
Unexecuted instantiation: <_ as pinned_init::InPlaceInit<_>>::pin_init::<_>
Unexecuted instantiation: <_ as pinned_init::InPlaceInit<_>>::pin_init::<_>
<alloc::boxed::Box<ring_buf::mutex::linked_list::ListHead> as pinned_init::InPlaceInit<ring_buf::mutex::linked_list::ListHead>>::pin_init::<pinned_init::__internal::InitClosure<<ring_buf::mutex::linked_list::ListHead>::insert_next::{closure#1}, ring_buf::mutex::linked_list::ListHead, core::convert::Infallible>>
Line
Count
Source
1210
1
    fn pin_init(init: impl PinInit<T>) -> Result<Pin<Self>, AllocError> {
1211
1
        // SAFETY: We delegate to `init` and only change the error type.
1212
1
        let init = unsafe {
1213
1
            pin_init_from_closure(|slot| {
1214
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
1
            })
1216
1
        };
1217
1
        Self::try_pin_init(init)
1218
1
    }
<alloc::boxed::Box<ring_buf::mutex::linked_list::ListHead> as pinned_init::InPlaceInit<ring_buf::mutex::linked_list::ListHead>>::pin_init::<pinned_init::__internal::InitClosure<<ring_buf::mutex::linked_list::ListHead>::new::{closure#1}, ring_buf::mutex::linked_list::ListHead, core::convert::Infallible>>
Line
Count
Source
1210
1
    fn pin_init(init: impl PinInit<T>) -> Result<Pin<Self>, AllocError> {
1211
1
        // SAFETY: We delegate to `init` and only change the error type.
1212
1
        let init = unsafe {
1213
1
            pin_init_from_closure(|slot| {
1214
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
1
            })
1216
1
        };
1217
1
        Self::try_pin_init(init)
1218
1
    }
<alloc::boxed::Box<ring_buf::RingBuffer<ring_buf::EvenU64, 4usize>> as pinned_init::InPlaceInit<ring_buf::RingBuffer<ring_buf::EvenU64, 4usize>>>::pin_init::<pinned_init::__internal::InitClosure<<ring_buf::RingBuffer<ring_buf::EvenU64, 4usize>>::new::{closure#1}, ring_buf::RingBuffer<ring_buf::EvenU64, 4usize>, core::convert::Infallible>>
Line
Count
Source
1210
1
    fn pin_init(init: impl PinInit<T>) -> Result<Pin<Self>, AllocError> {
1211
1
        // SAFETY: We delegate to `init` and only change the error type.
1212
1
        let init = unsafe {
1213
1
            pin_init_from_closure(|slot| {
1214
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
1
            })
1216
1
        };
1217
1
        Self::try_pin_init(init)
1218
1
    }
<alloc::sync::Arc<ring_buf::mutex::CMutex<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>> as pinned_init::InPlaceInit<ring_buf::mutex::CMutex<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>>>::pin_init::<pinned_init::__internal::InitClosure<<ring_buf::mutex::CMutex<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>>::new<pinned_init::__internal::InitClosure<<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>::new::{closure#1}, ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>, core::convert::Infallible>>::{closure#1}, ring_buf::mutex::CMutex<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>, core::convert::Infallible>>
Line
Count
Source
1210
1
    fn pin_init(init: impl PinInit<T>) -> Result<Pin<Self>, AllocError> {
1211
1
        // SAFETY: We delegate to `init` and only change the error type.
1212
1
        let init = unsafe {
1213
1
            pin_init_from_closure(|slot| {
1214
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
1
            })
1216
1
        };
1217
1
        Self::try_pin_init(init)
1218
1
    }
<alloc::sync::Arc<ring_buf::mutex::CMutex<usize>> as pinned_init::InPlaceInit<ring_buf::mutex::CMutex<usize>>>::pin_init::<pinned_init::__internal::InitClosure<<ring_buf::mutex::CMutex<usize>>::new<usize>::{closure#1}, ring_buf::mutex::CMutex<usize>, core::convert::Infallible>>
Line
Count
Source
1210
1
    fn pin_init(init: impl PinInit<T>) -> Result<Pin<Self>, AllocError> {
1211
1
        // SAFETY: We delegate to `init` and only change the error type.
1212
1
        let init = unsafe {
1213
1
            pin_init_from_closure(|slot| {
1214
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
1
            })
1216
1
        };
1217
1
        Self::try_pin_init(init)
1218
1
    }
<alloc::boxed::Box<linked_list::ListHead> as pinned_init::InPlaceInit<linked_list::ListHead>>::pin_init::<pinned_init::__internal::InitClosure<<linked_list::ListHead>::insert_next::{closure#1}, linked_list::ListHead, core::convert::Infallible>>
Line
Count
Source
1210
1
    fn pin_init(init: impl PinInit<T>) -> Result<Pin<Self>, AllocError> {
1211
1
        // SAFETY: We delegate to `init` and only change the error type.
1212
1
        let init = unsafe {
1213
1
            pin_init_from_closure(|slot| {
1214
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
1
            })
1216
1
        };
1217
1
        Self::try_pin_init(init)
1218
1
    }
<alloc::boxed::Box<linked_list::ListHead> as pinned_init::InPlaceInit<linked_list::ListHead>>::pin_init::<pinned_init::__internal::InitClosure<<linked_list::ListHead>::new::{closure#1}, linked_list::ListHead, core::convert::Infallible>>
Line
Count
Source
1210
1
    fn pin_init(init: impl PinInit<T>) -> Result<Pin<Self>, AllocError> {
1211
1
        // SAFETY: We delegate to `init` and only change the error type.
1212
1
        let init = unsafe {
1213
1
            pin_init_from_closure(|slot| {
1214
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
1
            })
1216
1
        };
1217
1
        Self::try_pin_init(init)
1218
1
    }
<alloc::sync::Arc<mutex::CMutex<usize>> as pinned_init::InPlaceInit<mutex::CMutex<usize>>>::pin_init::<pinned_init::__internal::InitClosure<<mutex::CMutex<usize>>::new<usize>::{closure#1}, mutex::CMutex<usize>, core::convert::Infallible>>
Line
Count
Source
1210
1
    fn pin_init(init: impl PinInit<T>) -> Result<Pin<Self>, AllocError> {
1211
1
        // SAFETY: We delegate to `init` and only change the error type.
1212
1
        let init = unsafe {
1213
1
            pin_init_from_closure(|slot| {
1214
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
1
            })
1216
1
        };
1217
1
        Self::try_pin_init(init)
1218
1
    }
<alloc::boxed::Box<mutex::linked_list::ListHead> as pinned_init::InPlaceInit<mutex::linked_list::ListHead>>::pin_init::<pinned_init::__internal::InitClosure<<mutex::linked_list::ListHead>::insert_next::{closure#1}, mutex::linked_list::ListHead, core::convert::Infallible>>
Line
Count
Source
1210
1
    fn pin_init(init: impl PinInit<T>) -> Result<Pin<Self>, AllocError> {
1211
1
        // SAFETY: We delegate to `init` and only change the error type.
1212
1
        let init = unsafe {
1213
1
            pin_init_from_closure(|slot| {
1214
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
1
            })
1216
1
        };
1217
1
        Self::try_pin_init(init)
1218
1
    }
<alloc::boxed::Box<mutex::linked_list::ListHead> as pinned_init::InPlaceInit<mutex::linked_list::ListHead>>::pin_init::<pinned_init::__internal::InitClosure<<mutex::linked_list::ListHead>::new::{closure#1}, mutex::linked_list::ListHead, core::convert::Infallible>>
Line
Count
Source
1210
1
    fn pin_init(init: impl PinInit<T>) -> Result<Pin<Self>, AllocError> {
1211
1
        // SAFETY: We delegate to `init` and only change the error type.
1212
1
        let init = unsafe {
1213
1
            pin_init_from_closure(|slot| {
1214
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
1
            })
1216
1
        };
1217
1
        Self::try_pin_init(init)
1218
1
    }
<alloc::boxed::Box<static_init::mutex::linked_list::ListHead> as pinned_init::InPlaceInit<static_init::mutex::linked_list::ListHead>>::pin_init::<pinned_init::__internal::InitClosure<<static_init::mutex::linked_list::ListHead>::new::{closure#1}, static_init::mutex::linked_list::ListHead, core::convert::Infallible>>
Line
Count
Source
1210
1
    fn pin_init(init: impl PinInit<T>) -> Result<Pin<Self>, AllocError> {
1211
1
        // SAFETY: We delegate to `init` and only change the error type.
1212
1
        let init = unsafe {
1213
1
            pin_init_from_closure(|slot| {
1214
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
1
            })
1216
1
        };
1217
1
        Self::try_pin_init(init)
1218
1
    }
<alloc::sync::Arc<static_init::mutex::CMutex<usize>> as pinned_init::InPlaceInit<static_init::mutex::CMutex<usize>>>::pin_init::<pinned_init::__internal::InitClosure<<static_init::mutex::CMutex<usize>>::new<usize>::{closure#1}, static_init::mutex::CMutex<usize>, core::convert::Infallible>>
Line
Count
Source
1210
1
    fn pin_init(init: impl PinInit<T>) -> Result<Pin<Self>, AllocError> {
1211
1
        // SAFETY: We delegate to `init` and only change the error type.
1212
1
        let init = unsafe {
1213
1
            pin_init_from_closure(|slot| {
1214
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
1
            })
1216
1
        };
1217
1
        Self::try_pin_init(init)
1218
1
    }
<alloc::boxed::Box<static_init::mutex::linked_list::ListHead> as pinned_init::InPlaceInit<static_init::mutex::linked_list::ListHead>>::pin_init::<pinned_init::__internal::InitClosure<<static_init::mutex::linked_list::ListHead>::insert_next::{closure#1}, static_init::mutex::linked_list::ListHead, core::convert::Infallible>>
Line
Count
Source
1210
1
    fn pin_init(init: impl PinInit<T>) -> Result<Pin<Self>, AllocError> {
1211
1
        // SAFETY: We delegate to `init` and only change the error type.
1212
1
        let init = unsafe {
1213
1
            pin_init_from_closure(|slot| {
1214
                Ok(init.__pinned_init(slot).unwrap()) // cannot fail
1215
1
            })
1216
1
        };
1217
1
        Self::try_pin_init(init)
1218
1
    }
1219
1220
    /// Use the given initializer to in-place initialize a `T`.
1221
    fn try_init<E>(init: impl Init<T, E>) -> Result<Self, E>
1222
    where
1223
        E: From<AllocError>;
1224
1225
    /// Use the given initializer to in-place initialize a `T`.
1226
6
    fn init(init: impl Init<T>) -> Result<Self, AllocError> {
1227
6
        let init = unsafe {
1228
6
            init_from_closure(|slot| 
Ok(init.__init(slot).unwrap())4
) //cannot fail
Unexecuted instantiation: <alloc::sync::Arc<[u8; 1099511627776usize]> as pinned_init::InPlaceInit<[u8; 1099511627776usize]>>::init::<pinned_init::__internal::InitClosure<pinned_init::zeroed<[u8; 1099511627776usize], core::convert::Infallible>::{closure#0}, [u8; 1099511627776usize], core::convert::Infallible>>::{closure#0}
<alloc::boxed::Box<alloc_fail::ring_buf::BigStruct> as pinned_init::InPlaceInit<alloc_fail::ring_buf::BigStruct>>::init::<pinned_init::__internal::InitClosure<alloc_fail::ring_buf::big_struct::{closure#3}, alloc_fail::ring_buf::BigStruct, core::convert::Infallible>>::{closure#0}
Line
Count
Source
1228
1
            init_from_closure(|slot| Ok(init.__init(slot).unwrap())) //cannot fail
Unexecuted instantiation: <alloc::boxed::Box<[u8; 1099511627776usize]> as pinned_init::InPlaceInit<[u8; 1099511627776usize]>>::init::<pinned_init::__internal::InitClosure<pinned_init::zeroed<[u8; 1099511627776usize], core::convert::Infallible>::{closure#0}, [u8; 1099511627776usize], core::convert::Infallible>>::{closure#0}
<alloc::sync::Arc<alloc_fail::ring_buf::BigStruct> as pinned_init::InPlaceInit<alloc_fail::ring_buf::BigStruct>>::init::<pinned_init::__internal::InitClosure<alloc_fail::ring_buf::big_struct::{closure#1}, alloc_fail::ring_buf::BigStruct, core::convert::Infallible>>::{closure#0}
Line
Count
Source
1228
1
            init_from_closure(|slot| Ok(init.__init(slot).unwrap())) //cannot fail
Unexecuted instantiation: <_ as pinned_init::InPlaceInit<_>>::init::<_>::{closure#0}
Unexecuted instantiation: <_ as pinned_init::InPlaceInit<_>>::init::<_>::{closure#0}
<alloc::sync::Arc<ring_buf::BigStruct> as pinned_init::InPlaceInit<ring_buf::BigStruct>>::init::<pinned_init::__internal::InitClosure<ring_buf::big_struct::{closure#1}, ring_buf::BigStruct, core::convert::Infallible>>::{closure#0}
Line
Count
Source
1228
1
            init_from_closure(|slot| Ok(init.__init(slot).unwrap())) //cannot fail
<alloc::boxed::Box<ring_buf::BigStruct> as pinned_init::InPlaceInit<ring_buf::BigStruct>>::init::<pinned_init::__internal::InitClosure<ring_buf::big_struct::{closure#3}, ring_buf::BigStruct, core::convert::Infallible>>::{closure#0}
Line
Count
Source
1228
1
            init_from_closure(|slot| Ok(init.__init(slot).unwrap())) //cannot fail
1229
6
        };
1230
6
        Self::try_init(init)
1231
6
    }
<alloc::sync::Arc<[u8; 1099511627776usize]> as pinned_init::InPlaceInit<[u8; 1099511627776usize]>>::init::<pinned_init::__internal::InitClosure<pinned_init::zeroed<[u8; 1099511627776usize], core::convert::Infallible>::{closure#0}, [u8; 1099511627776usize], core::convert::Infallible>>
Line
Count
Source
1226
1
    fn init(init: impl Init<T>) -> Result<Self, AllocError> {
1227
1
        let init = unsafe {
1228
1
            init_from_closure(|slot| Ok(init.__init(slot).unwrap())) //cannot fail
1229
1
        };
1230
1
        Self::try_init(init)
1231
1
    }
<alloc::sync::Arc<alloc_fail::ring_buf::BigStruct> as pinned_init::InPlaceInit<alloc_fail::ring_buf::BigStruct>>::init::<pinned_init::__internal::InitClosure<alloc_fail::ring_buf::big_struct::{closure#1}, alloc_fail::ring_buf::BigStruct, core::convert::Infallible>>
Line
Count
Source
1226
1
    fn init(init: impl Init<T>) -> Result<Self, AllocError> {
1227
1
        let init = unsafe {
1228
1
            init_from_closure(|slot| Ok(init.__init(slot).unwrap())) //cannot fail
1229
1
        };
1230
1
        Self::try_init(init)
1231
1
    }
<alloc::boxed::Box<alloc_fail::ring_buf::BigStruct> as pinned_init::InPlaceInit<alloc_fail::ring_buf::BigStruct>>::init::<pinned_init::__internal::InitClosure<alloc_fail::ring_buf::big_struct::{closure#3}, alloc_fail::ring_buf::BigStruct, core::convert::Infallible>>
Line
Count
Source
1226
1
    fn init(init: impl Init<T>) -> Result<Self, AllocError> {
1227
1
        let init = unsafe {
1228
1
            init_from_closure(|slot| Ok(init.__init(slot).unwrap())) //cannot fail
1229
1
        };
1230
1
        Self::try_init(init)
1231
1
    }
<alloc::boxed::Box<[u8; 1099511627776usize]> as pinned_init::InPlaceInit<[u8; 1099511627776usize]>>::init::<pinned_init::__internal::InitClosure<pinned_init::zeroed<[u8; 1099511627776usize], core::convert::Infallible>::{closure#0}, [u8; 1099511627776usize], core::convert::Infallible>>
Line
Count
Source
1226
1
    fn init(init: impl Init<T>) -> Result<Self, AllocError> {
1227
1
        let init = unsafe {
1228
1
            init_from_closure(|slot| Ok(init.__init(slot).unwrap())) //cannot fail
1229
1
        };
1230
1
        Self::try_init(init)
1231
1
    }
Unexecuted instantiation: <_ as pinned_init::InPlaceInit<_>>::init::<_>
Unexecuted instantiation: <_ as pinned_init::InPlaceInit<_>>::init::<_>
<alloc::boxed::Box<ring_buf::BigStruct> as pinned_init::InPlaceInit<ring_buf::BigStruct>>::init::<pinned_init::__internal::InitClosure<ring_buf::big_struct::{closure#3}, ring_buf::BigStruct, core::convert::Infallible>>
Line
Count
Source
1226
1
    fn init(init: impl Init<T>) -> Result<Self, AllocError> {
1227
1
        let init = unsafe {
1228
1
            init_from_closure(|slot| Ok(init.__init(slot).unwrap())) //cannot fail
1229
1
        };
1230
1
        Self::try_init(init)
1231
1
    }
<alloc::sync::Arc<ring_buf::BigStruct> as pinned_init::InPlaceInit<ring_buf::BigStruct>>::init::<pinned_init::__internal::InitClosure<ring_buf::big_struct::{closure#1}, ring_buf::BigStruct, core::convert::Infallible>>
Line
Count
Source
1226
1
    fn init(init: impl Init<T>) -> Result<Self, AllocError> {
1227
1
        let init = unsafe {
1228
1
            init_from_closure(|slot| Ok(init.__init(slot).unwrap())) //cannot fail
1229
1
        };
1230
1
        Self::try_init(init)
1231
1
    }
1232
}
1233
1234
#[cfg(any(feature = "alloc"))]
1235
impl<T> InPlaceInit<T> for Box<T> {
1236
    #[inline]
1237
15
    fn try_pin_init<E>(init: impl PinInit<T, E>) -> Result<Pin<Self>, E>
1238
15
    where
1239
15
        E: From<AllocError>,
1240
15
    {
1241
15
        let 
mut this14
= Box::try_new_uninit()
?1
;
1242
14
        let slot = this.as_mut_ptr();
1243
14
        // SAFETY: When init errors/panics, slot will get deallocated but not dropped,
1244
14
        // slot is valid and will not be moved, because we pin it later.
1245
14
        unsafe { init.__pinned_init(slot)
?2
};
1246
        // SAFETY: All fields have been initialized.
1247
12
        Ok(unsafe { this.assume_init() }.into())
1248
15
    }
<alloc::boxed::Box<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>> as pinned_init::InPlaceInit<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>>>::try_pin_init::<core::alloc::AllocError, pinned_init::__internal::InitClosure<<alloc::boxed::Box<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>> as pinned_init::InPlaceInit<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>>>::pin_init<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>>::new::{closure#1}, alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>, core::convert::Infallible>>::{closure#0}, alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>, core::alloc::AllocError>>
Line
Count
Source
1237
1
    fn try_pin_init<E>(init: impl PinInit<T, E>) -> Result<Pin<Self>, E>
1238
1
    where
1239
1
        E: From<AllocError>,
1240
1
    {
1241
1
        let 
mut this0
= Box::try_new_uninit()?;
1242
0
        let slot = this.as_mut_ptr();
1243
0
        // SAFETY: When init errors/panics, slot will get deallocated but not dropped,
1244
0
        // slot is valid and will not be moved, because we pin it later.
1245
0
        unsafe { init.__pinned_init(slot)? };
1246
        // SAFETY: All fields have been initialized.
1247
0
        Ok(unsafe { this.assume_init() }.into())
1248
1
    }
<alloc::boxed::Box<alloc_fail::ring_buf::mutex::linked_list::ListHead> as pinned_init::InPlaceInit<alloc_fail::ring_buf::mutex::linked_list::ListHead>>::try_pin_init::<core::alloc::AllocError, pinned_init::__internal::InitClosure<<alloc::boxed::Box<alloc_fail::ring_buf::mutex::linked_list::ListHead> as pinned_init::InPlaceInit<alloc_fail::ring_buf::mutex::linked_list::ListHead>>::pin_init<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::mutex::linked_list::ListHead>::insert_next::{closure#1}, alloc_fail::ring_buf::mutex::linked_list::ListHead, core::convert::Infallible>>::{closure#0}, alloc_fail::ring_buf::mutex::linked_list::ListHead, core::alloc::AllocError>>
Line
Count
Source
1237
1
    fn try_pin_init<E>(init: impl PinInit<T, E>) -> Result<Pin<Self>, E>
1238
1
    where
1239
1
        E: From<AllocError>,
1240
1
    {
1241
1
        let mut this = Box::try_new_uninit()
?0
;
1242
1
        let slot = this.as_mut_ptr();
1243
1
        // SAFETY: When init errors/panics, slot will get deallocated but not dropped,
1244
1
        // slot is valid and will not be moved, because we pin it later.
1245
1
        unsafe { init.__pinned_init(slot)
?0
};
1246
        // SAFETY: All fields have been initialized.
1247
1
        Ok(unsafe { this.assume_init() }.into())
1248
1
    }
<alloc::boxed::Box<alloc_fail::ring_buf::EvenU64> as pinned_init::InPlaceInit<alloc_fail::ring_buf::EvenU64>>::try_pin_init::<core::alloc::AllocError, pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::EvenU64>::new2::{closure#1}, alloc_fail::ring_buf::EvenU64, core::alloc::AllocError>>
Line
Count
Source
1237
1
    fn try_pin_init<E>(init: impl PinInit<T, E>) -> Result<Pin<Self>, E>
1238
1
    where
1239
1
        E: From<AllocError>,
1240
1
    {
1241
1
        let mut this = Box::try_new_uninit()
?0
;
1242
1
        let slot = this.as_mut_ptr();
1243
1
        // SAFETY: When init errors/panics, slot will get deallocated but not dropped,
1244
1
        // slot is valid and will not be moved, because we pin it later.
1245
1
        unsafe { init.__pinned_init(slot)? };
1246
        // SAFETY: All fields have been initialized.
1247
0
        Ok(unsafe { this.assume_init() }.into())
1248
1
    }
<alloc::boxed::Box<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::EvenU64, 4usize>> as pinned_init::InPlaceInit<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::EvenU64, 4usize>>>::try_pin_init::<core::alloc::AllocError, pinned_init::__internal::InitClosure<<alloc::boxed::Box<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::EvenU64, 4usize>> as pinned_init::InPlaceInit<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::EvenU64, 4usize>>>::pin_init<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::EvenU64, 4usize>>::new::{closure#1}, alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::EvenU64, 4usize>, core::convert::Infallible>>::{closure#0}, alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::EvenU64, 4usize>, core::alloc::AllocError>>
Line
Count
Source
1237
1
    fn try_pin_init<E>(init: impl PinInit<T, E>) -> Result<Pin<Self>, E>
1238
1
    where
1239
1
        E: From<AllocError>,
1240
1
    {
1241
1
        let mut this = Box::try_new_uninit()
?0
;
1242
1
        let slot = this.as_mut_ptr();
1243
1
        // SAFETY: When init errors/panics, slot will get deallocated but not dropped,
1244
1
        // slot is valid and will not be moved, because we pin it later.
1245
1
        unsafe { init.__pinned_init(slot)
?0
};
1246
        // SAFETY: All fields have been initialized.
1247
1
        Ok(unsafe { this.assume_init() }.into())
1248
1
    }
<alloc::boxed::Box<alloc_fail::ring_buf::mutex::linked_list::ListHead> as pinned_init::InPlaceInit<alloc_fail::ring_buf::mutex::linked_list::ListHead>>::try_pin_init::<core::alloc::AllocError, pinned_init::__internal::InitClosure<<alloc::boxed::Box<alloc_fail::ring_buf::mutex::linked_list::ListHead> as pinned_init::InPlaceInit<alloc_fail::ring_buf::mutex::linked_list::ListHead>>::pin_init<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::mutex::linked_list::ListHead>::new::{closure#1}, alloc_fail::ring_buf::mutex::linked_list::ListHead, core::convert::Infallible>>::{closure#0}, alloc_fail::ring_buf::mutex::linked_list::ListHead, core::alloc::AllocError>>
Line
Count
Source
1237
1
    fn try_pin_init<E>(init: impl PinInit<T, E>) -> Result<Pin<Self>, E>
1238
1
    where
1239
1
        E: From<AllocError>,
1240
1
    {
1241
1
        let mut this = Box::try_new_uninit()
?0
;
1242
1
        let slot = this.as_mut_ptr();
1243
1
        // SAFETY: When init errors/panics, slot will get deallocated but not dropped,
1244
1
        // slot is valid and will not be moved, because we pin it later.
1245
1
        unsafe { init.__pinned_init(slot)
?0
};
1246
        // SAFETY: All fields have been initialized.
1247
1
        Ok(unsafe { this.assume_init() }.into())
1248
1
    }
Unexecuted instantiation: <alloc::boxed::Box<_> as pinned_init::InPlaceInit<_>>::try_pin_init::<_, _>
Unexecuted instantiation: <alloc::boxed::Box<_> as pinned_init::InPlaceInit<_>>::try_pin_init::<_, _>
<alloc::boxed::Box<ring_buf::mutex::linked_list::ListHead> as pinned_init::InPlaceInit<ring_buf::mutex::linked_list::ListHead>>::try_pin_init::<core::alloc::AllocError, pinned_init::__internal::InitClosure<<alloc::boxed::Box<ring_buf::mutex::linked_list::ListHead> as pinned_init::InPlaceInit<ring_buf::mutex::linked_list::ListHead>>::pin_init<pinned_init::__internal::InitClosure<<ring_buf::mutex::linked_list::ListHead>::new::{closure#1}, ring_buf::mutex::linked_list::ListHead, core::convert::Infallible>>::{closure#0}, ring_buf::mutex::linked_list::ListHead, core::alloc::AllocError>>
Line
Count
Source
1237
1
    fn try_pin_init<E>(init: impl PinInit<T, E>) -> Result<Pin<Self>, E>
1238
1
    where
1239
1
        E: From<AllocError>,
1240
1
    {
1241
1
        let mut this = Box::try_new_uninit()
?0
;
1242
1
        let slot = this.as_mut_ptr();
1243
1
        // SAFETY: When init errors/panics, slot will get deallocated but not dropped,
1244
1
        // slot is valid and will not be moved, because we pin it later.
1245
1
        unsafe { init.__pinned_init(slot)
?0
};
1246
        // SAFETY: All fields have been initialized.
1247
1
        Ok(unsafe { this.assume_init() }.into())
1248
1
    }
<alloc::boxed::Box<ring_buf::EvenU64> as pinned_init::InPlaceInit<ring_buf::EvenU64>>::try_pin_init::<core::alloc::AllocError, pinned_init::__internal::InitClosure<<ring_buf::EvenU64>::new2::{closure#1}, ring_buf::EvenU64, core::alloc::AllocError>>
Line
Count
Source
1237
1
    fn try_pin_init<E>(init: impl PinInit<T, E>) -> Result<Pin<Self>, E>
1238
1
    where
1239
1
        E: From<AllocError>,
1240
1
    {
1241
1
        let mut this = Box::try_new_uninit()
?0
;
1242
1
        let slot = this.as_mut_ptr();
1243
1
        // SAFETY: When init errors/panics, slot will get deallocated but not dropped,
1244
1
        // slot is valid and will not be moved, because we pin it later.
1245
1
        unsafe { init.__pinned_init(slot)? };
1246
        // SAFETY: All fields have been initialized.
1247
0
        Ok(unsafe { this.assume_init() }.into())
1248
1
    }
<alloc::boxed::Box<ring_buf::RingBuffer<ring_buf::EvenU64, 4usize>> as pinned_init::InPlaceInit<ring_buf::RingBuffer<ring_buf::EvenU64, 4usize>>>::try_pin_init::<core::alloc::AllocError, pinned_init::__internal::InitClosure<<alloc::boxed::Box<ring_buf::RingBuffer<ring_buf::EvenU64, 4usize>> as pinned_init::InPlaceInit<ring_buf::RingBuffer<ring_buf::EvenU64, 4usize>>>::pin_init<pinned_init::__internal::InitClosure<<ring_buf::RingBuffer<ring_buf::EvenU64, 4usize>>::new::{closure#1}, ring_buf::RingBuffer<ring_buf::EvenU64, 4usize>, core::convert::Infallible>>::{closure#0}, ring_buf::RingBuffer<ring_buf::EvenU64, 4usize>, core::alloc::AllocError>>
Line
Count
Source
1237
1
    fn try_pin_init<E>(init: impl PinInit<T, E>) -> Result<Pin<Self>, E>
1238
1
    where
1239
1
        E: From<AllocError>,
1240
1
    {
1241
1
        let mut this = Box::try_new_uninit()
?0
;
1242
1
        let slot = this.as_mut_ptr();
1243
1
        // SAFETY: When init errors/panics, slot will get deallocated but not dropped,
1244
1
        // slot is valid and will not be moved, because we pin it later.
1245
1
        unsafe { init.__pinned_init(slot)
?0
};
1246
        // SAFETY: All fields have been initialized.
1247
1
        Ok(unsafe { this.assume_init() }.into())
1248
1
    }
<alloc::boxed::Box<ring_buf::mutex::linked_list::ListHead> as pinned_init::InPlaceInit<ring_buf::mutex::linked_list::ListHead>>::try_pin_init::<core::alloc::AllocError, pinned_init::__internal::InitClosure<<alloc::boxed::Box<ring_buf::mutex::linked_list::ListHead> as pinned_init::InPlaceInit<ring_buf::mutex::linked_list::ListHead>>::pin_init<pinned_init::__internal::InitClosure<<ring_buf::mutex::linked_list::ListHead>::insert_next::{closure#1}, ring_buf::mutex::linked_list::ListHead, core::convert::Infallible>>::{closure#0}, ring_buf::mutex::linked_list::ListHead, core::alloc::AllocError>>
Line
Count
Source
1237
1
    fn try_pin_init<E>(init: impl PinInit<T, E>) -> Result<Pin<Self>, E>
1238
1
    where
1239
1
        E: From<AllocError>,
1240
1
    {
1241
1
        let mut this = Box::try_new_uninit()
?0
;
1242
1
        let slot = this.as_mut_ptr();
1243
1
        // SAFETY: When init errors/panics, slot will get deallocated but not dropped,
1244
1
        // slot is valid and will not be moved, because we pin it later.
1245
1
        unsafe { init.__pinned_init(slot)
?0
};
1246
        // SAFETY: All fields have been initialized.
1247
1
        Ok(unsafe { this.assume_init() }.into())
1248
1
    }
<alloc::boxed::Box<linked_list::ListHead> as pinned_init::InPlaceInit<linked_list::ListHead>>::try_pin_init::<core::alloc::AllocError, pinned_init::__internal::InitClosure<<alloc::boxed::Box<linked_list::ListHead> as pinned_init::InPlaceInit<linked_list::ListHead>>::pin_init<pinned_init::__internal::InitClosure<<linked_list::ListHead>::new::{closure#1}, linked_list::ListHead, core::convert::Infallible>>::{closure#0}, linked_list::ListHead, core::alloc::AllocError>>
Line
Count
Source
1237
1
    fn try_pin_init<E>(init: impl PinInit<T, E>) -> Result<Pin<Self>, E>
1238
1
    where
1239
1
        E: From<AllocError>,
1240
1
    {
1241
1
        let mut this = Box::try_new_uninit()
?0
;
1242
1
        let slot = this.as_mut_ptr();
1243
1
        // SAFETY: When init errors/panics, slot will get deallocated but not dropped,
1244
1
        // slot is valid and will not be moved, because we pin it later.
1245
1
        unsafe { init.__pinned_init(slot)
?0
};
1246
        // SAFETY: All fields have been initialized.
1247
1
        Ok(unsafe { this.assume_init() }.into())
1248
1
    }
<alloc::boxed::Box<linked_list::ListHead> as pinned_init::InPlaceInit<linked_list::ListHead>>::try_pin_init::<core::alloc::AllocError, pinned_init::__internal::InitClosure<<alloc::boxed::Box<linked_list::ListHead> as pinned_init::InPlaceInit<linked_list::ListHead>>::pin_init<pinned_init::__internal::InitClosure<<linked_list::ListHead>::insert_next::{closure#1}, linked_list::ListHead, core::convert::Infallible>>::{closure#0}, linked_list::ListHead, core::alloc::AllocError>>
Line
Count
Source
1237
1
    fn try_pin_init<E>(init: impl PinInit<T, E>) -> Result<Pin<Self>, E>
1238
1
    where
1239
1
        E: From<AllocError>,
1240
1
    {
1241
1
        let mut this = Box::try_new_uninit()
?0
;
1242
1
        let slot = this.as_mut_ptr();
1243
1
        // SAFETY: When init errors/panics, slot will get deallocated but not dropped,
1244
1
        // slot is valid and will not be moved, because we pin it later.
1245
1
        unsafe { init.__pinned_init(slot)
?0
};
1246
        // SAFETY: All fields have been initialized.
1247
1
        Ok(unsafe { this.assume_init() }.into())
1248
1
    }
<alloc::boxed::Box<mutex::linked_list::ListHead> as pinned_init::InPlaceInit<mutex::linked_list::ListHead>>::try_pin_init::<core::alloc::AllocError, pinned_init::__internal::InitClosure<<alloc::boxed::Box<mutex::linked_list::ListHead> as pinned_init::InPlaceInit<mutex::linked_list::ListHead>>::pin_init<pinned_init::__internal::InitClosure<<mutex::linked_list::ListHead>::new::{closure#1}, mutex::linked_list::ListHead, core::convert::Infallible>>::{closure#0}, mutex::linked_list::ListHead, core::alloc::AllocError>>
Line
Count
Source
1237
1
    fn try_pin_init<E>(init: impl PinInit<T, E>) -> Result<Pin<Self>, E>
1238
1
    where
1239
1
        E: From<AllocError>,
1240
1
    {
1241
1
        let mut this = Box::try_new_uninit()
?0
;
1242
1
        let slot = this.as_mut_ptr();
1243
1
        // SAFETY: When init errors/panics, slot will get deallocated but not dropped,
1244
1
        // slot is valid and will not be moved, because we pin it later.
1245
1
        unsafe { init.__pinned_init(slot)
?0
};
1246
        // SAFETY: All fields have been initialized.
1247
1
        Ok(unsafe { this.assume_init() }.into())
1248
1
    }
<alloc::boxed::Box<mutex::linked_list::ListHead> as pinned_init::InPlaceInit<mutex::linked_list::ListHead>>::try_pin_init::<core::alloc::AllocError, pinned_init::__internal::InitClosure<<alloc::boxed::Box<mutex::linked_list::ListHead> as pinned_init::InPlaceInit<mutex::linked_list::ListHead>>::pin_init<pinned_init::__internal::InitClosure<<mutex::linked_list::ListHead>::insert_next::{closure#1}, mutex::linked_list::ListHead, core::convert::Infallible>>::{closure#0}, mutex::linked_list::ListHead, core::alloc::AllocError>>
Line
Count
Source
1237
1
    fn try_pin_init<E>(init: impl PinInit<T, E>) -> Result<Pin<Self>, E>
1238
1
    where
1239
1
        E: From<AllocError>,
1240
1
    {
1241
1
        let mut this = Box::try_new_uninit()
?0
;
1242
1
        let slot = this.as_mut_ptr();
1243
1
        // SAFETY: When init errors/panics, slot will get deallocated but not dropped,
1244
1
        // slot is valid and will not be moved, because we pin it later.
1245
1
        unsafe { init.__pinned_init(slot)
?0
};
1246
        // SAFETY: All fields have been initialized.
1247
1
        Ok(unsafe { this.assume_init() }.into())
1248
1
    }
<alloc::boxed::Box<static_init::mutex::linked_list::ListHead> as pinned_init::InPlaceInit<static_init::mutex::linked_list::ListHead>>::try_pin_init::<core::alloc::AllocError, pinned_init::__internal::InitClosure<<alloc::boxed::Box<static_init::mutex::linked_list::ListHead> as pinned_init::InPlaceInit<static_init::mutex::linked_list::ListHead>>::pin_init<pinned_init::__internal::InitClosure<<static_init::mutex::linked_list::ListHead>::new::{closure#1}, static_init::mutex::linked_list::ListHead, core::convert::Infallible>>::{closure#0}, static_init::mutex::linked_list::ListHead, core::alloc::AllocError>>
Line
Count
Source
1237
1
    fn try_pin_init<E>(init: impl PinInit<T, E>) -> Result<Pin<Self>, E>
1238
1
    where
1239
1
        E: From<AllocError>,
1240
1
    {
1241
1
        let mut this = Box::try_new_uninit()
?0
;
1242
1
        let slot = this.as_mut_ptr();
1243
1
        // SAFETY: When init errors/panics, slot will get deallocated but not dropped,
1244
1
        // slot is valid and will not be moved, because we pin it later.
1245
1
        unsafe { init.__pinned_init(slot)
?0
};
1246
        // SAFETY: All fields have been initialized.
1247
1
        Ok(unsafe { this.assume_init() }.into())
1248
1
    }
<alloc::boxed::Box<static_init::mutex::linked_list::ListHead> as pinned_init::InPlaceInit<static_init::mutex::linked_list::ListHead>>::try_pin_init::<core::alloc::AllocError, pinned_init::__internal::InitClosure<<alloc::boxed::Box<static_init::mutex::linked_list::ListHead> as pinned_init::InPlaceInit<static_init::mutex::linked_list::ListHead>>::pin_init<pinned_init::__internal::InitClosure<<static_init::mutex::linked_list::ListHead>::insert_next::{closure#1}, static_init::mutex::linked_list::ListHead, core::convert::Infallible>>::{closure#0}, static_init::mutex::linked_list::ListHead, core::alloc::AllocError>>
Line
Count
Source
1237
1
    fn try_pin_init<E>(init: impl PinInit<T, E>) -> Result<Pin<Self>, E>
1238
1
    where
1239
1
        E: From<AllocError>,
1240
1
    {
1241
1
        let mut this = Box::try_new_uninit()
?0
;
1242
1
        let slot = this.as_mut_ptr();
1243
1
        // SAFETY: When init errors/panics, slot will get deallocated but not dropped,
1244
1
        // slot is valid and will not be moved, because we pin it later.
1245
1
        unsafe { init.__pinned_init(slot)
?0
};
1246
        // SAFETY: All fields have been initialized.
1247
1
        Ok(unsafe { this.assume_init() }.into())
1248
1
    }
1249
1250
    #[inline]
1251
5
    fn try_init<E>(init: impl Init<T, E>) -> Result<Self, E>
1252
5
    where
1253
5
        E: From<AllocError>,
1254
5
    {
1255
5
        let 
mut this4
= Box::try_new_uninit()
?1
;
1256
4
        let slot = this.as_mut_ptr();
1257
4
        // SAFETY: When init errors/panics, slot will get deallocated but not dropped,
1258
4
        // slot is valid.
1259
4
        unsafe { init.__init(slot)
?2
};
1260
        // SAFETY: All fields have been initialized.
1261
2
        Ok(unsafe { this.assume_init() })
1262
5
    }
<alloc::boxed::Box<alloc_fail::ring_buf::EvenU64> as pinned_init::InPlaceInit<alloc_fail::ring_buf::EvenU64>>::try_init::<core::alloc::AllocError, pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::EvenU64>::new2::{closure#1}, alloc_fail::ring_buf::EvenU64, core::alloc::AllocError>>
Line
Count
Source
1251
1
    fn try_init<E>(init: impl Init<T, E>) -> Result<Self, E>
1252
1
    where
1253
1
        E: From<AllocError>,
1254
1
    {
1255
1
        let mut this = Box::try_new_uninit()
?0
;
1256
1
        let slot = this.as_mut_ptr();
1257
1
        // SAFETY: When init errors/panics, slot will get deallocated but not dropped,
1258
1
        // slot is valid.
1259
1
        unsafe { init.__init(slot)? };
1260
        // SAFETY: All fields have been initialized.
1261
0
        Ok(unsafe { this.assume_init() })
1262
1
    }
<alloc::boxed::Box<[u8; 1099511627776usize]> as pinned_init::InPlaceInit<[u8; 1099511627776usize]>>::try_init::<core::alloc::AllocError, pinned_init::__internal::InitClosure<<alloc::boxed::Box<[u8; 1099511627776usize]> as pinned_init::InPlaceInit<[u8; 1099511627776usize]>>::init<pinned_init::__internal::InitClosure<pinned_init::zeroed<[u8; 1099511627776usize], core::convert::Infallible>::{closure#0}, [u8; 1099511627776usize], core::convert::Infallible>>::{closure#0}, [u8; 1099511627776usize], core::alloc::AllocError>>
Line
Count
Source
1251
1
    fn try_init<E>(init: impl Init<T, E>) -> Result<Self, E>
1252
1
    where
1253
1
        E: From<AllocError>,
1254
1
    {
1255
1
        let 
mut this0
= Box::try_new_uninit()?;
1256
0
        let slot = this.as_mut_ptr();
1257
0
        // SAFETY: When init errors/panics, slot will get deallocated but not dropped,
1258
0
        // slot is valid.
1259
0
        unsafe { init.__init(slot)? };
1260
        // SAFETY: All fields have been initialized.
1261
0
        Ok(unsafe { this.assume_init() })
1262
1
    }
<alloc::boxed::Box<alloc_fail::ring_buf::BigStruct> as pinned_init::InPlaceInit<alloc_fail::ring_buf::BigStruct>>::try_init::<core::alloc::AllocError, pinned_init::__internal::InitClosure<<alloc::boxed::Box<alloc_fail::ring_buf::BigStruct> as pinned_init::InPlaceInit<alloc_fail::ring_buf::BigStruct>>::init<pinned_init::__internal::InitClosure<alloc_fail::ring_buf::big_struct::{closure#3}, alloc_fail::ring_buf::BigStruct, core::convert::Infallible>>::{closure#0}, alloc_fail::ring_buf::BigStruct, core::alloc::AllocError>>
Line
Count
Source
1251
1
    fn try_init<E>(init: impl Init<T, E>) -> Result<Self, E>
1252
1
    where
1253
1
        E: From<AllocError>,
1254
1
    {
1255
1
        let mut this = Box::try_new_uninit()
?0
;
1256
1
        let slot = this.as_mut_ptr();
1257
1
        // SAFETY: When init errors/panics, slot will get deallocated but not dropped,
1258
1
        // slot is valid.
1259
1
        unsafe { init.__init(slot)
?0
};
1260
        // SAFETY: All fields have been initialized.
1261
1
        Ok(unsafe { this.assume_init() })
1262
1
    }
Unexecuted instantiation: <alloc::boxed::Box<_> as pinned_init::InPlaceInit<_>>::try_init::<_, _>
Unexecuted instantiation: <alloc::boxed::Box<_> as pinned_init::InPlaceInit<_>>::try_init::<_, _>
<alloc::boxed::Box<ring_buf::BigStruct> as pinned_init::InPlaceInit<ring_buf::BigStruct>>::try_init::<core::alloc::AllocError, pinned_init::__internal::InitClosure<<alloc::boxed::Box<ring_buf::BigStruct> as pinned_init::InPlaceInit<ring_buf::BigStruct>>::init<pinned_init::__internal::InitClosure<ring_buf::big_struct::{closure#3}, ring_buf::BigStruct, core::convert::Infallible>>::{closure#0}, ring_buf::BigStruct, core::alloc::AllocError>>
Line
Count
Source
1251
1
    fn try_init<E>(init: impl Init<T, E>) -> Result<Self, E>
1252
1
    where
1253
1
        E: From<AllocError>,
1254
1
    {
1255
1
        let mut this = Box::try_new_uninit()
?0
;
1256
1
        let slot = this.as_mut_ptr();
1257
1
        // SAFETY: When init errors/panics, slot will get deallocated but not dropped,
1258
1
        // slot is valid.
1259
1
        unsafe { init.__init(slot)
?0
};
1260
        // SAFETY: All fields have been initialized.
1261
1
        Ok(unsafe { this.assume_init() })
1262
1
    }
<alloc::boxed::Box<ring_buf::EvenU64> as pinned_init::InPlaceInit<ring_buf::EvenU64>>::try_init::<core::alloc::AllocError, pinned_init::__internal::InitClosure<<ring_buf::EvenU64>::new2::{closure#1}, ring_buf::EvenU64, core::alloc::AllocError>>
Line
Count
Source
1251
1
    fn try_init<E>(init: impl Init<T, E>) -> Result<Self, E>
1252
1
    where
1253
1
        E: From<AllocError>,
1254
1
    {
1255
1
        let mut this = Box::try_new_uninit()
?0
;
1256
1
        let slot = this.as_mut_ptr();
1257
1
        // SAFETY: When init errors/panics, slot will get deallocated but not dropped,
1258
1
        // slot is valid.
1259
1
        unsafe { init.__init(slot)? };
1260
        // SAFETY: All fields have been initialized.
1261
0
        Ok(unsafe { this.assume_init() })
1262
1
    }
1263
}
1264
1265
#[cfg(any(feature = "alloc"))]
1266
impl<T> InPlaceInit<T> for Arc<T> {
1267
    #[inline]
1268
10
    fn try_pin_init<E>(init: impl PinInit<T, E>) -> Result<Pin<Self>, E>
1269
10
    where
1270
10
        E: From<AllocError>,
1271
10
    {
1272
10
        let 
mut this9
= Arc::try_new_uninit()
?1
;
1273
9
        let slot = unsafe { Arc::get_mut_unchecked(&mut this) };
1274
9
        let slot = slot.as_mut_ptr();
1275
9
        // SAFETY: When init errors/panics, slot will get deallocated but not dropped,
1276
9
        // slot is valid and will not be moved, because we pin it later.
1277
9
        unsafe { init.__pinned_init(slot)
?2
};
1278
        // SAFETY: All fields have been initialized and this is the only `Arc` to that data.
1279
7
        Ok(unsafe { Pin::new_unchecked(this.assume_init()) })
1280
10
    }
<alloc::sync::Arc<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>> as pinned_init::InPlaceInit<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>>>::try_pin_init::<core::alloc::AllocError, pinned_init::__internal::InitClosure<<alloc::sync::Arc<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>> as pinned_init::InPlaceInit<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>>>::pin_init<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>>::new::{closure#1}, alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>, core::convert::Infallible>>::{closure#0}, alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>, core::alloc::AllocError>>
Line
Count
Source
1268
1
    fn try_pin_init<E>(init: impl PinInit<T, E>) -> Result<Pin<Self>, E>
1269
1
    where
1270
1
        E: From<AllocError>,
1271
1
    {
1272
1
        let 
mut this0
= Arc::try_new_uninit()?;
1273
0
        let slot = unsafe { Arc::get_mut_unchecked(&mut this) };
1274
0
        let slot = slot.as_mut_ptr();
1275
0
        // SAFETY: When init errors/panics, slot will get deallocated but not dropped,
1276
0
        // slot is valid and will not be moved, because we pin it later.
1277
0
        unsafe { init.__pinned_init(slot)? };
1278
        // SAFETY: All fields have been initialized and this is the only `Arc` to that data.
1279
0
        Ok(unsafe { Pin::new_unchecked(this.assume_init()) })
1280
1
    }
<alloc::sync::Arc<alloc_fail::ring_buf::mutex::CMutex<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>> as pinned_init::InPlaceInit<alloc_fail::ring_buf::mutex::CMutex<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>>>::try_pin_init::<core::alloc::AllocError, pinned_init::__internal::InitClosure<<alloc::sync::Arc<alloc_fail::ring_buf::mutex::CMutex<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>> as pinned_init::InPlaceInit<alloc_fail::ring_buf::mutex::CMutex<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>>>::pin_init<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::mutex::CMutex<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>>::new<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>::new::{closure#1}, alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>, core::convert::Infallible>>::{closure#1}, alloc_fail::ring_buf::mutex::CMutex<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>, core::convert::Infallible>>::{closure#0}, alloc_fail::ring_buf::mutex::CMutex<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>, core::alloc::AllocError>>
Line
Count
Source
1268
1
    fn try_pin_init<E>(init: impl PinInit<T, E>) -> Result<Pin<Self>, E>
1269
1
    where
1270
1
        E: From<AllocError>,
1271
1
    {
1272
1
        let mut this = Arc::try_new_uninit()
?0
;
1273
1
        let slot = unsafe { Arc::get_mut_unchecked(&mut this) };
1274
1
        let slot = slot.as_mut_ptr();
1275
1
        // SAFETY: When init errors/panics, slot will get deallocated but not dropped,
1276
1
        // slot is valid and will not be moved, because we pin it later.
1277
1
        unsafe { init.__pinned_init(slot)
?0
};
1278
        // SAFETY: All fields have been initialized and this is the only `Arc` to that data.
1279
1
        Ok(unsafe { Pin::new_unchecked(this.assume_init()) })
1280
1
    }
<alloc::sync::Arc<alloc_fail::ring_buf::EvenU64> as pinned_init::InPlaceInit<alloc_fail::ring_buf::EvenU64>>::try_pin_init::<core::alloc::AllocError, pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::EvenU64>::new2::{closure#1}, alloc_fail::ring_buf::EvenU64, core::alloc::AllocError>>
Line
Count
Source
1268
1
    fn try_pin_init<E>(init: impl PinInit<T, E>) -> Result<Pin<Self>, E>
1269
1
    where
1270
1
        E: From<AllocError>,
1271
1
    {
1272
1
        let mut this = Arc::try_new_uninit()
?0
;
1273
1
        let slot = unsafe { Arc::get_mut_unchecked(&mut this) };
1274
1
        let slot = slot.as_mut_ptr();
1275
1
        // SAFETY: When init errors/panics, slot will get deallocated but not dropped,
1276
1
        // slot is valid and will not be moved, because we pin it later.
1277
1
        unsafe { init.__pinned_init(slot)? };
1278
        // SAFETY: All fields have been initialized and this is the only `Arc` to that data.
1279
0
        Ok(unsafe { Pin::new_unchecked(this.assume_init()) })
1280
1
    }
<alloc::sync::Arc<alloc_fail::ring_buf::mutex::CMutex<usize>> as pinned_init::InPlaceInit<alloc_fail::ring_buf::mutex::CMutex<usize>>>::try_pin_init::<core::alloc::AllocError, pinned_init::__internal::InitClosure<<alloc::sync::Arc<alloc_fail::ring_buf::mutex::CMutex<usize>> as pinned_init::InPlaceInit<alloc_fail::ring_buf::mutex::CMutex<usize>>>::pin_init<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::mutex::CMutex<usize>>::new<usize>::{closure#1}, alloc_fail::ring_buf::mutex::CMutex<usize>, core::convert::Infallible>>::{closure#0}, alloc_fail::ring_buf::mutex::CMutex<usize>, core::alloc::AllocError>>
Line
Count
Source
1268
1
    fn try_pin_init<E>(init: impl PinInit<T, E>) -> Result<Pin<Self>, E>
1269
1
    where
1270
1
        E: From<AllocError>,
1271
1
    {
1272
1
        let mut this = Arc::try_new_uninit()
?0
;
1273
1
        let slot = unsafe { Arc::get_mut_unchecked(&mut this) };
1274
1
        let slot = slot.as_mut_ptr();
1275
1
        // SAFETY: When init errors/panics, slot will get deallocated but not dropped,
1276
1
        // slot is valid and will not be moved, because we pin it later.
1277
1
        unsafe { init.__pinned_init(slot)
?0
};
1278
        // SAFETY: All fields have been initialized and this is the only `Arc` to that data.
1279
1
        Ok(unsafe { Pin::new_unchecked(this.assume_init()) })
1280
1
    }
Unexecuted instantiation: <alloc::sync::Arc<_> as pinned_init::InPlaceInit<_>>::try_pin_init::<_, _>
Unexecuted instantiation: <alloc::sync::Arc<_> as pinned_init::InPlaceInit<_>>::try_pin_init::<_, _>
<alloc::sync::Arc<ring_buf::mutex::CMutex<usize>> as pinned_init::InPlaceInit<ring_buf::mutex::CMutex<usize>>>::try_pin_init::<core::alloc::AllocError, pinned_init::__internal::InitClosure<<alloc::sync::Arc<ring_buf::mutex::CMutex<usize>> as pinned_init::InPlaceInit<ring_buf::mutex::CMutex<usize>>>::pin_init<pinned_init::__internal::InitClosure<<ring_buf::mutex::CMutex<usize>>::new<usize>::{closure#1}, ring_buf::mutex::CMutex<usize>, core::convert::Infallible>>::{closure#0}, ring_buf::mutex::CMutex<usize>, core::alloc::AllocError>>
Line
Count
Source
1268
1
    fn try_pin_init<E>(init: impl PinInit<T, E>) -> Result<Pin<Self>, E>
1269
1
    where
1270
1
        E: From<AllocError>,
1271
1
    {
1272
1
        let mut this = Arc::try_new_uninit()
?0
;
1273
1
        let slot = unsafe { Arc::get_mut_unchecked(&mut this) };
1274
1
        let slot = slot.as_mut_ptr();
1275
1
        // SAFETY: When init errors/panics, slot will get deallocated but not dropped,
1276
1
        // slot is valid and will not be moved, because we pin it later.
1277
1
        unsafe { init.__pinned_init(slot)
?0
};
1278
        // SAFETY: All fields have been initialized and this is the only `Arc` to that data.
1279
1
        Ok(unsafe { Pin::new_unchecked(this.assume_init()) })
1280
1
    }
<alloc::sync::Arc<ring_buf::mutex::CMutex<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>> as pinned_init::InPlaceInit<ring_buf::mutex::CMutex<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>>>::try_pin_init::<core::alloc::AllocError, pinned_init::__internal::InitClosure<<alloc::sync::Arc<ring_buf::mutex::CMutex<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>> as pinned_init::InPlaceInit<ring_buf::mutex::CMutex<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>>>::pin_init<pinned_init::__internal::InitClosure<<ring_buf::mutex::CMutex<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>>::new<pinned_init::__internal::InitClosure<<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>::new::{closure#1}, ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>, core::convert::Infallible>>::{closure#1}, ring_buf::mutex::CMutex<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>, core::convert::Infallible>>::{closure#0}, ring_buf::mutex::CMutex<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>, core::alloc::AllocError>>
Line
Count
Source
1268
1
    fn try_pin_init<E>(init: impl PinInit<T, E>) -> Result<Pin<Self>, E>
1269
1
    where
1270
1
        E: From<AllocError>,
1271
1
    {
1272
1
        let mut this = Arc::try_new_uninit()
?0
;
1273
1
        let slot = unsafe { Arc::get_mut_unchecked(&mut this) };
1274
1
        let slot = slot.as_mut_ptr();
1275
1
        // SAFETY: When init errors/panics, slot will get deallocated but not dropped,
1276
1
        // slot is valid and will not be moved, because we pin it later.
1277
1
        unsafe { init.__pinned_init(slot)
?0
};
1278
        // SAFETY: All fields have been initialized and this is the only `Arc` to that data.
1279
1
        Ok(unsafe { Pin::new_unchecked(this.assume_init()) })
1280
1
    }
<alloc::sync::Arc<ring_buf::EvenU64> as pinned_init::InPlaceInit<ring_buf::EvenU64>>::try_pin_init::<core::alloc::AllocError, pinned_init::__internal::InitClosure<<ring_buf::EvenU64>::new2::{closure#1}, ring_buf::EvenU64, core::alloc::AllocError>>
Line
Count
Source
1268
1
    fn try_pin_init<E>(init: impl PinInit<T, E>) -> Result<Pin<Self>, E>
1269
1
    where
1270
1
        E: From<AllocError>,
1271
1
    {
1272
1
        let mut this = Arc::try_new_uninit()
?0
;
1273
1
        let slot = unsafe { Arc::get_mut_unchecked(&mut this) };
1274
1
        let slot = slot.as_mut_ptr();
1275
1
        // SAFETY: When init errors/panics, slot will get deallocated but not dropped,
1276
1
        // slot is valid and will not be moved, because we pin it later.
1277
1
        unsafe { init.__pinned_init(slot)? };
1278
        // SAFETY: All fields have been initialized and this is the only `Arc` to that data.
1279
0
        Ok(unsafe { Pin::new_unchecked(this.assume_init()) })
1280
1
    }
<alloc::sync::Arc<mutex::CMutex<usize>> as pinned_init::InPlaceInit<mutex::CMutex<usize>>>::try_pin_init::<core::alloc::AllocError, pinned_init::__internal::InitClosure<<alloc::sync::Arc<mutex::CMutex<usize>> as pinned_init::InPlaceInit<mutex::CMutex<usize>>>::pin_init<pinned_init::__internal::InitClosure<<mutex::CMutex<usize>>::new<usize>::{closure#1}, mutex::CMutex<usize>, core::convert::Infallible>>::{closure#0}, mutex::CMutex<usize>, core::alloc::AllocError>>
Line
Count
Source
1268
1
    fn try_pin_init<E>(init: impl PinInit<T, E>) -> Result<Pin<Self>, E>
1269
1
    where
1270
1
        E: From<AllocError>,
1271
1
    {
1272
1
        let mut this = Arc::try_new_uninit()
?0
;
1273
1
        let slot = unsafe { Arc::get_mut_unchecked(&mut this) };
1274
1
        let slot = slot.as_mut_ptr();
1275
1
        // SAFETY: When init errors/panics, slot will get deallocated but not dropped,
1276
1
        // slot is valid and will not be moved, because we pin it later.
1277
1
        unsafe { init.__pinned_init(slot)
?0
};
1278
        // SAFETY: All fields have been initialized and this is the only `Arc` to that data.
1279
1
        Ok(unsafe { Pin::new_unchecked(this.assume_init()) })
1280
1
    }
<alloc::sync::Arc<pthread_mutex::pthread_mtx::PThreadMutex<usize>> as pinned_init::InPlaceInit<pthread_mutex::pthread_mtx::PThreadMutex<usize>>>::try_pin_init::<pthread_mutex::pthread_mtx::Error, pinned_init::__internal::InitClosure<<pthread_mutex::pthread_mtx::PThreadMutex<usize>>::new::{closure#1}, pthread_mutex::pthread_mtx::PThreadMutex<usize>, pthread_mutex::pthread_mtx::Error>>
Line
Count
Source
1268
1
    fn try_pin_init<E>(init: impl PinInit<T, E>) -> Result<Pin<Self>, E>
1269
1
    where
1270
1
        E: From<AllocError>,
1271
1
    {
1272
1
        let mut this = Arc::try_new_uninit()
?0
;
1273
1
        let slot = unsafe { Arc::get_mut_unchecked(&mut this) };
1274
1
        let slot = slot.as_mut_ptr();
1275
1
        // SAFETY: When init errors/panics, slot will get deallocated but not dropped,
1276
1
        // slot is valid and will not be moved, because we pin it later.
1277
1
        unsafe { init.__pinned_init(slot)
?0
};
1278
        // SAFETY: All fields have been initialized and this is the only `Arc` to that data.
1279
1
        Ok(unsafe { Pin::new_unchecked(this.assume_init()) })
1280
1
    }
<alloc::sync::Arc<static_init::mutex::CMutex<usize>> as pinned_init::InPlaceInit<static_init::mutex::CMutex<usize>>>::try_pin_init::<core::alloc::AllocError, pinned_init::__internal::InitClosure<<alloc::sync::Arc<static_init::mutex::CMutex<usize>> as pinned_init::InPlaceInit<static_init::mutex::CMutex<usize>>>::pin_init<pinned_init::__internal::InitClosure<<static_init::mutex::CMutex<usize>>::new<usize>::{closure#1}, static_init::mutex::CMutex<usize>, core::convert::Infallible>>::{closure#0}, static_init::mutex::CMutex<usize>, core::alloc::AllocError>>
Line
Count
Source
1268
1
    fn try_pin_init<E>(init: impl PinInit<T, E>) -> Result<Pin<Self>, E>
1269
1
    where
1270
1
        E: From<AllocError>,
1271
1
    {
1272
1
        let mut this = Arc::try_new_uninit()
?0
;
1273
1
        let slot = unsafe { Arc::get_mut_unchecked(&mut this) };
1274
1
        let slot = slot.as_mut_ptr();
1275
1
        // SAFETY: When init errors/panics, slot will get deallocated but not dropped,
1276
1
        // slot is valid and will not be moved, because we pin it later.
1277
1
        unsafe { init.__pinned_init(slot)
?0
};
1278
        // SAFETY: All fields have been initialized and this is the only `Arc` to that data.
1279
1
        Ok(unsafe { Pin::new_unchecked(this.assume_init()) })
1280
1
    }
1281
1282
    #[inline]
1283
5
    fn try_init<E>(init: impl Init<T, E>) -> Result<Self, E>
1284
5
    where
1285
5
        E: From<AllocError>,
1286
5
    {
1287
5
        let 
mut this4
= Arc::try_new_uninit()
?1
;
1288
4
        let slot = unsafe { Arc::get_mut_unchecked(&mut this) };
1289
4
        let slot = slot.as_mut_ptr();
1290
4
        // SAFETY: when init errors/panics, slot will get deallocated but not dropped,
1291
4
        // slot is valid.
1292
4
        unsafe { init.__init(slot)
?2
};
1293
        // SAFETY: All fields have been initialized.
1294
2
        Ok(unsafe { this.assume_init() })
1295
5
    }
<alloc::sync::Arc<alloc_fail::ring_buf::BigStruct> as pinned_init::InPlaceInit<alloc_fail::ring_buf::BigStruct>>::try_init::<core::alloc::AllocError, pinned_init::__internal::InitClosure<<alloc::sync::Arc<alloc_fail::ring_buf::BigStruct> as pinned_init::InPlaceInit<alloc_fail::ring_buf::BigStruct>>::init<pinned_init::__internal::InitClosure<alloc_fail::ring_buf::big_struct::{closure#1}, alloc_fail::ring_buf::BigStruct, core::convert::Infallible>>::{closure#0}, alloc_fail::ring_buf::BigStruct, core::alloc::AllocError>>
Line
Count
Source
1283
1
    fn try_init<E>(init: impl Init<T, E>) -> Result<Self, E>
1284
1
    where
1285
1
        E: From<AllocError>,
1286
1
    {
1287
1
        let mut this = Arc::try_new_uninit()
?0
;
1288
1
        let slot = unsafe { Arc::get_mut_unchecked(&mut this) };
1289
1
        let slot = slot.as_mut_ptr();
1290
1
        // SAFETY: when init errors/panics, slot will get deallocated but not dropped,
1291
1
        // slot is valid.
1292
1
        unsafe { init.__init(slot)
?0
};
1293
        // SAFETY: All fields have been initialized.
1294
1
        Ok(unsafe { this.assume_init() })
1295
1
    }
<alloc::sync::Arc<[u8; 1099511627776usize]> as pinned_init::InPlaceInit<[u8; 1099511627776usize]>>::try_init::<core::alloc::AllocError, pinned_init::__internal::InitClosure<<alloc::sync::Arc<[u8; 1099511627776usize]> as pinned_init::InPlaceInit<[u8; 1099511627776usize]>>::init<pinned_init::__internal::InitClosure<pinned_init::zeroed<[u8; 1099511627776usize], core::convert::Infallible>::{closure#0}, [u8; 1099511627776usize], core::convert::Infallible>>::{closure#0}, [u8; 1099511627776usize], core::alloc::AllocError>>
Line
Count
Source
1283
1
    fn try_init<E>(init: impl Init<T, E>) -> Result<Self, E>
1284
1
    where
1285
1
        E: From<AllocError>,
1286
1
    {
1287
1
        let 
mut this0
= Arc::try_new_uninit()?;
1288
0
        let slot = unsafe { Arc::get_mut_unchecked(&mut this) };
1289
0
        let slot = slot.as_mut_ptr();
1290
0
        // SAFETY: when init errors/panics, slot will get deallocated but not dropped,
1291
0
        // slot is valid.
1292
0
        unsafe { init.__init(slot)? };
1293
        // SAFETY: All fields have been initialized.
1294
0
        Ok(unsafe { this.assume_init() })
1295
1
    }
<alloc::sync::Arc<alloc_fail::ring_buf::EvenU64> as pinned_init::InPlaceInit<alloc_fail::ring_buf::EvenU64>>::try_init::<core::alloc::AllocError, pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::EvenU64>::new2::{closure#1}, alloc_fail::ring_buf::EvenU64, core::alloc::AllocError>>
Line
Count
Source
1283
1
    fn try_init<E>(init: impl Init<T, E>) -> Result<Self, E>
1284
1
    where
1285
1
        E: From<AllocError>,
1286
1
    {
1287
1
        let mut this = Arc::try_new_uninit()
?0
;
1288
1
        let slot = unsafe { Arc::get_mut_unchecked(&mut this) };
1289
1
        let slot = slot.as_mut_ptr();
1290
1
        // SAFETY: when init errors/panics, slot will get deallocated but not dropped,
1291
1
        // slot is valid.
1292
1
        unsafe { init.__init(slot)? };
1293
        // SAFETY: All fields have been initialized.
1294
0
        Ok(unsafe { this.assume_init() })
1295
1
    }
Unexecuted instantiation: <alloc::sync::Arc<_> as pinned_init::InPlaceInit<_>>::try_init::<_, _>
Unexecuted instantiation: <alloc::sync::Arc<_> as pinned_init::InPlaceInit<_>>::try_init::<_, _>
<alloc::sync::Arc<ring_buf::EvenU64> as pinned_init::InPlaceInit<ring_buf::EvenU64>>::try_init::<core::alloc::AllocError, pinned_init::__internal::InitClosure<<ring_buf::EvenU64>::new2::{closure#1}, ring_buf::EvenU64, core::alloc::AllocError>>
Line
Count
Source
1283
1
    fn try_init<E>(init: impl Init<T, E>) -> Result<Self, E>
1284
1
    where
1285
1
        E: From<AllocError>,
1286
1
    {
1287
1
        let mut this = Arc::try_new_uninit()
?0
;
1288
1
        let slot = unsafe { Arc::get_mut_unchecked(&mut this) };
1289
1
        let slot = slot.as_mut_ptr();
1290
1
        // SAFETY: when init errors/panics, slot will get deallocated but not dropped,
1291
1
        // slot is valid.
1292
1
        unsafe { init.__init(slot)? };
1293
        // SAFETY: All fields have been initialized.
1294
0
        Ok(unsafe { this.assume_init() })
1295
1
    }
<alloc::sync::Arc<ring_buf::BigStruct> as pinned_init::InPlaceInit<ring_buf::BigStruct>>::try_init::<core::alloc::AllocError, pinned_init::__internal::InitClosure<<alloc::sync::Arc<ring_buf::BigStruct> as pinned_init::InPlaceInit<ring_buf::BigStruct>>::init<pinned_init::__internal::InitClosure<ring_buf::big_struct::{closure#1}, ring_buf::BigStruct, core::convert::Infallible>>::{closure#0}, ring_buf::BigStruct, core::alloc::AllocError>>
Line
Count
Source
1283
1
    fn try_init<E>(init: impl Init<T, E>) -> Result<Self, E>
1284
1
    where
1285
1
        E: From<AllocError>,
1286
1
    {
1287
1
        let mut this = Arc::try_new_uninit()
?0
;
1288
1
        let slot = unsafe { Arc::get_mut_unchecked(&mut this) };
1289
1
        let slot = slot.as_mut_ptr();
1290
1
        // SAFETY: when init errors/panics, slot will get deallocated but not dropped,
1291
1
        // slot is valid.
1292
1
        unsafe { init.__init(slot)
?0
};
1293
        // SAFETY: All fields have been initialized.
1294
1
        Ok(unsafe { this.assume_init() })
1295
1
    }
1296
}
1297
1298
/// Trait facilitating pinned destruction.
1299
///
1300
/// Use [`pinned_drop`] to implement this trait safely:
1301
///
1302
/// ```rust
1303
/// # #![feature(allocator_api, no_coverage)]
1304
/// # #[path = "../examples/mutex.rs"] mod mutex; use mutex::*;
1305
/// use pinned_init::*;
1306
/// use core::pin::Pin;
1307
/// #[pin_data(PinnedDrop)]
1308
/// struct Foo {
1309
///     #[pin]
1310
///     mtx: CMutex<usize>,
1311
/// }
1312
///
1313
/// #[pinned_drop]
1314
/// impl PinnedDrop for Foo {
1315
///     fn drop(self: Pin<&mut Self>) {
1316
///         println!("Foo is being dropped!");
1317
///     }
1318
/// }
1319
/// # let _ = Box::pin_init(pin_init!(Foo { mtx <- CMutex::new(0) }));
1320
/// ```
1321
///
1322
/// # Safety
1323
///
1324
/// This trait must be implemented via the [`pinned_drop`] proc-macro attribute on the impl.
1325
///
1326
/// [`pinned_drop`]: pinned_init_macro::pinned_drop
1327
pub unsafe trait PinnedDrop: __internal::HasPinData {
1328
    /// Executes the pinned destructor of this type.
1329
    ///
1330
    /// While this function is marked safe, it is actually unsafe to call it manually. For this
1331
    /// reason it takes an additional parameter. This type can only be constructed by `unsafe` code
1332
    /// and thus prevents this function from being called where it should not.
1333
    ///
1334
    /// This extra parameter will be generated by the `#[pinned_drop]` proc-macro attribute
1335
    /// automatically.
1336
    fn drop(self: Pin<&mut Self>, only_call_from_drop: __internal::OnlyCallFromDrop);
1337
}
1338
1339
/// Marker trait for types that can be initialized by writing just zeroes.
1340
///
1341
/// # Safety
1342
///
1343
/// The bit pattern consisting of only zeroes is a valid bit pattern for this type. In other words,
1344
/// this is not UB:
1345
///
1346
/// ```rust,ignore
1347
/// let val: Self = unsafe { core::mem::zeroed() };
1348
/// ```
1349
pub unsafe trait Zeroable {}
1350
1351
/// Create a new zeroed T.
1352
///
1353
/// The returned initializer will write `0x00` to every byte of the given `slot`.
1354
#[inline]
1355
136
pub fn zeroed<T: Zeroable, E>() -> impl Init<T, E> {
1356
136
    // SAFETY: Because `T: Zeroable`, all bytes zero is a valid bit pattern for `T`
1357
136
    // and because we write all zeroes, the memory is initialized.
1358
136
    unsafe {
1359
136
        init_from_closure(|slot: *mut T| {
1360
134
            slot.write_bytes(0, 1);
1361
134
            Ok(())
1362
136
        })
pinned_init::zeroed::<core::mem::maybe_uninit::MaybeUninit<u8>, core::convert::Infallible>::{closure#0}
Line
Count
Source
1359
2
        init_from_closure(|slot: *mut T| {
1360
2
            slot.write_bytes(0, 1);
1361
2
            Ok(())
1362
2
        })
Unexecuted instantiation: pinned_init::zeroed::<[u8; 1099511627776usize], core::convert::Infallible>::{closure#0}
pinned_init::zeroed::<[u8; 1048576usize], core::convert::Infallible>::{closure#0}
Line
Count
Source
1359
65
        init_from_closure(|slot: *mut T| {
1360
65
            slot.write_bytes(0, 1);
1361
65
            Ok(())
1362
65
        })
Unexecuted instantiation: pinned_init::zeroed::<_, _>::{closure#0}
Unexecuted instantiation: pinned_init::zeroed::<_, _>::{closure#0}
pinned_init::zeroed::<[u8; 1048576usize], core::convert::Infallible>::{closure#0}
Line
Count
Source
1359
65
        init_from_closure(|slot: *mut T| {
1360
65
            slot.write_bytes(0, 1);
1361
65
            Ok(())
1362
65
        })
pinned_init::zeroed::<core::mem::maybe_uninit::MaybeUninit<u8>, core::convert::Infallible>::{closure#0}
Line
Count
Source
1359
2
        init_from_closure(|slot: *mut T| {
1360
2
            slot.write_bytes(0, 1);
1361
2
            Ok(())
1362
2
        })
1363
136
    }
1364
136
}
pinned_init::zeroed::<[u8; 1099511627776usize], core::convert::Infallible>
Line
Count
Source
1355
2
pub fn zeroed<T: Zeroable, E>() -> impl Init<T, E> {
1356
2
    // SAFETY: Because `T: Zeroable`, all bytes zero is a valid bit pattern for `T`
1357
2
    // and because we write all zeroes, the memory is initialized.
1358
2
    unsafe {
1359
2
        init_from_closure(|slot: *mut T| {
1360
            slot.write_bytes(0, 1);
1361
            Ok(())
1362
2
        })
1363
2
    }
1364
2
}
pinned_init::zeroed::<[u8; 1048576usize], core::convert::Infallible>
Line
Count
Source
1355
65
pub fn zeroed<T: Zeroable, E>() -> impl Init<T, E> {
1356
65
    // SAFETY: Because `T: Zeroable`, all bytes zero is a valid bit pattern for `T`
1357
65
    // and because we write all zeroes, the memory is initialized.
1358
65
    unsafe {
1359
65
        init_from_closure(|slot: *mut T| {
1360
            slot.write_bytes(0, 1);
1361
            Ok(())
1362
65
        })
1363
65
    }
1364
65
}
pinned_init::zeroed::<core::mem::maybe_uninit::MaybeUninit<u8>, core::convert::Infallible>
Line
Count
Source
1355
2
pub fn zeroed<T: Zeroable, E>() -> impl Init<T, E> {
1356
2
    // SAFETY: Because `T: Zeroable`, all bytes zero is a valid bit pattern for `T`
1357
2
    // and because we write all zeroes, the memory is initialized.
1358
2
    unsafe {
1359
2
        init_from_closure(|slot: *mut T| {
1360
            slot.write_bytes(0, 1);
1361
            Ok(())
1362
2
        })
1363
2
    }
1364
2
}
Unexecuted instantiation: pinned_init::zeroed::<_, _>
Unexecuted instantiation: pinned_init::zeroed::<_, _>
pinned_init::zeroed::<core::mem::maybe_uninit::MaybeUninit<u8>, core::convert::Infallible>
Line
Count
Source
1355
2
pub fn zeroed<T: Zeroable, E>() -> impl Init<T, E> {
1356
2
    // SAFETY: Because `T: Zeroable`, all bytes zero is a valid bit pattern for `T`
1357
2
    // and because we write all zeroes, the memory is initialized.
1358
2
    unsafe {
1359
2
        init_from_closure(|slot: *mut T| {
1360
            slot.write_bytes(0, 1);
1361
            Ok(())
1362
2
        })
1363
2
    }
1364
2
}
pinned_init::zeroed::<[u8; 1048576usize], core::convert::Infallible>
Line
Count
Source
1355
65
pub fn zeroed<T: Zeroable, E>() -> impl Init<T, E> {
1356
65
    // SAFETY: Because `T: Zeroable`, all bytes zero is a valid bit pattern for `T`
1357
65
    // and because we write all zeroes, the memory is initialized.
1358
65
    unsafe {
1359
65
        init_from_closure(|slot: *mut T| {
1360
            slot.write_bytes(0, 1);
1361
            Ok(())
1362
65
        })
1363
65
    }
1364
65
}
1365
1366
macro_rules! impl_zeroable {
1367
    ($($(#[$attr:meta])*$({$($generics:tt)*})? $t:ty, )*) => {
1368
        $(
1369
            $(#[$attr])*
1370
            unsafe impl$($($generics)*)? Zeroable for $t {}
1371
        )*
1372
    };
1373
}
1374
1375
impl_zeroable! {
1376
    // SAFETY: All primitives that are allowed to be zero.
1377
    bool,
1378
    char,
1379
    u8, u16, u32, u64, u128, usize,
1380
    i8, i16, i32, i64, i128, isize,
1381
    f32, f64,
1382
1383
    // SAFETY: These are ZSTs, there is nothing to zero.
1384
    {<T: ?Sized>} PhantomData<T>, core::marker::PhantomPinned, Infallible, (),
1385
1386
    // SAFETY: Type is allowed to take any value, including all zeros.
1387
    {<T>} MaybeUninit<T>,
1388
1389
    // SAFETY: `T: Zeroable` and `UnsafeCell` is `repr(transparent)`.
1390
    {<T: ?Sized + Zeroable>} UnsafeCell<T>,
1391
1392
    // SAFETY: All zeros is equivalent to `None` (option layout optimization guarantee).
1393
    Option<NonZeroU8>, Option<NonZeroU16>, Option<NonZeroU32>, Option<NonZeroU64>,
1394
    Option<NonZeroU128>, Option<NonZeroUsize>,
1395
    Option<NonZeroI8>, Option<NonZeroI16>, Option<NonZeroI32>, Option<NonZeroI64>,
1396
    Option<NonZeroI128>, Option<NonZeroIsize>,
1397
1398
    // SAFETY: All zeros is equivalent to `None` (option layout optimization guarantee).
1399
    //
1400
    // In this case we are allowed to use `T: ?Sized`, since all zeros is the `None` variant.
1401
    {<T: ?Sized>} Option<NonNull<T>>,
1402
    #[cfg(feature = "alloc")]
1403
    {<T: ?Sized>} Option<Box<T>>,
1404
1405
    // SAFETY: `null` pointer is valid.
1406
    //
1407
    // We cannot use `T: ?Sized`, since the VTABLE pointer part of fat pointers is not allowed to be
1408
    // null.
1409
    //
1410
    // When `Pointee` gets stabilized, we could use
1411
    // `T: ?Sized where <T as Pointee>::Metadata: Zeroable`
1412
    {<T>} *mut T, {<T>} *const T,
1413
1414
    // SAFETY: `null` pointer is valid and the metadata part of these fat pointers is allowed to be
1415
    // zero.
1416
    {<T>} *mut [T], {<T>} *const [T], *mut str, *const str,
1417
1418
    // SAFETY: `T` is `Zeroable`.
1419
    {<const N: usize, T: Zeroable>} [T; N], {<T: Zeroable>} Wrapping<T>,
1420
}
1421
1422
macro_rules! impl_tuple_zeroable {
1423
    ($(,)?) => {};
1424
    ($first:ident, $($t:ident),* $(,)?) => {
1425
        // SAFETY: All elements are zeroable and padding can be zero.
1426
        unsafe impl<$first: Zeroable, $($t: Zeroable),*> Zeroable for ($first, $($t),*) {}
1427
        impl_tuple_zeroable!($($t),* ,);
1428
    }
1429
}
1430
1431
impl_tuple_zeroable!(A, B, C, D, E, F, G, H, I, J);
\ No newline at end of file diff --git a/coverage/9762db8666aae4a71263fb3c4affdaf962cf87f6/coverage/home/runner/work/pinned-init/pinned-init/src/macros.rs.html b/coverage/9762db8666aae4a71263fb3c4affdaf962cf87f6/coverage/home/runner/work/pinned-init/pinned-init/src/macros.rs.html new file mode 100644 index 0000000..37e9e80 --- /dev/null +++ b/coverage/9762db8666aae4a71263fb3c4affdaf962cf87f6/coverage/home/runner/work/pinned-init/pinned-init/src/macros.rs.html @@ -0,0 +1 @@ +

Coverage Report

Created: 2023-07-24 21:40

/home/runner/work/pinned-init/pinned-init/src/macros.rs
Line
Count
Source (jump to first uncovered line)
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
9
//! safe code! Use the public facing macros instead.
10
//!
11
//! This architecture has been chosen because the kernel does not yet have access to `syn` which
12
//! would make matters a lot easier for implementing these as proc-macros.
13
//!
14
//! # Macro expansion example
15
//!
16
//! This section is intended for readers trying to understand the macros in this module and the
17
//! `pin_init!` macros from `init.rs`.
18
//!
19
//! We will look at the following example:
20
//!
21
//! ```rust,ignore
22
//! # use kernel::init::*;
23
//! # use core::pin::Pin;
24
//! #[pin_data]
25
//! #[repr(C)]
26
//! struct Bar<T> {
27
//!     #[pin]
28
//!     t: T,
29
//!     pub x: usize,
30
//! }
31
//!
32
//! impl<T> Bar<T> {
33
//!     fn new(t: T) -> impl PinInit<Self> {
34
//!         pin_init!(Self { t, x: 0 })
35
//!     }
36
//! }
37
//!
38
//! #[pin_data(PinnedDrop)]
39
//! struct Foo {
40
//!     a: usize,
41
//!     #[pin]
42
//!     b: Bar<u32>,
43
//! }
44
//!
45
//! #[pinned_drop]
46
//! impl PinnedDrop for Foo {
47
//!     fn drop(self: Pin<&mut Self>) {
48
//!         pr_info!("{self:p} is getting dropped.");
49
//!     }
50
//! }
51
//!
52
//! let a = 42;
53
//! let initializer = pin_init!(Foo {
54
//!     a,
55
//!     b <- Bar::new(36),
56
//! });
57
//! ```
58
//!
59
//! This example includes the most common and important features of the pin-init API.
60
//!
61
//! Below you can find individual section about the different macro invocations. Here are some
62
//! general things we need to take into account when designing macros:
63
//! - use global paths, similarly to file paths, these start with the separator: `::core::panic!()`
64
//!   this ensures that the correct item is used, since users could define their own `mod core {}`
65
//!   and then their own `panic!` inside to execute arbitrary code inside of our macro.
66
//! - macro `unsafe` hygiene: we need to ensure that we do not expand arbitrary, user-supplied
67
//!   expressions inside of an `unsafe` block in the macro, because this would allow users to do
68
//!   `unsafe` operations without an associated `unsafe` block.
69
//!
70
//! ## `#[pin_data]` on `Bar`
71
//!
72
//! This macro is used to specify which fields are structurally pinned and which fields are not. It
73
//! is placed on the struct definition and allows `#[pin]` to be placed on the fields.
74
//!
75
//! Here is the definition of `Bar` from our example:
76
//!
77
//! ```rust,ignore
78
//! # use kernel::init::*;
79
//! #[pin_data]
80
//! #[repr(C)]
81
//! struct Bar<T> {
82
//!     #[pin]
83
//!     t: T,
84
//!     pub x: usize,
85
//! }
86
//! ```
87
//!
88
//! This expands to the following code:
89
//!
90
//! ```rust,ignore
91
//! // Firstly the normal definition of the struct, attributes are preserved:
92
//! #[repr(C)]
93
//! struct Bar<T> {
94
//!     t: T,
95
//!     pub x: usize,
96
//! }
97
//! // Then an anonymous constant is defined, this is because we do not want any code to access the
98
//! // types that we define inside:
99
//! const _: () = {
100
//!     // We define the pin-data carrying struct, it is a ZST and needs to have the same generics,
101
//!     // since we need to implement access functions for each field and thus need to know its
102
//!     // type.
103
//!     struct __ThePinData<T> {
104
//!         __phantom: ::core::marker::PhantomData<fn(Bar<T>) -> Bar<T>>,
105
//!     }
106
//!     // We implement `Copy` for the pin-data struct, since all functions it defines will take
107
//!     // `self` by value.
108
//!     impl<T> ::core::clone::Clone for __ThePinData<T> {
109
//!         fn clone(&self) -> Self {
110
//!             *self
111
//!         }
112
//!     }
113
//!     impl<T> ::core::marker::Copy for __ThePinData<T> {}
114
//!     // For every field of `Bar`, the pin-data struct will define a function with the same name
115
//!     // and accessor (`pub` or `pub(crate)` etc.). This function will take a pointer to the
116
//!     // field (`slot`) and a `PinInit` or `Init` depending on the projection kind of the field
117
//!     // (if pinning is structural for the field, then `PinInit` otherwise `Init`).
118
//!     #[allow(dead_code)]
119
//!     impl<T> __ThePinData<T> {
120
//!         unsafe fn t<E>(
121
//!             self,
122
//!             slot: *mut T,
123
//!             // Since `t` is `#[pin]`, this is `PinInit`.
124
//!             init: impl ::kernel::init::PinInit<T, E>,
125
//!         ) -> ::core::result::Result<(), E> {
126
//!             unsafe { ::kernel::init::PinInit::__pinned_init(init, slot) }
127
//!         }
128
//!         pub unsafe fn x<E>(
129
//!             self,
130
//!             slot: *mut usize,
131
//!             // Since `x` is not `#[pin]`, this is `Init`.
132
//!             init: impl ::kernel::init::Init<usize, E>,
133
//!         ) -> ::core::result::Result<(), E> {
134
//!             unsafe { ::kernel::init::Init::__init(init, slot) }
135
//!         }
136
//!     }
137
//!     // Implement the internal `HasPinData` trait that associates `Bar` with the pin-data struct
138
//!     // that we constructed above.
139
//!     unsafe impl<T> ::kernel::init::__internal::HasPinData for Bar<T> {
140
//!         type PinData = __ThePinData<T>;
141
//!         unsafe fn __pin_data() -> Self::PinData {
142
//!             __ThePinData {
143
//!                 __phantom: ::core::marker::PhantomData,
144
//!             }
145
//!         }
146
//!     }
147
//!     // Implement the internal `PinData` trait that marks the pin-data struct as a pin-data
148
//!     // struct. This is important to ensure that no user can implement a rouge `__pin_data`
149
//!     // function without using `unsafe`.
150
//!     unsafe impl<T> ::kernel::init::__internal::PinData for __ThePinData<T> {
151
//!         type Datee = Bar<T>;
152
//!     }
153
//!     // Now we only want to implement `Unpin` for `Bar` when every structurally pinned field is
154
//!     // `Unpin`. In other words, whether `Bar` is `Unpin` only depends on structurally pinned
155
//!     // fields (those marked with `#[pin]`). These fields will be listed in this struct, in our
156
//!     // case no such fields exist, hence this is almost empty. The two phantomdata fields exist
157
//!     // for two reasons:
158
//!     // - `__phantom`: every generic must be used, since we cannot really know which generics
159
//!     //   are used, we declere all and then use everything here once.
160
//!     // - `__phantom_pin`: uses the `'__pin` lifetime and ensures that this struct is invariant
161
//!     //   over it. The lifetime is needed to work around the limitation that trait bounds must
162
//!     //   not be trivial, e.g. the user has a `#[pin] PhantomPinned` field -- this is
163
//!     //   unconditionally `!Unpin` and results in an error. The lifetime tricks the compiler
164
//!     //   into accepting these bounds regardless.
165
//!     #[allow(dead_code)]
166
//!     struct __Unpin<'__pin, T> {
167
//!         __phantom_pin: ::core::marker::PhantomData<fn(&'__pin ()) -> &'__pin ()>,
168
//!         __phantom: ::core::marker::PhantomData<fn(Bar<T>) -> Bar<T>>,
169
//!         // Our only `#[pin]` field is `t`.
170
//!         t: T,
171
//!     }
172
//!     #[doc(hidden)]
173
//!     impl<'__pin, T> ::core::marker::Unpin for Bar<T>
174
//!     where
175
//!         __Unpin<'__pin, T>: ::core::marker::Unpin,
176
//!     {}
177
//!     // Now we need to ensure that `Bar` does not implement `Drop`, since that would give users
178
//!     // access to `&mut self` inside of `drop` even if the struct was pinned. This could lead to
179
//!     // UB with only safe code, so we disallow this by giving a trait implementation error using
180
//!     // a direct impl and a blanket implementation.
181
//!     trait MustNotImplDrop {}
182
//!     // Normally `Drop` bounds do not have the correct semantics, but for this purpose they do
183
//!     // (normally people want to know if a type has any kind of drop glue at all, here we want
184
//!     // to know if it has any kind of custom drop glue, which is exactly what this bound does).
185
//!     #[allow(drop_bounds)]
186
//!     impl<T: ::core::ops::Drop> MustNotImplDrop for T {}
187
//!     impl<T> MustNotImplDrop for Bar<T> {}
188
//!     // Here comes a convenience check, if one implemented `PinnedDrop`, but forgot to add it to
189
//!     // `#[pin_data]`, then this will error with the same mechanic as above, this is not needed
190
//!     // for safety, but a good sanity check, since no normal code calls `PinnedDrop::drop`.
191
//!     #[allow(non_camel_case_types)]
192
//!     trait UselessPinnedDropImpl_you_need_to_specify_PinnedDrop {}
193
//!     impl<
194
//!         T: ::kernel::init::PinnedDrop,
195
//!     > UselessPinnedDropImpl_you_need_to_specify_PinnedDrop for T {}
196
//!     impl<T> UselessPinnedDropImpl_you_need_to_specify_PinnedDrop for Bar<T> {}
197
//! };
198
//! ```
199
//!
200
//! ## `pin_init!` in `impl Bar`
201
//!
202
//! This macro creates an pin-initializer for the given struct. It requires that the struct is
203
//! annotated by `#[pin_data]`.
204
//!
205
//! Here is the impl on `Bar` defining the new function:
206
//!
207
//! ```rust,ignore
208
//! impl<T> Bar<T> {
209
//!     fn new(t: T) -> impl PinInit<Self> {
210
//!         pin_init!(Self { t, x: 0 })
211
//!     }
212
//! }
213
//! ```
214
//!
215
//! This expands to the following code:
216
//!
217
//! ```rust,ignore
218
//! impl<T> Bar<T> {
219
//!     fn new(t: T) -> impl PinInit<Self> {
220
//!         {
221
//!             // We do not want to allow arbitrary returns, so we declare this type as the `Ok`
222
//!             // return type and shadow it later when we insert the arbitrary user code. That way
223
//!             // there will be no possibility of returning without `unsafe`.
224
//!             struct __InitOk;
225
//!             // Get the data about fields from the supplied type.
226
//!             // - the function is unsafe, hence the unsafe block
227
//!             // - we `use` the `HasPinData` trait in the block, it is only available in that
228
//!             //   scope.
229
//!             let data = unsafe {
230
//!                 use ::kernel::init::__internal::HasPinData;
231
//!                 Self::__pin_data()
232
//!             };
233
//!             // Ensure that `data` really is of type `PinData` and help with type inference:
234
//!             let init = ::kernel::init::__internal::PinData::make_closure::<
235
//!                 _,
236
//!                 __InitOk,
237
//!                 ::core::convert::Infallible,
238
//!             >(data, move |slot| {
239
//!                 {
240
//!                     // Shadow the structure so it cannot be used to return early. If a user
241
//!                     // tries to write `return Ok(__InitOk)`, then they get a type error,
242
//!                     // since that will refer to this struct instead of the one defined
243
//!                     // above.
244
//!                     struct __InitOk;
245
//!                     // This is the expansion of `t,`, which is syntactic sugar for `t: t,`.
246
//!                     {
247
//!                         unsafe { ::core::ptr::write(::core::addr_of_mut!((*slot).t), t) };
248
//!                     }
249
//!                     // Since initialization could fail later (not in this case, since the
250
//!                     // error type is `Infallible`) we will need to drop this field if there
251
//!                     // is an error later. This `DropGuard` will drop the field when it gets
252
//!                     // dropped and has not yet been forgotten.
253
//!                     let t = unsafe {
254
//!                         ::pinned_init::__internal::DropGuard::new(::core::addr_of_mut!((*slot).t))
255
//!                     };
256
//!                     // Expansion of `x: 0,`:
257
//!                     // Since this can be an arbitrary expression we cannot place it inside
258
//!                     // of the `unsafe` block, so we bind it here.
259
//!                     {
260
//!                         let x = 0;
261
//!                         unsafe { ::core::ptr::write(::core::addr_of_mut!((*slot).x), x) };
262
//!                     }
263
//!                     // We again create a `DropGuard`.
264
//!                     let x = unsafe {
265
//!                         ::kernel::init::__internal::DropGuard::new(::core::addr_of_mut!((*slot).x))
266
//!                     };
267
//!                     // Since initialization has successfully completed, we can now forget
268
//!                     // the guards. This is not `mem::forget`, since we only have
269
//!                     // `&DropGuard`.
270
//!                     ::core::mem::forget(x);
271
//!                     ::core::mem::forget(t);
272
//!                     // Here we use the type checker to ensure that every field has been
273
//!                     // initialized exactly once, since this is `if false` it will never get
274
//!                     // executed, but still type-checked.
275
//!                     // Additionally we abuse `slot` to automatically infer the correct type
276
//!                     // for the struct. This is also another check that every field is
277
//!                     // accessible from this scope.
278
//!                     #[allow(unreachable_code, clippy::diverging_sub_expression)]
279
//!                     let _ = || {
280
//!                         unsafe {
281
//!                             ::core::ptr::write(
282
//!                                 slot,
283
//!                                 Self {
284
//!                                     // We only care about typecheck finding every field
285
//!                                     // here, the expression does not matter, just conjure
286
//!                                     // one using `panic!()`:
287
//!                                     t: ::core::panic!(),
288
//!                                     x: ::core::panic!(),
289
//!                                 },
290
//!                             );
291
//!                         };
292
//!                     };
293
//!                 }
294
//!                 // We leave the scope above and gain access to the previously shadowed
295
//!                 // `__InitOk` that we need to return.
296
//!                 Ok(__InitOk)
297
//!             });
298
//!             // Change the return type from `__InitOk` to `()`.
299
//!             let init = move |
300
//!                 slot,
301
//!             | -> ::core::result::Result<(), ::core::convert::Infallible> {
302
//!                 init(slot).map(|__InitOk| ())
303
//!             };
304
//!             // Construct the initializer.
305
//!             let init = unsafe {
306
//!                 ::kernel::init::pin_init_from_closure::<
307
//!                     _,
308
//!                     ::core::convert::Infallible,
309
//!                 >(init)
310
//!             };
311
//!             init
312
//!         }
313
//!     }
314
//! }
315
//! ```
316
//!
317
//! ## `#[pin_data]` on `Foo`
318
//!
319
//! Since we already took a look at `#[pin_data]` on `Bar`, this section will only explain the
320
//! differences/new things in the expansion of the `Foo` definition:
321
//!
322
//! ```rust,ignore
323
//! #[pin_data(PinnedDrop)]
324
//! struct Foo {
325
//!     a: usize,
326
//!     #[pin]
327
//!     b: Bar<u32>,
328
//! }
329
//! ```
330
//!
331
//! This expands to the following code:
332
//!
333
//! ```rust,ignore
334
//! struct Foo {
335
//!     a: usize,
336
//!     b: Bar<u32>,
337
//! }
338
//! const _: () = {
339
//!     struct __ThePinData {
340
//!         __phantom: ::core::marker::PhantomData<fn(Foo) -> Foo>,
341
//!     }
342
//!     impl ::core::clone::Clone for __ThePinData {
343
//!         fn clone(&self) -> Self {
344
//!             *self
345
//!         }
346
//!     }
347
//!     impl ::core::marker::Copy for __ThePinData {}
348
//!     #[allow(dead_code)]
349
//!     impl __ThePinData {
350
//!         unsafe fn b<E>(
351
//!             self,
352
//!             slot: *mut Bar<u32>,
353
//!             init: impl ::kernel::init::PinInit<Bar<u32>, E>,
354
//!         ) -> ::core::result::Result<(), E> {
355
//!             unsafe { ::kernel::init::PinInit::__pinned_init(init, slot) }
356
//!         }
357
//!         unsafe fn a<E>(
358
//!             self,
359
//!             slot: *mut usize,
360
//!             init: impl ::kernel::init::Init<usize, E>,
361
//!         ) -> ::core::result::Result<(), E> {
362
//!             unsafe { ::kernel::init::Init::__init(init, slot) }
363
//!         }
364
//!     }
365
//!     unsafe impl ::kernel::init::__internal::HasPinData for Foo {
366
//!         type PinData = __ThePinData;
367
//!         unsafe fn __pin_data() -> Self::PinData {
368
//!             __ThePinData {
369
//!                 __phantom: ::core::marker::PhantomData,
370
//!             }
371
//!         }
372
//!     }
373
//!     unsafe impl ::kernel::init::__internal::PinData for __ThePinData {
374
//!         type Datee = Foo;
375
//!     }
376
//!     #[allow(dead_code)]
377
//!     struct __Unpin<'__pin> {
378
//!         __phantom_pin: ::core::marker::PhantomData<fn(&'__pin ()) -> &'__pin ()>,
379
//!         __phantom: ::core::marker::PhantomData<fn(Foo) -> Foo>,
380
//!         b: Bar<u32>,
381
//!     }
382
//!     #[doc(hidden)]
383
//!     impl<'__pin> ::core::marker::Unpin for Foo
384
//!     where
385
//!         __Unpin<'__pin>: ::core::marker::Unpin,
386
//!     {}
387
//!     // Since we specified `PinnedDrop` as the argument to `#[pin_data]`, we expect `Foo` to
388
//!     // implement `PinnedDrop`. Thus we do not need to prevent `Drop` implementations like
389
//!     // before, instead we implement `Drop` here and delegate to `PinnedDrop`.
390
//!     impl ::core::ops::Drop for Foo {
391
//!         fn drop(&mut self) {
392
//!             // Since we are getting dropped, no one else has a reference to `self` and thus we
393
//!             // can assume that we never move.
394
//!             let pinned = unsafe { ::core::pin::Pin::new_unchecked(self) };
395
//!             // Create the unsafe token that proves that we are inside of a destructor, this
396
//!             // type is only allowed to be created in a destructor.
397
//!             let token = unsafe { ::kernel::init::__internal::OnlyCallFromDrop::new() };
398
//!             ::kernel::init::PinnedDrop::drop(pinned, token);
399
//!         }
400
//!     }
401
//! };
402
//! ```
403
//!
404
//! ## `#[pinned_drop]` on `impl PinnedDrop for Foo`
405
//!
406
//! This macro is used to implement the `PinnedDrop` trait, since that trait is `unsafe` and has an
407
//! extra parameter that should not be used at all. The macro hides that parameter.
408
//!
409
//! Here is the `PinnedDrop` impl for `Foo`:
410
//!
411
//! ```rust,ignore
412
//! #[pinned_drop]
413
//! impl PinnedDrop for Foo {
414
//!     fn drop(self: Pin<&mut Self>) {
415
//!         pr_info!("{self:p} is getting dropped.");
416
//!     }
417
//! }
418
//! ```
419
//!
420
//! This expands to the following code:
421
//!
422
//! ```rust,ignore
423
//! // `unsafe`, full path and the token parameter are added, everything else stays the same.
424
//! unsafe impl ::kernel::init::PinnedDrop for Foo {
425
//!     fn drop(self: Pin<&mut Self>, _: ::kernel::init::__internal::OnlyCallFromDrop) {
426
//!         pr_info!("{self:p} is getting dropped.");
427
//!     }
428
//! }
429
//! ```
430
//!
431
//! ## `pin_init!` on `Foo`
432
//!
433
//! Since we already took a look at `pin_init!` on `Bar`, this section will only show the expansion
434
//! of `pin_init!` on `Foo`:
435
//!
436
//! ```rust,ignore
437
//! let a = 42;
438
//! let initializer = pin_init!(Foo {
439
//!     a,
440
//!     b <- Bar::new(36),
441
//! });
442
//! ```
443
//!
444
//! This expands to the following code:
445
//!
446
//! ```rust,ignore
447
//! let a = 42;
448
//! let initializer = {
449
//!     struct __InitOk;
450
//!     let data = unsafe {
451
//!         use ::kernel::init::__internal::HasPinData;
452
//!         Foo::__pin_data()
453
//!     };
454
//!     let init = ::kernel::init::__internal::PinData::make_closure::<
455
//!         _,
456
//!         __InitOk,
457
//!         ::core::convert::Infallible,
458
//!     >(data, move |slot| {
459
//!         {
460
//!             struct __InitOk;
461
//!             {
462
//!                 unsafe { ::core::ptr::write(::core::addr_of_mut!((*slot).a), a) };
463
//!             }
464
//!             let a = unsafe {
465
//!                 ::kernel::init::__internal::DropGuard::new(::core::addr_of_mut!((*slot).a))
466
//!             };
467
//!             let init = Bar::new(36);
468
//!             unsafe { data.b(::core::addr_of_mut!((*slot).b), b)? };
469
//!             let b = unsafe {
470
//!                 ::kernel::init::__internal::DropGuard::new(::core::addr_of_mut!((*slot).b))
471
//!             };
472
//!             ::core::mem::forget(b);
473
//!             ::core::mem::forget(a);
474
//!             #[allow(unreachable_code, clippy::diverging_sub_expression)]
475
//!             let _ = || {
476
//!                 unsafe {
477
//!                     ::core::ptr::write(
478
//!                         slot,
479
//!                         Foo {
480
//!                             a: ::core::panic!(),
481
//!                             b: ::core::panic!(),
482
//!                         },
483
//!                     );
484
//!                 };
485
//!             };
486
//!         }
487
//!         Ok(__InitOk)
488
//!     });
489
//!     let init = move |
490
//!         slot,
491
//!     | -> ::core::result::Result<(), ::core::convert::Infallible> {
492
//!         init(slot).map(|__InitOk| ())
493
//!     };
494
//!     let init = unsafe {
495
//!         ::kernel::init::pin_init_from_closure::<_, ::core::convert::Infallible>(init)
496
//!     };
497
//!     init
498
//! };
499
//! ```
500
501
/// Creates a `unsafe impl<...> PinnedDrop for $type` block.
502
///
503
/// See [`PinnedDrop`] for more information.
504
#[doc(hidden)]
505
#[macro_export]
506
macro_rules! __pinned_drop {
507
    (
508
        @impl_sig($($impl_sig:tt)*),
509
        @impl_body(
510
            $(#[$($attr:tt)*])*
511
            fn drop($($sig:tt)*) {
512
                $($inner:tt)*
513
            }
514
        ),
515
    ) => {
516
        unsafe $($impl_sig)* {
517
            // Inherit all attributes and the type/ident tokens for the signature.
518
            $(#[$($attr)*])*
519
47.0k
            
fn drop($($sig)*, _: $crate::__internal::OnlyCallFromDrop) 1
{
520
47.0k
                $($inner)*
521
47.0k
            
}46.8k
<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize> as pinned_init::PinnedDrop>::drop
Line
Count
Source
519
64
            fn drop($($sig)*, _: $crate::__internal::OnlyCallFromDrop) {
520
64
                $($inner)*
521
64
            }
Unexecuted instantiation: <alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::EvenU64, 4usize> as pinned_init::PinnedDrop>::drop
Unexecuted instantiation: <alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize> as pinned_init::PinnedDrop>::drop
Unexecuted instantiation: <alloc_fail::ring_buf::RingBuffer<u8, 64usize> as pinned_init::PinnedDrop>::drop
<alloc_fail::ring_buf::mutex::linked_list::ListHead as pinned_init::PinnedDrop>::drop
Line
Count
Source
519
9.61k
            fn drop($($sig)*, _: $crate::__internal::OnlyCallFromDrop) {
520
9.61k
                $($inner)*
521
9.61k
            }
<ring_buf::mutex::linked_list::ListHead as pinned_init::PinnedDrop>::drop
Line
Count
Source
519
14.4k
            fn drop($($sig)*, _: $crate::__internal::OnlyCallFromDrop) {
520
14.4k
                $($inner)*
521
14.4k
            }
<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize> as pinned_init::PinnedDrop>::drop
Line
Count
Source
519
64
            fn drop($($sig)*, _: $crate::__internal::OnlyCallFromDrop) {
520
64
                $($inner)*
521
64
            }
Unexecuted instantiation: <ring_buf::RingBuffer<u8, 64usize> as pinned_init::PinnedDrop>::drop
Unexecuted instantiation: <ring_buf::RingBuffer<ring_buf::EvenU64, 4usize> as pinned_init::PinnedDrop>::drop
<linked_list::ListHead as pinned_init::PinnedDrop>::drop
Line
Count
Source
519
5
            fn drop($($sig)*, _: $crate::__internal::OnlyCallFromDrop) {
520
5
                $($inner)*
521
5
            }
<mutex::linked_list::ListHead as pinned_init::PinnedDrop>::drop
Line
Count
Source
519
10.1k
            fn drop($($sig)*, _: $crate::__internal::OnlyCallFromDrop) {
520
10.1k
                $($inner)*
521
10.1k
            }
<static_init::mutex::linked_list::ListHead as pinned_init::PinnedDrop>::drop
Line
Count
Source
519
12.6k
            fn drop($($sig)*, _: $crate::__internal::OnlyCallFromDrop) {
520
12.6k
                $($inner)*
521
12.6k
            }
522
        }
523
    }
524
}
525
526
/// This macro first parses the struct definition such that it separates pinned and not pinned
527
/// fields. Afterwards it declares the struct and implement the `PinData` trait safely.
528
#[doc(hidden)]
529
#[macro_export]
530
macro_rules! __pin_data {
531
    // Proc-macro entry point, this is supplied by the proc-macro pre-parsing.
532
    (parse_input:
533
        @args($($pinned_drop:ident)?),
534
        @sig(
535
            $(#[$($struct_attr:tt)*])*
536
            $vis:vis struct $name:ident
537
            $(where $($whr:tt)*)?
538
        ),
539
        @impl_generics($($impl_generics:tt)*),
540
        @ty_generics($($ty_generics:tt)*),
541
        @body({ $($fields:tt)* }),
542
    ) => {
543
        // We now use token munching to iterate through all of the fields. While doing this we
544
        // identify fields marked with `#[pin]`, these fields are the 'pinned fields'. The user
545
        // wants these to be structurally pinned. The rest of the fields are the
546
        // 'not pinned fields'. Additionally we collect all fields, since we need them in the right
547
        // order to declare the struct.
548
        //
549
        // In this call we also put some explaining comments for the parameters.
550
        $crate::__pin_data!(find_pinned_fields:
551
            // Attributes on the struct itself, these will just be propagated to be put onto the
552
            // struct definition.
553
            @struct_attrs($(#[$($struct_attr)*])*),
554
            // The visibility of the struct.
555
            @vis($vis),
556
            // The name of the struct.
557
            @name($name),
558
            // The 'impl generics', the generics that will need to be specified on the struct inside
559
            // of an `impl<$ty_generics>` block.
560
            @impl_generics($($impl_generics)*),
561
            // The 'ty generics', the generics that will need to be specified on the impl blocks.
562
            @ty_generics($($ty_generics)*),
563
            // The where clause of any impl block and the declaration.
564
            @where($($($whr)*)?),
565
            // The remaining fields tokens that need to be processed.
566
            // We add a `,` at the end to ensure correct parsing.
567
            @fields_munch($($fields)* ,),
568
            // The pinned fields.
569
            @pinned(),
570
            // The not pinned fields.
571
            @not_pinned(),
572
            // All fields.
573
            @fields(),
574
            // The accumulator containing all attributes already parsed.
575
            @accum(),
576
            // Contains `yes` or `` to indicate if `#[pin]` was found on the current field.
577
            @is_pinned(),
578
            // The proc-macro argument, this should be `PinnedDrop` or ``.
579
            @pinned_drop($($pinned_drop)?),
580
        );
581
    };
582
    (find_pinned_fields:
583
        @struct_attrs($($struct_attrs:tt)*),
584
        @vis($vis:vis),
585
        @name($name:ident),
586
        @impl_generics($($impl_generics:tt)*),
587
        @ty_generics($($ty_generics:tt)*),
588
        @where($($whr:tt)*),
589
        // We found a PhantomPinned field, this should generally be pinned!
590
        @fields_munch($field:ident : $($($(::)?core::)?marker::)?PhantomPinned, $($rest:tt)*),
591
        @pinned($($pinned:tt)*),
592
        @not_pinned($($not_pinned:tt)*),
593
        @fields($($fields:tt)*),
594
        @accum($($accum:tt)*),
595
        // This field is not pinned.
596
        @is_pinned(),
597
        @pinned_drop($($pinned_drop:ident)?),
598
    ) => {
599
        ::core::compile_error!(concat!(
600
            "The field `",
601
            stringify!($field),
602
            "` of type `PhantomPinned` only has an effect, if it has the `#[pin]` attribute.",
603
        ));
604
        $crate::__pin_data!(find_pinned_fields:
605
            @struct_attrs($($struct_attrs)*),
606
            @vis($vis),
607
            @name($name),
608
            @impl_generics($($impl_generics)*),
609
            @ty_generics($($ty_generics)*),
610
            @where($($whr)*),
611
            @fields_munch($($rest)*),
612
            @pinned($($pinned)* $($accum)* $field: ::core::marker::PhantomPinned,),
613
            @not_pinned($($not_pinned)*),
614
            @fields($($fields)* $($accum)* $field: ::core::marker::PhantomPinned,),
615
            @accum(),
616
            @is_pinned(),
617
            @pinned_drop($($pinned_drop)?),
618
        );
619
    };
620
    (find_pinned_fields:
621
        @struct_attrs($($struct_attrs:tt)*),
622
        @vis($vis:vis),
623
        @name($name:ident),
624
        @impl_generics($($impl_generics:tt)*),
625
        @ty_generics($($ty_generics:tt)*),
626
        @where($($whr:tt)*),
627
        // We reached the field declaration.
628
        @fields_munch($field:ident : $type:ty, $($rest:tt)*),
629
        @pinned($($pinned:tt)*),
630
        @not_pinned($($not_pinned:tt)*),
631
        @fields($($fields:tt)*),
632
        @accum($($accum:tt)*),
633
        // This field is pinned.
634
        @is_pinned(yes),
635
        @pinned_drop($($pinned_drop:ident)?),
636
    ) => {
637
        $crate::__pin_data!(find_pinned_fields:
638
            @struct_attrs($($struct_attrs)*),
639
            @vis($vis),
640
            @name($name),
641
            @impl_generics($($impl_generics)*),
642
            @ty_generics($($ty_generics)*),
643
            @where($($whr)*),
644
            @fields_munch($($rest)*),
645
            @pinned($($pinned)* $($accum)* $field: $type,),
646
            @not_pinned($($not_pinned)*),
647
            @fields($($fields)* $($accum)* $field: $type,),
648
            @accum(),
649
            @is_pinned(),
650
            @pinned_drop($($pinned_drop)?),
651
        );
652
    };
653
    (find_pinned_fields:
654
        @struct_attrs($($struct_attrs:tt)*),
655
        @vis($vis:vis),
656
        @name($name:ident),
657
        @impl_generics($($impl_generics:tt)*),
658
        @ty_generics($($ty_generics:tt)*),
659
        @where($($whr:tt)*),
660
        // We reached the field declaration.
661
        @fields_munch($field:ident : $type:ty, $($rest:tt)*),
662
        @pinned($($pinned:tt)*),
663
        @not_pinned($($not_pinned:tt)*),
664
        @fields($($fields:tt)*),
665
        @accum($($accum:tt)*),
666
        // This field is not pinned.
667
        @is_pinned(),
668
        @pinned_drop($($pinned_drop:ident)?),
669
    ) => {
670
        $crate::__pin_data!(find_pinned_fields:
671
            @struct_attrs($($struct_attrs)*),
672
            @vis($vis),
673
            @name($name),
674
            @impl_generics($($impl_generics)*),
675
            @ty_generics($($ty_generics)*),
676
            @where($($whr)*),
677
            @fields_munch($($rest)*),
678
            @pinned($($pinned)*),
679
            @not_pinned($($not_pinned)* $($accum)* $field: $type,),
680
            @fields($($fields)* $($accum)* $field: $type,),
681
            @accum(),
682
            @is_pinned(),
683
            @pinned_drop($($pinned_drop)?),
684
        );
685
    };
686
    (find_pinned_fields:
687
        @struct_attrs($($struct_attrs:tt)*),
688
        @vis($vis:vis),
689
        @name($name:ident),
690
        @impl_generics($($impl_generics:tt)*),
691
        @ty_generics($($ty_generics:tt)*),
692
        @where($($whr:tt)*),
693
        // We found the `#[pin]` attr.
694
        @fields_munch(#[pin] $($rest:tt)*),
695
        @pinned($($pinned:tt)*),
696
        @not_pinned($($not_pinned:tt)*),
697
        @fields($($fields:tt)*),
698
        @accum($($accum:tt)*),
699
        @is_pinned($($is_pinned:ident)?),
700
        @pinned_drop($($pinned_drop:ident)?),
701
    ) => {
702
        $crate::__pin_data!(find_pinned_fields:
703
            @struct_attrs($($struct_attrs)*),
704
            @vis($vis),
705
            @name($name),
706
            @impl_generics($($impl_generics)*),
707
            @ty_generics($($ty_generics)*),
708
            @where($($whr)*),
709
            @fields_munch($($rest)*),
710
            // We do not include `#[pin]` in the list of attributes, since it is not actually an
711
            // attribute that is defined somewhere.
712
            @pinned($($pinned)*),
713
            @not_pinned($($not_pinned)*),
714
            @fields($($fields)*),
715
            @accum($($accum)*),
716
            // Set this to `yes`.
717
            @is_pinned(yes),
718
            @pinned_drop($($pinned_drop)?),
719
        );
720
    };
721
    (find_pinned_fields:
722
        @struct_attrs($($struct_attrs:tt)*),
723
        @vis($vis:vis),
724
        @name($name:ident),
725
        @impl_generics($($impl_generics:tt)*),
726
        @ty_generics($($ty_generics:tt)*),
727
        @where($($whr:tt)*),
728
        // We reached the field declaration with visibility, for simplicity we only munch the
729
        // visibility and put it into `$accum`.
730
        @fields_munch($fvis:vis $field:ident $($rest:tt)*),
731
        @pinned($($pinned:tt)*),
732
        @not_pinned($($not_pinned:tt)*),
733
        @fields($($fields:tt)*),
734
        @accum($($accum:tt)*),
735
        @is_pinned($($is_pinned:ident)?),
736
        @pinned_drop($($pinned_drop:ident)?),
737
    ) => {
738
        $crate::__pin_data!(find_pinned_fields:
739
            @struct_attrs($($struct_attrs)*),
740
            @vis($vis),
741
            @name($name),
742
            @impl_generics($($impl_generics)*),
743
            @ty_generics($($ty_generics)*),
744
            @where($($whr)*),
745
            @fields_munch($field $($rest)*),
746
            @pinned($($pinned)*),
747
            @not_pinned($($not_pinned)*),
748
            @fields($($fields)*),
749
            @accum($($accum)* $fvis),
750
            @is_pinned($($is_pinned)?),
751
            @pinned_drop($($pinned_drop)?),
752
        );
753
    };
754
    (find_pinned_fields:
755
        @struct_attrs($($struct_attrs:tt)*),
756
        @vis($vis:vis),
757
        @name($name:ident),
758
        @impl_generics($($impl_generics:tt)*),
759
        @ty_generics($($ty_generics:tt)*),
760
        @where($($whr:tt)*),
761
        // Some other attribute, just put it into `$accum`.
762
        @fields_munch(#[$($attr:tt)*] $($rest:tt)*),
763
        @pinned($($pinned:tt)*),
764
        @not_pinned($($not_pinned:tt)*),
765
        @fields($($fields:tt)*),
766
        @accum($($accum:tt)*),
767
        @is_pinned($($is_pinned:ident)?),
768
        @pinned_drop($($pinned_drop:ident)?),
769
    ) => {
770
        $crate::__pin_data!(find_pinned_fields:
771
            @struct_attrs($($struct_attrs)*),
772
            @vis($vis),
773
            @name($name),
774
            @impl_generics($($impl_generics)*),
775
            @ty_generics($($ty_generics)*),
776
            @where($($whr)*),
777
            @fields_munch($($rest)*),
778
            @pinned($($pinned)*),
779
            @not_pinned($($not_pinned)*),
780
            @fields($($fields)*),
781
            @accum($($accum)* #[$($attr)*]),
782
            @is_pinned($($is_pinned)?),
783
            @pinned_drop($($pinned_drop)?),
784
        );
785
    };
786
    (find_pinned_fields:
787
        @struct_attrs($($struct_attrs:tt)*),
788
        @vis($vis:vis),
789
        @name($name:ident),
790
        @impl_generics($($impl_generics:tt)*),
791
        @ty_generics($($ty_generics:tt)*),
792
        @where($($whr:tt)*),
793
        // We reached the end of the fields, plus an optional additional comma, since we added one
794
        // before and the user is also allowed to put a trailing comma.
795
        @fields_munch($(,)?),
796
        @pinned($($pinned:tt)*),
797
        @not_pinned($($not_pinned:tt)*),
798
        @fields($($fields:tt)*),
799
        @accum(),
800
        @is_pinned(),
801
        @pinned_drop($($pinned_drop:ident)?),
802
    ) => {
803
        // Declare the struct with all fields in the correct order.
804
        $($struct_attrs)*
805
        $vis struct $name <$($impl_generics)*>
806
        where $($whr)*
807
        {
808
            $($fields)*
809
        }
810
811
        // We put the rest into this const item, because it then will not be accessible to anything
812
        // outside.
813
        const _: () = {
814
            // We declare this struct which will host all of the projection function for our type.
815
            // it will be invariant over all generic parameters which are inherited from the
816
            // struct.
817
            $vis struct __ThePinData<$($impl_generics)*>
818
            where $($whr)*
819
            {
820
                __phantom: ::core::marker::PhantomData<
821
                    fn($name<$($ty_generics)*>) -> $name<$($ty_generics)*>
822
                >,
823
            }
824
825
            impl<$($impl_generics)*> ::core::clone::Clone for __ThePinData<$($ty_generics)*>
826
            where $($whr)*
827
            {
828
                #[cfg_attr(coverage_nightly, no_coverage)]
829
                fn clone(&self) -> Self { *self }
830
            }
831
832
            impl<$($impl_generics)*> ::core::marker::Copy for __ThePinData<$($ty_generics)*>
833
            where $($whr)*
834
            {}
835
836
            // Make all projection functions.
837
            $crate::__pin_data!(make_pin_data:
838
                @pin_data(__ThePinData),
839
                @impl_generics($($impl_generics)*),
840
                @ty_generics($($ty_generics)*),
841
                @where($($whr)*),
842
                @pinned($($pinned)*),
843
                @not_pinned($($not_pinned)*),
844
            );
845
846
            // SAFETY: We have added the correct projection functions above to `__ThePinData` and
847
            // we also use the least restrictive generics possible.
848
            unsafe impl<$($impl_generics)*> $crate::__internal::HasPinData for $name<$($ty_generics)*>
849
            where $($whr)*
850
            {
851
                type PinData = __ThePinData<$($ty_generics)*>;
852
853
93.7k
                unsafe fn __pin_data() -> Self::PinData {
854
93.7k
                    __ThePinData { __phantom: ::core::marker::PhantomData }
855
93.7k
                }
<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize> as pinned_init::__internal::HasPinData>::__pin_data
Line
Count
Source
853
1
                unsafe fn __pin_data() -> Self::PinData {
854
1
                    __ThePinData { __phantom: ::core::marker::PhantomData }
855
1
                }
<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::EvenU64, 4usize> as pinned_init::__internal::HasPinData>::__pin_data
Line
Count
Source
853
1
                unsafe fn __pin_data() -> Self::PinData {
854
1
                    __ThePinData { __phantom: ::core::marker::PhantomData }
855
1
                }
<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize> as pinned_init::__internal::HasPinData>::__pin_data
Line
Count
Source
853
2
                unsafe fn __pin_data() -> Self::PinData {
854
2
                    __ThePinData { __phantom: ::core::marker::PhantomData }
855
2
                }
<alloc_fail::ring_buf::mutex::CMutex<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>> as pinned_init::__internal::HasPinData>::__pin_data
Line
Count
Source
853
1
                unsafe fn __pin_data() -> Self::PinData {
854
1
                    __ThePinData { __phantom: ::core::marker::PhantomData }
855
1
                }
<alloc_fail::ring_buf::mutex::CMutex<usize> as pinned_init::__internal::HasPinData>::__pin_data
Line
Count
Source
853
1
                unsafe fn __pin_data() -> Self::PinData {
854
1
                    __ThePinData { __phantom: ::core::marker::PhantomData }
855
1
                }
<alloc_fail::ring_buf::mutex::WaitEntry as pinned_init::__internal::HasPinData>::__pin_data
Line
Count
Source
853
9.60k
                unsafe fn __pin_data() -> Self::PinData {
854
9.60k
                    __ThePinData { __phantom: ::core::marker::PhantomData }
855
9.60k
                }
<alloc_fail::ring_buf::RingBuffer<u8, 64usize> as pinned_init::__internal::HasPinData>::__pin_data
Line
Count
Source
853
1
                unsafe fn __pin_data() -> Self::PinData {
854
1
                    __ThePinData { __phantom: ::core::marker::PhantomData }
855
1
                }
<alloc_fail::ring_buf::mutex::linked_list::ListHead as pinned_init::__internal::HasPinData>::__pin_data
Line
Count
Source
853
9.61k
                unsafe fn __pin_data() -> Self::PinData {
854
9.61k
                    __ThePinData { __phantom: ::core::marker::PhantomData }
855
9.61k
                }
<ring_buf::mutex::CMutex<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>> as pinned_init::__internal::HasPinData>::__pin_data
Line
Count
Source
853
1
                unsafe fn __pin_data() -> Self::PinData {
854
1
                    __ThePinData { __phantom: ::core::marker::PhantomData }
855
1
                }
<ring_buf::mutex::CMutex<usize> as pinned_init::__internal::HasPinData>::__pin_data
Line
Count
Source
853
1
                unsafe fn __pin_data() -> Self::PinData {
854
1
                    __ThePinData { __phantom: ::core::marker::PhantomData }
855
1
                }
<ring_buf::mutex::linked_list::ListHead as pinned_init::__internal::HasPinData>::__pin_data
Line
Count
Source
853
14.4k
                unsafe fn __pin_data() -> Self::PinData {
854
14.4k
                    __ThePinData { __phantom: ::core::marker::PhantomData }
855
14.4k
                }
<ring_buf::mutex::WaitEntry as pinned_init::__internal::HasPinData>::__pin_data
Line
Count
Source
853
14.4k
                unsafe fn __pin_data() -> Self::PinData {
854
14.4k
                    __ThePinData { __phantom: ::core::marker::PhantomData }
855
14.4k
                }
<ring_buf::RingBuffer<u8, 64usize> as pinned_init::__internal::HasPinData>::__pin_data
Line
Count
Source
853
1
                unsafe fn __pin_data() -> Self::PinData {
854
1
                    __ThePinData { __phantom: ::core::marker::PhantomData }
855
1
                }
<ring_buf::RingBuffer<ring_buf::EvenU64, 4usize> as pinned_init::__internal::HasPinData>::__pin_data
Line
Count
Source
853
1
                unsafe fn __pin_data() -> Self::PinData {
854
1
                    __ThePinData { __phantom: ::core::marker::PhantomData }
855
1
                }
<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize> as pinned_init::__internal::HasPinData>::__pin_data
Line
Count
Source
853
1
                unsafe fn __pin_data() -> Self::PinData {
854
1
                    __ThePinData { __phantom: ::core::marker::PhantomData }
855
1
                }
<linked_list::ListHead as pinned_init::__internal::HasPinData>::__pin_data
Line
Count
Source
853
5
                unsafe fn __pin_data() -> Self::PinData {
854
5
                    __ThePinData { __phantom: ::core::marker::PhantomData }
855
5
                }
<mutex::linked_list::ListHead as pinned_init::__internal::HasPinData>::__pin_data
Line
Count
Source
853
10.1k
                unsafe fn __pin_data() -> Self::PinData {
854
10.1k
                    __ThePinData { __phantom: ::core::marker::PhantomData }
855
10.1k
                }
<mutex::WaitEntry as pinned_init::__internal::HasPinData>::__pin_data
Line
Count
Source
853
10.1k
                unsafe fn __pin_data() -> Self::PinData {
854
10.1k
                    __ThePinData { __phantom: ::core::marker::PhantomData }
855
10.1k
                }
<mutex::CMutex<usize> as pinned_init::__internal::HasPinData>::__pin_data
Line
Count
Source
853
1
                unsafe fn __pin_data() -> Self::PinData {
854
1
                    __ThePinData { __phantom: ::core::marker::PhantomData }
855
1
                }
<pthread_mutex::pthread_mtx::PThreadMutex<usize> as pinned_init::__internal::HasPinData>::__pin_data
Line
Count
Source
853
1
                unsafe fn __pin_data() -> Self::PinData {
854
1
                    __ThePinData { __phantom: ::core::marker::PhantomData }
855
1
                }
<static_init::mutex::WaitEntry as pinned_init::__internal::HasPinData>::__pin_data
Line
Count
Source
853
12.6k
                unsafe fn __pin_data() -> Self::PinData {
854
12.6k
                    __ThePinData { __phantom: ::core::marker::PhantomData }
855
12.6k
                }
<static_init::mutex::linked_list::ListHead as pinned_init::__internal::HasPinData>::__pin_data
Line
Count
Source
853
12.6k
                unsafe fn __pin_data() -> Self::PinData {
854
12.6k
                    __ThePinData { __phantom: ::core::marker::PhantomData }
855
12.6k
                }
<static_init::mutex::CMutex<usize> as pinned_init::__internal::HasPinData>::__pin_data
Line
Count
Source
853
1
                unsafe fn __pin_data() -> Self::PinData {
854
1
                    __ThePinData { __phantom: ::core::marker::PhantomData }
855
1
                }
Unexecuted instantiation: <with_zero::Foo as pinned_init::__internal::HasPinData>::__pin_data
856
            }
857
858
            unsafe impl<$($impl_generics)*> $crate::__internal::PinData for __ThePinData<$($ty_generics)*>
859
            where $($whr)*
860
            {
861
                type Datee = $name<$($ty_generics)*>;
862
            }
863
864
            // This struct will be used for the unpin analysis. Since only structurally pinned
865
            // fields are relevant whether the struct should implement `Unpin`.
866
            #[allow(dead_code)]
867
            struct __Unpin <'__pin, $($impl_generics)*>
868
            where $($whr)*
869
            {
870
                __phantom_pin: ::core::marker::PhantomData<fn(&'__pin ()) -> &'__pin ()>,
871
                __phantom: ::core::marker::PhantomData<
872
                    fn($name<$($ty_generics)*>) -> $name<$($ty_generics)*>
873
                >,
874
                // Only the pinned fields.
875
                $($pinned)*
876
            }
877
878
            #[doc(hidden)]
879
            impl<'__pin, $($impl_generics)*> ::core::marker::Unpin for $name<$($ty_generics)*>
880
            where
881
                __Unpin<'__pin, $($ty_generics)*>: ::core::marker::Unpin,
882
                $($whr)*
883
            {}
884
885
            // We need to disallow normal `Drop` implementation, the exact behavior depends on
886
            // whether `PinnedDrop` was specified as the parameter.
887
            $crate::__pin_data!(drop_prevention:
888
                @name($name),
889
                @impl_generics($($impl_generics)*),
890
                @ty_generics($($ty_generics)*),
891
                @where($($whr)*),
892
                @pinned_drop($($pinned_drop)?),
893
            );
894
        };
895
    };
896
    // When no `PinnedDrop` was specified, then we have to prevent implementing drop.
897
    (drop_prevention:
898
        @name($name:ident),
899
        @impl_generics($($impl_generics:tt)*),
900
        @ty_generics($($ty_generics:tt)*),
901
        @where($($whr:tt)*),
902
        @pinned_drop(),
903
    ) => {
904
        // We prevent this by creating a trait that will be implemented for all types implementing
905
        // `Drop`. Additionally we will implement this trait for the struct leading to a conflict,
906
        // if it also implements `Drop`
907
        trait MustNotImplDrop {}
908
        #[allow(drop_bounds)]
909
        impl<T: ::core::ops::Drop> MustNotImplDrop for T {}
910
        impl<$($impl_generics)*> MustNotImplDrop for $name<$($ty_generics)*>
911
        where $($whr)* {}
912
        // We also take care to prevent users from writing a useless `PinnedDrop` implementation.
913
        // They might implement `PinnedDrop` correctly for the struct, but forget to give
914
        // `PinnedDrop` as the parameter to `#[pin_data]`.
915
        #[allow(non_camel_case_types)]
916
        trait UselessPinnedDropImpl_you_need_to_specify_PinnedDrop {}
917
        impl<T: $crate::PinnedDrop>
918
            UselessPinnedDropImpl_you_need_to_specify_PinnedDrop for T {}
919
        impl<$($impl_generics)*>
920
            UselessPinnedDropImpl_you_need_to_specify_PinnedDrop for $name<$($ty_generics)*>
921
        where $($whr)* {}
922
    };
923
    // When `PinnedDrop` was specified we just implement `Drop` and delegate.
924
    (drop_prevention:
925
        @name($name:ident),
926
        @impl_generics($($impl_generics:tt)*),
927
        @ty_generics($($ty_generics:tt)*),
928
        @where($($whr:tt)*),
929
        @pinned_drop(PinnedDrop),
930
    ) => {
931
        impl<$($impl_generics)*> ::core::ops::Drop for $name<$($ty_generics)*>
932
        where $($whr)*
933
        {
934
46.8k
            fn drop(&mut self) {
935
46.8k
                // SAFETY: Since this is a destructor, `self` will not move after this function
936
46.8k
                // terminates, since it is inaccessible.
937
46.8k
                let pinned = unsafe { ::core::pin::Pin::new_unchecked(self) };
938
46.8k
                // SAFETY: Since this is a drop function, we can create this token to call the
939
46.8k
                // pinned destructor of this type.
940
46.8k
                let token = unsafe { $crate::__internal::OnlyCallFromDrop::new() };
941
46.8k
                $crate::PinnedDrop::drop(pinned, token);
942
46.8k
            }
<alloc_fail::ring_buf::RingBuffer<u8, 64usize> as core::ops::drop::Drop>::drop
Line
Count
Source
934
1
            fn drop(&mut self) {
935
1
                // SAFETY: Since this is a destructor, `self` will not move after this function
936
1
                // terminates, since it is inaccessible.
937
1
                let pinned = unsafe { ::core::pin::Pin::new_unchecked(self) };
938
1
                // SAFETY: Since this is a drop function, we can create this token to call the
939
1
                // pinned destructor of this type.
940
1
                let token = unsafe { $crate::__internal::OnlyCallFromDrop::new() };
941
1
                $crate::PinnedDrop::drop(pinned, token);
942
1
            }
<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize> as core::ops::drop::Drop>::drop
Line
Count
Source
934
1
            fn drop(&mut self) {
935
1
                // SAFETY: Since this is a destructor, `self` will not move after this function
936
1
                // terminates, since it is inaccessible.
937
1
                let pinned = unsafe { ::core::pin::Pin::new_unchecked(self) };
938
1
                // SAFETY: Since this is a drop function, we can create this token to call the
939
1
                // pinned destructor of this type.
940
1
                let token = unsafe { $crate::__internal::OnlyCallFromDrop::new() };
941
1
                $crate::PinnedDrop::drop(pinned, token);
942
1
            }
<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::EvenU64, 4usize> as core::ops::drop::Drop>::drop
Line
Count
Source
934
1
            fn drop(&mut self) {
935
1
                // SAFETY: Since this is a destructor, `self` will not move after this function
936
1
                // terminates, since it is inaccessible.
937
1
                let pinned = unsafe { ::core::pin::Pin::new_unchecked(self) };
938
1
                // SAFETY: Since this is a drop function, we can create this token to call the
939
1
                // pinned destructor of this type.
940
1
                let token = unsafe { $crate::__internal::OnlyCallFromDrop::new() };
941
1
                $crate::PinnedDrop::drop(pinned, token);
942
1
            }
Unexecuted instantiation: <alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize> as core::ops::drop::Drop>::drop
<alloc_fail::ring_buf::mutex::linked_list::ListHead as core::ops::drop::Drop>::drop
Line
Count
Source
934
9.61k
            fn drop(&mut self) {
935
9.61k
                // SAFETY: Since this is a destructor, `self` will not move after this function
936
9.61k
                // terminates, since it is inaccessible.
937
9.61k
                let pinned = unsafe { ::core::pin::Pin::new_unchecked(self) };
938
9.61k
                // SAFETY: Since this is a drop function, we can create this token to call the
939
9.61k
                // pinned destructor of this type.
940
9.61k
                let token = unsafe { $crate::__internal::OnlyCallFromDrop::new() };
941
9.61k
                $crate::PinnedDrop::drop(pinned, token);
942
9.61k
            }
<ring_buf::mutex::linked_list::ListHead as core::ops::drop::Drop>::drop
Line
Count
Source
934
14.4k
            fn drop(&mut self) {
935
14.4k
                // SAFETY: Since this is a destructor, `self` will not move after this function
936
14.4k
                // terminates, since it is inaccessible.
937
14.4k
                let pinned = unsafe { ::core::pin::Pin::new_unchecked(self) };
938
14.4k
                // SAFETY: Since this is a drop function, we can create this token to call the
939
14.4k
                // pinned destructor of this type.
940
14.4k
                let token = unsafe { $crate::__internal::OnlyCallFromDrop::new() };
941
14.4k
                $crate::PinnedDrop::drop(pinned, token);
942
14.4k
            }
<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize> as core::ops::drop::Drop>::drop
Line
Count
Source
934
1
            fn drop(&mut self) {
935
1
                // SAFETY: Since this is a destructor, `self` will not move after this function
936
1
                // terminates, since it is inaccessible.
937
1
                let pinned = unsafe { ::core::pin::Pin::new_unchecked(self) };
938
1
                // SAFETY: Since this is a drop function, we can create this token to call the
939
1
                // pinned destructor of this type.
940
1
                let token = unsafe { $crate::__internal::OnlyCallFromDrop::new() };
941
1
                $crate::PinnedDrop::drop(pinned, token);
942
1
            }
<ring_buf::RingBuffer<ring_buf::EvenU64, 4usize> as core::ops::drop::Drop>::drop
Line
Count
Source
934
1
            fn drop(&mut self) {
935
1
                // SAFETY: Since this is a destructor, `self` will not move after this function
936
1
                // terminates, since it is inaccessible.
937
1
                let pinned = unsafe { ::core::pin::Pin::new_unchecked(self) };
938
1
                // SAFETY: Since this is a drop function, we can create this token to call the
939
1
                // pinned destructor of this type.
940
1
                let token = unsafe { $crate::__internal::OnlyCallFromDrop::new() };
941
1
                $crate::PinnedDrop::drop(pinned, token);
942
1
            }
<ring_buf::RingBuffer<u8, 64usize> as core::ops::drop::Drop>::drop
Line
Count
Source
934
1
            fn drop(&mut self) {
935
1
                // SAFETY: Since this is a destructor, `self` will not move after this function
936
1
                // terminates, since it is inaccessible.
937
1
                let pinned = unsafe { ::core::pin::Pin::new_unchecked(self) };
938
1
                // SAFETY: Since this is a drop function, we can create this token to call the
939
1
                // pinned destructor of this type.
940
1
                let token = unsafe { $crate::__internal::OnlyCallFromDrop::new() };
941
1
                $crate::PinnedDrop::drop(pinned, token);
942
1
            }
<linked_list::ListHead as core::ops::drop::Drop>::drop
Line
Count
Source
934
5
            fn drop(&mut self) {
935
5
                // SAFETY: Since this is a destructor, `self` will not move after this function
936
5
                // terminates, since it is inaccessible.
937
5
                let pinned = unsafe { ::core::pin::Pin::new_unchecked(self) };
938
5
                // SAFETY: Since this is a drop function, we can create this token to call the
939
5
                // pinned destructor of this type.
940
5
                let token = unsafe { $crate::__internal::OnlyCallFromDrop::new() };
941
5
                $crate::PinnedDrop::drop(pinned, token);
942
5
            }
<mutex::linked_list::ListHead as core::ops::drop::Drop>::drop
Line
Count
Source
934
10.1k
            fn drop(&mut self) {
935
10.1k
                // SAFETY: Since this is a destructor, `self` will not move after this function
936
10.1k
                // terminates, since it is inaccessible.
937
10.1k
                let pinned = unsafe { ::core::pin::Pin::new_unchecked(self) };
938
10.1k
                // SAFETY: Since this is a drop function, we can create this token to call the
939
10.1k
                // pinned destructor of this type.
940
10.1k
                let token = unsafe { $crate::__internal::OnlyCallFromDrop::new() };
941
10.1k
                $crate::PinnedDrop::drop(pinned, token);
942
10.1k
            }
<pthread_mutex::pthread_mtx::PThreadMutex<usize> as core::ops::drop::Drop>::drop
Line
Count
Source
934
1
            fn drop(&mut self) {
935
1
                // SAFETY: Since this is a destructor, `self` will not move after this function
936
1
                // terminates, since it is inaccessible.
937
1
                let pinned = unsafe { ::core::pin::Pin::new_unchecked(self) };
938
1
                // SAFETY: Since this is a drop function, we can create this token to call the
939
1
                // pinned destructor of this type.
940
1
                let token = unsafe { $crate::__internal::OnlyCallFromDrop::new() };
941
1
                $crate::PinnedDrop::drop(pinned, token);
942
1
            }
<static_init::mutex::linked_list::ListHead as core::ops::drop::Drop>::drop
Line
Count
Source
934
12.6k
            fn drop(&mut self) {
935
12.6k
                // SAFETY: Since this is a destructor, `self` will not move after this function
936
12.6k
                // terminates, since it is inaccessible.
937
12.6k
                let pinned = unsafe { ::core::pin::Pin::new_unchecked(self) };
938
12.6k
                // SAFETY: Since this is a drop function, we can create this token to call the
939
12.6k
                // pinned destructor of this type.
940
12.6k
                let token = unsafe { $crate::__internal::OnlyCallFromDrop::new() };
941
12.6k
                $crate::PinnedDrop::drop(pinned, token);
942
12.6k
            }
943
        }
944
    };
945
    // If some other parameter was specified, we emit a readable error.
946
    (drop_prevention:
947
        @name($name:ident),
948
        @impl_generics($($impl_generics:tt)*),
949
        @ty_generics($($ty_generics:tt)*),
950
        @where($($whr:tt)*),
951
        @pinned_drop($($rest:tt)*),
952
    ) => {
953
        compile_error!(
954
            "Wrong parameters to `#[pin_data]`, expected nothing or `PinnedDrop`, got '{}'.",
955
            stringify!($($rest)*),
956
        );
957
    };
958
    (make_pin_data:
959
        @pin_data($pin_data:ident),
960
        @impl_generics($($impl_generics:tt)*),
961
        @ty_generics($($ty_generics:tt)*),
962
        @where($($whr:tt)*),
963
        @pinned($($(#[$($p_attr:tt)*])* $pvis:vis $p_field:ident : $p_type:ty),* $(,)?),
964
        @not_pinned($($(#[$($attr:tt)*])* $fvis:vis $field:ident : $type:ty),* $(,)?),
965
    ) => {
966
        // For every field, we create a projection function according to its projection type. If a
967
        // field is structurally pinned, then it must be initialized via `PinInit`, if it is not
968
        // structurally pinned, then it can be initialized via `Init`.
969
        //
970
        // The functions are `unsafe` to prevent accidentally calling them.
971
        #[allow(dead_code)]
972
        impl<$($impl_generics)*> $pin_data<$($ty_generics)*>
973
        where $($whr)*
974
        {
975
            $(
976
                $(#[$($p_attr)*])*
977
46.8k
                $pvis unsafe fn $p_field<E>(
978
46.8k
                    self,
979
46.8k
                    slot: *mut $p_type,
980
46.8k
                    init: impl $crate::PinInit<$p_type, E>,
981
46.8k
                ) -> ::core::result::Result<(), E> {
982
46.8k
                    unsafe { $crate::PinInit::__pinned_init(init, slot) }
983
46.8k
                }
<alloc_fail::ring_buf::mutex::_::__ThePinData<usize>>::data::<core::convert::Infallible, pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::mutex::CMutex<usize>>::new<usize>::{closure#0}::{closure#1}, core::cell::UnsafeCell<usize>, core::convert::Infallible>>
Line
Count
Source
977
1
                $pvis unsafe fn $p_field<E>(
978
1
                    self,
979
1
                    slot: *mut $p_type,
980
1
                    init: impl $crate::PinInit<$p_type, E>,
981
1
                ) -> ::core::result::Result<(), E> {
982
1
                    unsafe { $crate::PinInit::__pinned_init(init, slot) }
983
1
                }
<alloc_fail::ring_buf::mutex::_::__ThePinData<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>>::wait_list::<core::convert::Infallible, pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::mutex::linked_list::ListHead>::new::{closure#1}, alloc_fail::ring_buf::mutex::linked_list::ListHead, core::convert::Infallible>>
Line
Count
Source
977
1
                $pvis unsafe fn $p_field<E>(
978
1
                    self,
979
1
                    slot: *mut $p_type,
980
1
                    init: impl $crate::PinInit<$p_type, E>,
981
1
                ) -> ::core::result::Result<(), E> {
982
1
                    unsafe { $crate::PinInit::__pinned_init(init, slot) }
983
1
                }
<alloc_fail::ring_buf::mutex::_::__ThePinData<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>>::data::<core::convert::Infallible, pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::mutex::CMutex<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>>::new<pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>::new::{closure#1}, alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>, core::convert::Infallible>>::{closure#0}::{closure#1}, core::cell::UnsafeCell<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>, core::convert::Infallible>>
Line
Count
Source
977
1
                $pvis unsafe fn $p_field<E>(
978
1
                    self,
979
1
                    slot: *mut $p_type,
980
1
                    init: impl $crate::PinInit<$p_type, E>,
981
1
                ) -> ::core::result::Result<(), E> {
982
1
                    unsafe { $crate::PinInit::__pinned_init(init, slot) }
983
1
                }
<alloc_fail::ring_buf::mutex::_::__ThePinData>::wait_list::<core::convert::Infallible, pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::mutex::linked_list::ListHead>::insert_prev::{closure#1}, alloc_fail::ring_buf::mutex::linked_list::ListHead, core::convert::Infallible>>
Line
Count
Source
977
9.60k
                $pvis unsafe fn $p_field<E>(
978
9.60k
                    self,
979
9.60k
                    slot: *mut $p_type,
980
9.60k
                    init: impl $crate::PinInit<$p_type, E>,
981
9.60k
                ) -> ::core::result::Result<(), E> {
982
9.60k
                    unsafe { $crate::PinInit::__pinned_init(init, slot) }
983
9.60k
                }
<alloc_fail::ring_buf::mutex::_::__ThePinData<usize>>::wait_list::<core::convert::Infallible, pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::mutex::linked_list::ListHead>::new::{closure#1}, alloc_fail::ring_buf::mutex::linked_list::ListHead, core::convert::Infallible>>
Line
Count
Source
977
1
                $pvis unsafe fn $p_field<E>(
978
1
                    self,
979
1
                    slot: *mut $p_type,
980
1
                    init: impl $crate::PinInit<$p_type, E>,
981
1
                ) -> ::core::result::Result<(), E> {
982
1
                    unsafe { $crate::PinInit::__pinned_init(init, slot) }
983
1
                }
Unexecuted instantiation: <alloc_fail::ring_buf::mutex::linked_list::_::__ThePinData>::pin::<_, _>
Unexecuted instantiation: <alloc_fail::ring_buf::_::__ThePinData<_, _>>::_pin::<_, _>
<ring_buf::mutex::_::__ThePinData<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>>::wait_list::<core::convert::Infallible, pinned_init::__internal::InitClosure<<ring_buf::mutex::linked_list::ListHead>::new::{closure#1}, ring_buf::mutex::linked_list::ListHead, core::convert::Infallible>>
Line
Count
Source
977
1
                $pvis unsafe fn $p_field<E>(
978
1
                    self,
979
1
                    slot: *mut $p_type,
980
1
                    init: impl $crate::PinInit<$p_type, E>,
981
1
                ) -> ::core::result::Result<(), E> {
982
1
                    unsafe { $crate::PinInit::__pinned_init(init, slot) }
983
1
                }
<ring_buf::mutex::_::__ThePinData<usize>>::data::<core::convert::Infallible, pinned_init::__internal::InitClosure<<ring_buf::mutex::CMutex<usize>>::new<usize>::{closure#0}::{closure#1}, core::cell::UnsafeCell<usize>, core::convert::Infallible>>
Line
Count
Source
977
1
                $pvis unsafe fn $p_field<E>(
978
1
                    self,
979
1
                    slot: *mut $p_type,
980
1
                    init: impl $crate::PinInit<$p_type, E>,
981
1
                ) -> ::core::result::Result<(), E> {
982
1
                    unsafe { $crate::PinInit::__pinned_init(init, slot) }
983
1
                }
<ring_buf::mutex::_::__ThePinData>::wait_list::<core::convert::Infallible, pinned_init::__internal::InitClosure<<ring_buf::mutex::linked_list::ListHead>::insert_prev::{closure#1}, ring_buf::mutex::linked_list::ListHead, core::convert::Infallible>>
Line
Count
Source
977
14.4k
                $pvis unsafe fn $p_field<E>(
978
14.4k
                    self,
979
14.4k
                    slot: *mut $p_type,
980
14.4k
                    init: impl $crate::PinInit<$p_type, E>,
981
14.4k
                ) -> ::core::result::Result<(), E> {
982
14.4k
                    unsafe { $crate::PinInit::__pinned_init(init, slot) }
983
14.4k
                }
<ring_buf::mutex::_::__ThePinData<usize>>::wait_list::<core::convert::Infallible, pinned_init::__internal::InitClosure<<ring_buf::mutex::linked_list::ListHead>::new::{closure#1}, ring_buf::mutex::linked_list::ListHead, core::convert::Infallible>>
Line
Count
Source
977
1
                $pvis unsafe fn $p_field<E>(
978
1
                    self,
979
1
                    slot: *mut $p_type,
980
1
                    init: impl $crate::PinInit<$p_type, E>,
981
1
                ) -> ::core::result::Result<(), E> {
982
1
                    unsafe { $crate::PinInit::__pinned_init(init, slot) }
983
1
                }
<ring_buf::mutex::_::__ThePinData<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>>::data::<core::convert::Infallible, pinned_init::__internal::InitClosure<<ring_buf::mutex::CMutex<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>>::new<pinned_init::__internal::InitClosure<<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>::new::{closure#1}, ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>, core::convert::Infallible>>::{closure#0}::{closure#1}, core::cell::UnsafeCell<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>, core::convert::Infallible>>
Line
Count
Source
977
1
                $pvis unsafe fn $p_field<E>(
978
1
                    self,
979
1
                    slot: *mut $p_type,
980
1
                    init: impl $crate::PinInit<$p_type, E>,
981
1
                ) -> ::core::result::Result<(), E> {
982
1
                    unsafe { $crate::PinInit::__pinned_init(init, slot) }
983
1
                }
Unexecuted instantiation: <ring_buf::_::__ThePinData<_, _>>::_pin::<_, _>
Unexecuted instantiation: <ring_buf::mutex::linked_list::_::__ThePinData>::pin::<_, _>
Unexecuted instantiation: <linked_list::_::__ThePinData>::pin::<_, _>
<mutex::_::__ThePinData>::wait_list::<core::convert::Infallible, pinned_init::__internal::InitClosure<<mutex::linked_list::ListHead>::insert_prev::{closure#1}, mutex::linked_list::ListHead, core::convert::Infallible>>
Line
Count
Source
977
10.1k
                $pvis unsafe fn $p_field<E>(
978
10.1k
                    self,
979
10.1k
                    slot: *mut $p_type,
980
10.1k
                    init: impl $crate::PinInit<$p_type, E>,
981
10.1k
                ) -> ::core::result::Result<(), E> {
982
10.1k
                    unsafe { $crate::PinInit::__pinned_init(init, slot) }
983
10.1k
                }
<mutex::_::__ThePinData<usize>>::data::<core::convert::Infallible, pinned_init::__internal::InitClosure<<mutex::CMutex<usize>>::new<usize>::{closure#0}::{closure#1}, core::cell::UnsafeCell<usize>, core::convert::Infallible>>
Line
Count
Source
977
1
                $pvis unsafe fn $p_field<E>(
978
1
                    self,
979
1
                    slot: *mut $p_type,
980
1
                    init: impl $crate::PinInit<$p_type, E>,
981
1
                ) -> ::core::result::Result<(), E> {
982
1
                    unsafe { $crate::PinInit::__pinned_init(init, slot) }
983
1
                }
<mutex::_::__ThePinData<usize>>::wait_list::<core::convert::Infallible, pinned_init::__internal::InitClosure<<mutex::linked_list::ListHead>::new::{closure#1}, mutex::linked_list::ListHead, core::convert::Infallible>>
Line
Count
Source
977
1
                $pvis unsafe fn $p_field<E>(
978
1
                    self,
979
1
                    slot: *mut $p_type,
980
1
                    init: impl $crate::PinInit<$p_type, E>,
981
1
                ) -> ::core::result::Result<(), E> {
982
1
                    unsafe { $crate::PinInit::__pinned_init(init, slot) }
983
1
                }
Unexecuted instantiation: <mutex::linked_list::_::__ThePinData>::pin::<_, _>
<pthread_mutex::pthread_mtx::_::__ThePinData<usize>>::raw::<pthread_mutex::pthread_mtx::Error, pinned_init::__internal::InitClosure<<pthread_mutex::pthread_mtx::PThreadMutex<_>>::new::init_raw::{closure#0}, core::cell::UnsafeCell<libc::unix::linux_like::linux::pthread_mutex_t>, pthread_mutex::pthread_mtx::Error>>
Line
Count
Source
977
1
                $pvis unsafe fn $p_field<E>(
978
1
                    self,
979
1
                    slot: *mut $p_type,
980
1
                    init: impl $crate::PinInit<$p_type, E>,
981
1
                ) -> ::core::result::Result<(), E> {
982
1
                    unsafe { $crate::PinInit::__pinned_init(init, slot) }
983
1
                }
Unexecuted instantiation: <pthread_mutex::pthread_mtx::_::__ThePinData<_>>::pin::<_, _>
<static_init::mutex::_::__ThePinData<usize>>::data::<core::convert::Infallible, pinned_init::__internal::InitClosure<<static_init::mutex::CMutex<usize>>::new<usize>::{closure#0}::{closure#1}, core::cell::UnsafeCell<usize>, core::convert::Infallible>>
Line
Count
Source
977
1
                $pvis unsafe fn $p_field<E>(
978
1
                    self,
979
1
                    slot: *mut $p_type,
980
1
                    init: impl $crate::PinInit<$p_type, E>,
981
1
                ) -> ::core::result::Result<(), E> {
982
1
                    unsafe { $crate::PinInit::__pinned_init(init, slot) }
983
1
                }
<static_init::mutex::_::__ThePinData<usize>>::wait_list::<core::convert::Infallible, pinned_init::__internal::InitClosure<<static_init::mutex::linked_list::ListHead>::new::{closure#1}, static_init::mutex::linked_list::ListHead, core::convert::Infallible>>
Line
Count
Source
977
1
                $pvis unsafe fn $p_field<E>(
978
1
                    self,
979
1
                    slot: *mut $p_type,
980
1
                    init: impl $crate::PinInit<$p_type, E>,
981
1
                ) -> ::core::result::Result<(), E> {
982
1
                    unsafe { $crate::PinInit::__pinned_init(init, slot) }
983
1
                }
<static_init::mutex::_::__ThePinData>::wait_list::<core::convert::Infallible, pinned_init::__internal::InitClosure<<static_init::mutex::linked_list::ListHead>::insert_prev::{closure#1}, static_init::mutex::linked_list::ListHead, core::convert::Infallible>>
Line
Count
Source
977
12.6k
                $pvis unsafe fn $p_field<E>(
978
12.6k
                    self,
979
12.6k
                    slot: *mut $p_type,
980
12.6k
                    init: impl $crate::PinInit<$p_type, E>,
981
12.6k
                ) -> ::core::result::Result<(), E> {
982
12.6k
                    unsafe { $crate::PinInit::__pinned_init(init, slot) }
983
12.6k
                }
Unexecuted instantiation: <static_init::mutex::linked_list::_::__ThePinData>::pin::<_, _>
984
            )*
985
            $(
986
                $(#[$($attr)*])*
987
6
                $fvis unsafe fn $field<E>(
988
6
                    self,
989
6
                    slot: *mut $type,
990
6
                    init: impl $crate::Init<$type, E>,
991
6
                ) -> ::core::result::Result<(), E> {
992
6
                    unsafe { $crate::Init::__init(init, slot) }
993
6
                }
<alloc_fail::ring_buf::_::__ThePinData<alloc_fail::ring_buf::BigStruct, 64usize>>::buffer::<core::convert::Infallible, pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::BigStruct, 64usize>>::new::{closure#0}::{closure#1}, [core::mem::maybe_uninit::MaybeUninit<alloc_fail::ring_buf::BigStruct>; 64usize], core::convert::Infallible>>
Line
Count
Source
987
1
                $fvis unsafe fn $field<E>(
988
1
                    self,
989
1
                    slot: *mut $type,
990
1
                    init: impl $crate::Init<$type, E>,
991
1
                ) -> ::core::result::Result<(), E> {
992
1
                    unsafe { $crate::Init::__init(init, slot) }
993
1
                }
Unexecuted instantiation: <alloc_fail::ring_buf::_::__ThePinData<u8, 1099511627776usize>>::buffer::<core::convert::Infallible, pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<u8, 1099511627776usize>>::new::{closure#0}::{closure#1}, [core::mem::maybe_uninit::MaybeUninit<u8>; 1099511627776usize], core::convert::Infallible>>
<alloc_fail::ring_buf::_::__ThePinData<u8, 64usize>>::buffer::<core::convert::Infallible, pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<u8, 64usize>>::new::{closure#0}::{closure#1}, [core::mem::maybe_uninit::MaybeUninit<u8>; 64usize], core::convert::Infallible>>
Line
Count
Source
987
1
                $fvis unsafe fn $field<E>(
988
1
                    self,
989
1
                    slot: *mut $type,
990
1
                    init: impl $crate::Init<$type, E>,
991
1
                ) -> ::core::result::Result<(), E> {
992
1
                    unsafe { $crate::Init::__init(init, slot) }
993
1
                }
<alloc_fail::ring_buf::_::__ThePinData<alloc_fail::ring_buf::EvenU64, 4usize>>::buffer::<core::convert::Infallible, pinned_init::__internal::InitClosure<<alloc_fail::ring_buf::RingBuffer<alloc_fail::ring_buf::EvenU64, 4usize>>::new::{closure#0}::{closure#1}, [core::mem::maybe_uninit::MaybeUninit<alloc_fail::ring_buf::EvenU64>; 4usize], core::convert::Infallible>>
Line
Count
Source
987
1
                $fvis unsafe fn $field<E>(
988
1
                    self,
989
1
                    slot: *mut $type,
990
1
                    init: impl $crate::Init<$type, E>,
991
1
                ) -> ::core::result::Result<(), E> {
992
1
                    unsafe { $crate::Init::__init(init, slot) }
993
1
                }
Unexecuted instantiation: <alloc_fail::ring_buf::mutex::linked_list::_::__ThePinData>::next::<_, _>
Unexecuted instantiation: <alloc_fail::ring_buf::mutex::_::__ThePinData<_>>::locked::<_, _>
Unexecuted instantiation: <alloc_fail::ring_buf::_::__ThePinData<_, _>>::head::<_, _>
Unexecuted instantiation: <alloc_fail::ring_buf::mutex::linked_list::_::__ThePinData>::prev::<_, _>
Unexecuted instantiation: <alloc_fail::ring_buf::_::__ThePinData<_, _>>::tail::<_, _>
Unexecuted instantiation: <alloc_fail::ring_buf::mutex::_::__ThePinData>::thread::<_, _>
Unexecuted instantiation: <alloc_fail::ring_buf::mutex::_::__ThePinData<_>>::spin_lock::<_, _>
Unexecuted instantiation: <ring_buf::mutex::linked_list::_::__ThePinData>::prev::<_, _>
<ring_buf::_::__ThePinData<ring_buf::EvenU64, 4usize>>::buffer::<core::convert::Infallible, pinned_init::__internal::InitClosure<<ring_buf::RingBuffer<ring_buf::EvenU64, 4usize>>::new::{closure#0}::{closure#1}, [core::mem::maybe_uninit::MaybeUninit<ring_buf::EvenU64>; 4usize], core::convert::Infallible>>
Line
Count
Source
987
1
                $fvis unsafe fn $field<E>(
988
1
                    self,
989
1
                    slot: *mut $type,
990
1
                    init: impl $crate::Init<$type, E>,
991
1
                ) -> ::core::result::Result<(), E> {
992
1
                    unsafe { $crate::Init::__init(init, slot) }
993
1
                }
Unexecuted instantiation: <ring_buf::_::__ThePinData<_, _>>::tail::<_, _>
<ring_buf::_::__ThePinData<u8, 64usize>>::buffer::<core::convert::Infallible, pinned_init::__internal::InitClosure<<ring_buf::RingBuffer<u8, 64usize>>::new::{closure#0}::{closure#1}, [core::mem::maybe_uninit::MaybeUninit<u8>; 64usize], core::convert::Infallible>>
Line
Count
Source
987
1
                $fvis unsafe fn $field<E>(
988
1
                    self,
989
1
                    slot: *mut $type,
990
1
                    init: impl $crate::Init<$type, E>,
991
1
                ) -> ::core::result::Result<(), E> {
992
1
                    unsafe { $crate::Init::__init(init, slot) }
993
1
                }
Unexecuted instantiation: <ring_buf::mutex::_::__ThePinData>::thread::<_, _>
Unexecuted instantiation: <ring_buf::mutex::_::__ThePinData<_>>::locked::<_, _>
<ring_buf::_::__ThePinData<ring_buf::BigStruct, 64usize>>::buffer::<core::convert::Infallible, pinned_init::__internal::InitClosure<<ring_buf::RingBuffer<ring_buf::BigStruct, 64usize>>::new::{closure#0}::{closure#1}, [core::mem::maybe_uninit::MaybeUninit<ring_buf::BigStruct>; 64usize], core::convert::Infallible>>
Line
Count
Source
987
1
                $fvis unsafe fn $field<E>(
988
1
                    self,
989
1
                    slot: *mut $type,
990
1
                    init: impl $crate::Init<$type, E>,
991
1
                ) -> ::core::result::Result<(), E> {
992
1
                    unsafe { $crate::Init::__init(init, slot) }
993
1
                }
Unexecuted instantiation: <ring_buf::mutex::linked_list::_::__ThePinData>::next::<_, _>
Unexecuted instantiation: <ring_buf::mutex::_::__ThePinData<_>>::spin_lock::<_, _>
Unexecuted instantiation: <ring_buf::_::__ThePinData<_, _>>::head::<_, _>
Unexecuted instantiation: <linked_list::_::__ThePinData>::prev::<_, _>
Unexecuted instantiation: <linked_list::_::__ThePinData>::next::<_, _>
Unexecuted instantiation: <mutex::_::__ThePinData<_>>::locked::<_, _>
Unexecuted instantiation: <mutex::linked_list::_::__ThePinData>::prev::<_, _>
Unexecuted instantiation: <mutex::_::__ThePinData<_>>::spin_lock::<_, _>
Unexecuted instantiation: <mutex::linked_list::_::__ThePinData>::next::<_, _>
Unexecuted instantiation: <mutex::_::__ThePinData>::thread::<_, _>
Unexecuted instantiation: <pthread_mutex::pthread_mtx::_::__ThePinData<_>>::data::<_, _>
Unexecuted instantiation: <static_init::mutex::_::__ThePinData<_>>::locked::<_, _>
Unexecuted instantiation: <static_init::mutex::linked_list::_::__ThePinData>::next::<_, _>
Unexecuted instantiation: <static_init::mutex::_::__ThePinData<_>>::spin_lock::<_, _>
Unexecuted instantiation: <static_init::mutex::_::__ThePinData>::thread::<_, _>
Unexecuted instantiation: <static_init::mutex::linked_list::_::__ThePinData>::prev::<_, _>
Unexecuted instantiation: <with_zero::_::__ThePinData>::a::<_, _>
Unexecuted instantiation: <with_zero::_::__ThePinData>::b::<_, _>
994
            )*
995
        }
996
    };
997
}
998
999
/// The internal init macro. Do not call manually!
1000
///
1001
/// This is called by the `{try_}{pin_}init!` macros with various inputs.
1002
///
1003
/// This macro has multiple internal call configurations, these are always the very first ident:
1004
/// - nothing: this is the base case and calle by the `{try_}{pin_}init!` macros.
1005
/// - `with_update_parsed`: when the `..Zeroable::zeroed()` syntax has been handled.
1006
/// - `init_slot`: recursively creates the code that initializes all fields in `slot`.
1007
/// - `make_initializer`: recursively create the struct initializer that guarantees that every
1008
///   field has been initialized exactly once.
1009
#[doc(hidden)]
1010
#[macro_export]
1011
macro_rules! __init_internal {
1012
    (
1013
        @this($($this:ident)?),
1014
        @typ($t:path),
1015
        @fields($($fields:tt)*),
1016
        @error($err:ty),
1017
        // Either `PinData` or `InitData`, `$use_data` should only be present in the `PinData`
1018
        // case.
1019
        @data($data:ident, $($use_data:ident)?),
1020
        // `HasPinData` or `HasInitData`.
1021
        @has_data($has_data:ident, $get_data:ident),
1022
        // `pin_init_from_closure` or `init_from_closure`.
1023
        @construct_closure($construct_closure:ident),
1024
        @munch_fields(),
1025
    ) => {
1026
        $crate::__init_internal!(with_update_parsed:
1027
            @this($($this)?),
1028
            @typ($t),
1029
            @fields($($fields)*),
1030
            @error($err),
1031
            @data($data, $($use_data)?),
1032
            @has_data($has_data, $get_data),
1033
            @construct_closure($construct_closure),
1034
            @zeroed(), // nothing means default behavior.
1035
        )
1036
    };
1037
    (
1038
        @this($($this:ident)?),
1039
        @typ($t:path),
1040
        @fields($($fields:tt)*),
1041
        @error($err:ty),
1042
        // Either `PinData` or `InitData`, `$use_data` should only be present in the `PinData`
1043
        // case.
1044
        @data($data:ident, $($use_data:ident)?),
1045
        // `HasPinData` or `HasInitData`.
1046
        @has_data($has_data:ident, $get_data:ident),
1047
        // `pin_init_from_closure` or `init_from_closure`.
1048
        @construct_closure($construct_closure:ident),
1049
        @munch_fields(..Zeroable::zeroed()),
1050
    ) => {
1051
        $crate::__init_internal!(with_update_parsed:
1052
            @this($($this)?),
1053
            @typ($t),
1054
            @fields($($fields)*),
1055
            @error($err),
1056
            @data($data, $($use_data)?),
1057
            @has_data($has_data, $get_data),
1058
            @construct_closure($construct_closure),
1059
            @zeroed(()), // `()` means zero all fields not mentioned.
1060
        )
1061
    };
1062
    (
1063
        @this($($this:ident)?),
1064
        @typ($t:path),
1065
        @fields($($fields:tt)*),
1066
        @error($err:ty),
1067
        // Either `PinData` or `InitData`, `$use_data` should only be present in the `PinData`
1068
        // case.
1069
        @data($data:ident, $($use_data:ident)?),
1070
        // `HasPinData` or `HasInitData`.
1071
        @has_data($has_data:ident, $get_data:ident),
1072
        // `pin_init_from_closure` or `init_from_closure`.
1073
        @construct_closure($construct_closure:ident),
1074
        @munch_fields($ignore:tt $($rest:tt)*),
1075
    ) => {
1076
        $crate::__init_internal!(
1077
            @this($($this)?),
1078
            @typ($t),
1079
            @fields($($fields)*),
1080
            @error($err),
1081
            @data($data, $($use_data)?),
1082
            @has_data($has_data, $get_data),
1083
            @construct_closure($construct_closure),
1084
            @munch_fields($($rest)*),
1085
        )
1086
    };
1087
    (with_update_parsed:
1088
        @this($($this:ident)?),
1089
        @typ($t:path),
1090
        @fields($($fields:tt)*),
1091
        @error($err:ty),
1092
        // Either `PinData` or `InitData`, `$use_data` should only be present in the `PinData`
1093
        // case.
1094
        @data($data:ident, $($use_data:ident)?),
1095
        // `HasPinData` or `HasInitData`.
1096
        @has_data($has_data:ident, $get_data:ident),
1097
        // `pin_init_from_closure` or `init_from_closure`.
1098
        @construct_closure($construct_closure:ident),
1099
        @zeroed($($init_zeroed:expr)?),
1100
    ) => {{
1101
        // We do not want to allow arbitrary returns, so we declare this type as the `Ok` return
1102
        // type and shadow it later when we insert the arbitrary user code. That way there will be
1103
        // no possibility of returning without `unsafe`.
1104
        struct __InitOk;
1105
        // Get the data about fields from the supplied type.
1106
        let data = unsafe {
1107
            use $crate::__internal::$has_data;
1108
            $crate::__internal::paste!($t::$get_data())
1109
        };
1110
        // Ensure that `data` really is of type `$data` and help with type inference:
1111
        let init = $crate::__internal::$data::make_closure::<_, __InitOk, $err>(
1112
            data,
1113
            move |slot| {
1114
                {
1115
                    // Shadow the structure so it cannot be used to return early.
1116
                    struct __InitOk;
1117
                    // If `$init_zeroed` is present we should zero the slot now and not emit an
1118
                    // error when fields are missing (since they will be zeroed). We also have to
1119
                    // check that the type actually implements `Zeroable`.
1120
                    $({
1121
0
                        fn assert_zeroable<T: $crate::Zeroable>(_: *mut T) {}
1122
                        // Ensure that the struct is indeed `Zeroable`.
1123
                        assert_zeroable(slot);
1124
                        // SAFETY:  The type implements `Zeroable` by the check above.
1125
                        unsafe { ::core::ptr::write_bytes(slot, 0, 1) };
1126
                        $init_zeroed // this will be `()` if set.
1127
                    })?
1128
                    // Create the `this` so it can be referenced by the user inside of the
1129
                    // expressions creating the individual fields.
1130
                    $(let $this = unsafe { ::core::ptr::NonNull::new_unchecked(slot) };)?
1131
                    // Initialize every field.
1132
                    $crate::__init_internal!(init_slot($($use_data)?):
1133
                        @data(data),
1134
                        @slot(slot),
1135
                        @guards(),
1136
                        @munch_fields($($fields)*,),
1137
                    );
1138
                    // We use unreachable code to ensure that all fields have been mentioned exactly
1139
                    // once, this struct initializer will still be type-checked and complain with a
1140
                    // very natural error message if a field is forgotten/mentioned more than once.
1141
                    #[allow(unreachable_code, clippy::diverging_sub_expression)]
1142
                    let _ = || {
1143
                        $crate::__init_internal!(make_initializer:
1144
                            @slot(slot),
1145
                            @type_name($t),
1146
                            @munch_fields($($fields)*,),
1147
                            @acc(),
1148
                        );
1149
                    };
1150
                }
1151
                Ok(__InitOk)
1152
            }
1153
        );
1154
        let init = move |slot| -> ::core::result::Result<(), $err> {
1155
            init(slot).map(|__InitOk| ())
1156
        };
1157
        let init = unsafe { $crate::$construct_closure::<_, $err>(init) };
1158
        init
1159
    }};
1160
    (init_slot($($use_data:ident)?):
1161
        @data($data:ident),
1162
        @slot($slot:ident),
1163
        @guards($($guards:ident,)*),
1164
        @munch_fields($(..Zeroable::zeroed())? $(,)?),
1165
    ) => {
1166
        // Endpoint of munching, no fields are left. If execution reaches this point, all fields
1167
        // have been initialized. Therefore we can now dismiss the guards by forgetting them.
1168
        $(::core::mem::forget($guards);)*
1169
    };
1170
    (init_slot($use_data:ident): // use_data is present, so we use the `data` to init fields.
1171
        @data($data:ident),
1172
        @slot($slot:ident),
1173
        @guards($($guards:ident,)*),
1174
        // In-place initialization syntax.
1175
        @munch_fields($field:ident <- $val:expr, $($rest:tt)*),
1176
    ) => {
1177
        let init = $val;
1178
        // Call the initializer.
1179
        //
1180
        // SAFETY: `slot` is valid, because we are inside of an initializer closure, we
1181
        // return when an error/panic occurs.
1182
        // We also use the `data` to require the correct trait (`Init` or `PinInit`) for `$field`.
1183
        unsafe { $data.$field(::core::ptr::addr_of_mut!((*$slot).$field), init)? };
1184
        // Create the drop guard:
1185
        //
1186
        // We rely on macro hygiene to make it impossible for users to access this local variable.
1187
        // We use `paste!` to create new hygiene for $field.
1188
        $crate::__internal::paste! {
1189
            // SAFETY: We forget the guard later when initialization has succeeded.
1190
            let [<$field>] = unsafe {
1191
                $crate::__internal::DropGuard::new(::core::ptr::addr_of_mut!((*$slot).$field))
1192
            };
1193
1194
            $crate::__init_internal!(init_slot($use_data):
1195
                @data($data),
1196
                @slot($slot),
1197
                @guards([<$field>], $($guards,)*),
1198
                @munch_fields($($rest)*),
1199
            );
1200
        }
1201
    };
1202
    (init_slot(): // no use_data, so we use `Init::__init` directly.
1203
        @data($data:ident),
1204
        @slot($slot:ident),
1205
        @guards($($guards:ident,)*),
1206
        // In-place initialization syntax.
1207
        @munch_fields($field:ident <- $val:expr, $($rest:tt)*),
1208
    ) => {
1209
        let init = $val;
1210
        // Call the initializer.
1211
        //
1212
        // SAFETY: `slot` is valid, because we are inside of an initializer closure, we
1213
        // return when an error/panic occurs.
1214
        unsafe { $crate::Init::__init(init, ::core::ptr::addr_of_mut!((*$slot).$field))? };
1215
        // Create the drop guard:
1216
        //
1217
        // We rely on macro hygiene to make it impossible for users to access this local variable.
1218
        // We use `paste!` to create new hygiene for $field.
1219
        $crate::__internal::paste! {
1220
            // SAFETY: We forget the guard later when initialization has succeeded.
1221
            let [<$field>] = unsafe {
1222
                $crate::__internal::DropGuard::new(::core::ptr::addr_of_mut!((*$slot).$field))
1223
            };
1224
1225
            $crate::__init_internal!(init_slot():
1226
                @data($data),
1227
                @slot($slot),
1228
                @guards([<$field>], $($guards,)*),
1229
                @munch_fields($($rest)*),
1230
            );
1231
        }
1232
    };
1233
    (init_slot($($use_data:ident)?):
1234
        @data($data:ident),
1235
        @slot($slot:ident),
1236
        @guards($($guards:ident,)*),
1237
        // Init by-value.
1238
        @munch_fields($field:ident $(: $val:expr)?, $($rest:tt)*),
1239
    ) => {
1240
        {
1241
            $(let $field = $val;)?
1242
            // Initialize the field.
1243
            //
1244
            // SAFETY: The memory at `slot` is uninitialized.
1245
            unsafe { ::core::ptr::write(::core::ptr::addr_of_mut!((*$slot).$field), $field) };
1246
        }
1247
        // Create the drop guard:
1248
        //
1249
        // We rely on macro hygiene to make it impossible for users to access this local variable.
1250
        // We use `paste!` to create new hygiene for $field.
1251
        $crate::__internal::paste! {
1252
            // SAFETY: We forget the guard later when initialization has succeeded.
1253
            let [<$field>] = unsafe {
1254
                $crate::__internal::DropGuard::new(::core::ptr::addr_of_mut!((*$slot).$field))
1255
            };
1256
1257
            $crate::__init_internal!(init_slot($($use_data)?):
1258
                @data($data),
1259
                @slot($slot),
1260
                @guards([<$field>], $($guards,)*),
1261
                @munch_fields($($rest)*),
1262
            );
1263
        }
1264
    };
1265
    (make_initializer:
1266
        @slot($slot:ident),
1267
        @type_name($t:path),
1268
        @munch_fields(..Zeroable::zeroed() $(,)?),
1269
        @acc($($acc:tt)*),
1270
    ) => {
1271
        // Endpoint, nothing more to munch, create the initializer. Since the users specified
1272
        // `..Zeroable::zeroed()`, the slot will already have been zeroed and all field that have
1273
        // not been overwritten are thus zero and initialized. We still check that all fields are
1274
        // actually accessible by using the struct update syntax ourselves.
1275
        // Since we are in the `if false` branch, this will never get executed. We abuse `slot` to
1276
        // get the correct type inference here:
1277
        #[allow(unused_assignments)]
1278
        unsafe {
1279
            let mut zeroed = ::core::mem::zeroed();
1280
            // We have to use type inference here to make zeroed have the correct type. This does
1281
            // not get executed, so it has no effect.
1282
            ::core::ptr::write($slot, zeroed);
1283
            zeroed = ::core::mem::zeroed();
1284
            // Here we abuse `paste!` to retokenize `$t`. Declarative macros have some internal
1285
            // information that is associated to already parsed fragments, so a path fragment
1286
            // cannot be used in this position. Doing the retokenization results in valid rust
1287
            // code.
1288
            $crate::__internal::paste!(
1289
                ::core::ptr::write($slot, $t {
1290
                    $($acc)*
1291
                    ..zeroed
1292
                });
1293
            );
1294
        }
1295
    };
1296
    (make_initializer:
1297
        @slot($slot:ident),
1298
        @type_name($t:path),
1299
        @munch_fields($(,)?),
1300
        @acc($($acc:tt)*),
1301
    ) => {
1302
        // Endpoint, nothing more to munch, create the initializer.
1303
        // Since we are in the closure that is never called, this will never get executed.
1304
        // We abuse `slot` to get the correct type inference here:
1305
        unsafe {
1306
            // Here we abuse `paste!` to retokenize `$t`. Declarative macros have some internal
1307
            // information that is associated to already parsed fragments, so a path fragment
1308
            // cannot be used in this position. Doing the retokenization results in valid rust
1309
            // code.
1310
            $crate::__internal::paste!(
1311
                ::core::ptr::write($slot, $t {
1312
                    $($acc)*
1313
                });
1314
            );
1315
        }
1316
    };
1317
    (make_initializer:
1318
        @slot($slot:ident),
1319
        @type_name($t:path),
1320
        @munch_fields($field:ident <- $val:expr, $($rest:tt)*),
1321
        @acc($($acc:tt)*),
1322
    ) => {
1323
        $crate::__init_internal!(make_initializer:
1324
            @slot($slot),
1325
            @type_name($t),
1326
            @munch_fields($($rest)*),
1327
            @acc($($acc)* $field: ::core::panic!(),),
1328
        );
1329
    };
1330
    (make_initializer:
1331
        @slot($slot:ident),
1332
        @type_name($t:path),
1333
        @munch_fields($field:ident $(: $val:expr)?, $($rest:tt)*),
1334
        @acc($($acc:tt)*),
1335
    ) => {
1336
        $crate::__init_internal!(make_initializer:
1337
            @slot($slot),
1338
            @type_name($t),
1339
            @munch_fields($($rest)*),
1340
            @acc($($acc)* $field: ::core::panic!(),),
1341
        );
1342
    };
1343
}
1344
1345
#[doc(hidden)]
1346
#[macro_export]
1347
macro_rules! __derive_zeroable {
1348
    (parse_input:
1349
        @sig(
1350
            $(#[$($struct_attr:tt)*])*
1351
            $vis:vis struct $name:ident
1352
            $(where $($whr:tt)*)?
1353
        ),
1354
        @impl_generics($($impl_generics:tt)*),
1355
        @ty_generics($($ty_generics:tt)*),
1356
        @body({
1357
            $(
1358
                $(#[$($field_attr:tt)*])*
1359
                $field:ident : $field_ty:ty
1360
            ),* $(,)?
1361
        }),
1362
    ) => {
1363
        // SAFETY: every field type implements `Zeroable` and padding bytes may be zero.
1364
        #[automatically_derived]
1365
        unsafe impl<$($impl_generics)*> $crate::Zeroable for $name<$($ty_generics)*>
1366
        where
1367
            $($($whr)*)?
1368
        {}
1369
        const _: () = {
1370
0
            fn assert_zeroable<T: $crate::Zeroable + ?::core::marker::Sized>() {}
1371
0
            fn ensure_zeroable<$($impl_generics)*>()
1372
0
                where $($($whr)*)?
1373
0
            {
1374
0
                $(assert_zeroable::<$field_ty>();)*
1375
0
            }
1376
        };
1377
    };
1378
}
\ No newline at end of file diff --git a/coverage/9762db8666aae4a71263fb3c4affdaf962cf87f6/index.html b/coverage/9762db8666aae4a71263fb3c4affdaf962cf87f6/index.html new file mode 100644 index 0000000..13487b9 --- /dev/null +++ b/coverage/9762db8666aae4a71263fb3c4affdaf962cf87f6/index.html @@ -0,0 +1 @@ +

Coverage Report

Created: 2023-07-24 21:40

Click here for information about interpreting this report.

FilenameFunction CoverageLine CoverageRegion CoverageBranch Coverage
__internal.rs
 100.00% (16/16)
 100.00% (89/89)
  96.30% (26/27)
- (0/0)
lib.rs
  59.26% (16/27)
  51.04% (98/192)
  48.19% (40/83)
- (0/0)
macros.rs
  66.67% (6/9)
  82.05% (32/39)
  72.73% (8/11)
- (0/0)
Totals
  73.08% (38/52)
  68.44% (219/320)
  61.16% (74/121)
- (0/0)
Generated by llvm-cov -- llvm version 16.0.5-rust-1.73.0-nightly
\ No newline at end of file diff --git a/coverage/9762db8666aae4a71263fb3c4affdaf962cf87f6/style.css b/coverage/9762db8666aae4a71263fb3c4affdaf962cf87f6/style.css new file mode 100644 index 0000000..d95ffe2 --- /dev/null +++ b/coverage/9762db8666aae4a71263fb3c4affdaf962cf87f6/style.css @@ -0,0 +1,143 @@ +.red { + background-color: #ffd0d0; +} +.cyan { + background-color: cyan; +} +body { + font-family: -apple-system, sans-serif; +} +pre { + margin-top: 0px !important; + margin-bottom: 0px !important; +} +.source-name-title { + padding: 5px 10px; + border-bottom: 1px solid #dbdbdb; + background-color: #eee; + line-height: 35px; +} +.centered { + display: table; + margin-left: left; + margin-right: auto; + border: 1px solid #dbdbdb; + border-radius: 3px; +} +.expansion-view { + background-color: rgba(0, 0, 0, 0); + margin-left: 0px; + margin-top: 5px; + margin-right: 5px; + margin-bottom: 5px; + border: 1px solid #dbdbdb; + border-radius: 3px; +} +table { + border-collapse: collapse; +} +.light-row { + background: #ffffff; + border: 1px solid #dbdbdb; +} +.light-row-bold { + background: #ffffff; + border: 1px solid #dbdbdb; + font-weight: bold; +} +.column-entry { + text-align: left; +} +.column-entry-bold { + font-weight: bold; + text-align: left; +} +.column-entry-yellow { + text-align: left; + background-color: #ffffd0; +} +.column-entry-yellow:hover { + background-color: #fffff0; +} +.column-entry-red { + text-align: left; + background-color: #ffd0d0; +} +.column-entry-red:hover { + background-color: #fff0f0; +} +.column-entry-green { + text-align: left; + background-color: #d0ffd0; +} +.column-entry-green:hover { + background-color: #f0fff0; +} +.line-number { + text-align: right; + color: #aaa; +} +.covered-line { + text-align: right; + color: #0080ff; +} +.uncovered-line { + text-align: right; + color: #ff3300; +} +.tooltip { + position: relative; + display: inline; + background-color: #b3e6ff; + text-decoration: none; +} +.tooltip span.tooltip-content { + position: absolute; + width: 100px; + margin-left: -50px; + color: #FFFFFF; + background: #000000; + height: 30px; + line-height: 30px; + text-align: center; + visibility: hidden; + border-radius: 6px; +} +.tooltip span.tooltip-content:after { + content: ''; + position: absolute; + top: 100%; + left: 50%; + margin-left: -8px; + width: 0; height: 0; + border-top: 8px solid #000000; + border-right: 8px solid transparent; + border-left: 8px solid transparent; +} +:hover.tooltip span.tooltip-content { + visibility: visible; + opacity: 0.8; + bottom: 30px; + left: 50%; + z-index: 999; +} +th, td { + vertical-align: top; + padding: 2px 8px; + border-collapse: collapse; + border-right: solid 1px #eee; + border-left: solid 1px #eee; + text-align: left; +} +td pre { + display: inline-block; +} +td:first-child { + border-left: none; +} +td:last-child { + border-right: none; +} +tr:hover { + background-color: #f0f0f0; +}