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

Coverage Report

Created: 2023-07-19 13:34

/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
    }
<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<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
    }
<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
    }
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
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
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
<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::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_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_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::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<<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
    }
<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<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#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<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<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::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
    }
Unexecuted instantiation: <pinned_init::__internal::InitClosure<_, _, _> as pinned_init::Init<_, _>>::__init
Unexecuted instantiation: <pinned_init::__internal::InitClosure<_, _, _> as pinned_init::Init<_, _>>::__init
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::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<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<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<<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<<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<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::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::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::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
    }
<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::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
    }
<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
    }
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
81.6k
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
81.6k
        (self.0)(slot)
47
81.6k
    }
<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
    }
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_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::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
    }
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
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::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::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::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
    }
<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::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
    }
<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.81k
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
9.81k
        (self.0)(slot)
47
9.81k
    }
<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::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::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
    }
<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::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.81k
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
9.81k
        (self.0)(slot)
47
9.81k
    }
<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_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::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
    }
Unexecuted instantiation: <pinned_init::__internal::InitClosure<_, _, _> as pinned_init::PinInit<_, _>>::__pinned_init
<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<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<<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::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<<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::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::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<<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<<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<<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
9.77k
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
9.77k
        (self.0)(slot)
47
9.77k
    }
<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::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::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::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
9.77k
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
9.77k
        (self.0)(slot)
47
9.77k
    }
<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<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<<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<<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<<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<<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<<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>::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<<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::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::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::WaitEntry>::insert_new::{closure#1}, mutex::WaitEntry, core::convert::Infallible> as pinned_init::PinInit<mutex::WaitEntry>>::__pinned_init
Line
Count
Source
45
10.5k
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
10.5k
        (self.0)(slot)
47
10.5k
    }
<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<<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.5k
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
10.5k
        (self.0)(slot)
47
10.5k
    }
<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::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::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<_>>::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<<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<<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
    }
<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
10.5k
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
10.5k
        (self.0)(slot)
47
10.5k
    }
<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>::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::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::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<<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::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
10.5k
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
46
10.5k
        (self.0)(slot)
47
10.5k
    }
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
81.4k
    fn make_closure<F, O, E>(self, f: F) -> F
72
81.4k
    where
73
81.4k
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
81.4k
    {
75
81.4k
        f
76
81.4k
    }
<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.81k
    fn make_closure<F, O, E>(self, f: F) -> F
72
9.81k
    where
73
9.81k
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
9.81k
    {
75
9.81k
        f
76
9.81k
    }
<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::_::__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::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.81k
    fn make_closure<F, O, E>(self, f: F) -> F
72
9.81k
    where
73
9.81k
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
9.81k
    {
75
9.81k
        f
76
9.81k
    }
<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::_::__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::_::__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<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
    }
Unexecuted instantiation: <_ as pinned_init::__internal::PinData>::make_closure::<_, _, _>
Unexecuted instantiation: <_ as pinned_init::__internal::PinData>::make_closure::<_, _, _>
<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
9.77k
    fn make_closure<F, O, E>(self, f: F) -> F
72
9.77k
    where
73
9.77k
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
9.77k
    {
75
9.77k
        f
76
9.77k
    }
<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::_::__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>::insert_prev::{closure#0}, <ring_buf::mutex::linked_list::ListHead>::insert_prev::__InitOk, core::convert::Infallible>
Line
Count
Source
71
9.77k
    fn make_closure<F, O, E>(self, f: F) -> F
72
9.77k
    where
73
9.77k
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
9.77k
    {
75
9.77k
        f
76
9.77k
    }
<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::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::_::__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>::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
    }
<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
    }
<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.5k
    fn make_closure<F, O, E>(self, f: F) -> F
72
10.5k
    where
73
10.5k
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
10.5k
    {
75
10.5k
        f
76
10.5k
    }
<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::_::__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.5k
    fn make_closure<F, O, E>(self, f: F) -> F
72
10.5k
    where
73
10.5k
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
10.5k
    {
75
10.5k
        f
76
10.5k
    }
<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::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
    }
<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
10.5k
    fn make_closure<F, O, E>(self, f: F) -> F
72
10.5k
    where
73
10.5k
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
10.5k
    {
75
10.5k
        f
76
10.5k
    }
<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
10.5k
    fn make_closure<F, O, E>(self, f: F) -> F
72
10.5k
    where
73
10.5k
        F: FnOnce(*mut Self::Datee) -> Result<O, E>,
74
10.5k
    {
75
10.5k
        f
76
10.5k
    }
<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
    }
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::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::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::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::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#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
    }
<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
    }
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::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#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
    }
<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#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::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#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
    }
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::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
    }
<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
    }
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
40.8k
    fn drop(&mut self) {
146
40.8k
        if self.is_init {
147
40.8k
            // SAFETY: As we are being dropped, we only call this once. And since `self.is_init` is
148
40.8k
            // true, `self.value` is initialized.
149
40.8k
            unsafe { self.value.assume_init_drop() };
150
40.8k
        }
2
151
40.8k
    }
<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
    }
<pinned_init::__internal::StackInit<alloc_fail::ring_buf::mutex::WaitEntry> as core::ops::drop::Drop>::drop
Line
Count
Source
145
9.81k
    fn drop(&mut self) {
146
9.81k
        if self.is_init {
147
9.81k
            // SAFETY: As we are being dropped, we only call this once. And since `self.is_init` is
148
9.81k
            // true, `self.value` is initialized.
149
9.81k
            unsafe { self.value.assume_init_drop() };
150
9.81k
        }
0
151
9.81k
    }
<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
    }
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::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<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::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<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::WaitEntry> as core::ops::drop::Drop>::drop
Line
Count
Source
145
9.77k
    fn drop(&mut self) {
146
9.77k
        if self.is_init {
147
9.77k
            // SAFETY: As we are being dropped, we only call this once. And since `self.is_init` is
148
9.77k
            // true, `self.value` is initialized.
149
9.77k
            unsafe { self.value.assume_init_drop() };
150
9.77k
        }
0
151
9.77k
    }
<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::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.5k
    fn drop(&mut self) {
146
10.5k
        if self.is_init {
147
10.5k
            // SAFETY: As we are being dropped, we only call this once. And since `self.is_init` is
148
10.5k
            // true, `self.value` is initialized.
149
10.5k
            unsafe { self.value.assume_init_drop() };
150
10.5k
        }
0
151
10.5k
    }
<pinned_init::__internal::StackInit<static_init::mutex::WaitEntry> as core::ops::drop::Drop>::drop
Line
Count
Source
145
10.5k
    fn drop(&mut self) {
146
10.5k
        if self.is_init {
147
10.5k
            // SAFETY: As we are being dropped, we only call this once. And since `self.is_init` is
148
10.5k
            // true, `self.value` is initialized.
149
10.5k
            unsafe { self.value.assume_init_drop() };
150
10.5k
        }
0
151
10.5k
    }
<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
40.8k
    pub fn uninit() -> Self {
161
40.8k
        Self {
162
40.8k
            value: MaybeUninit::uninit(),
163
40.8k
            is_init: false,
164
40.8k
        }
165
40.8k
    }
<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.81k
    pub fn uninit() -> Self {
161
9.81k
        Self {
162
9.81k
            value: MaybeUninit::uninit(),
163
9.81k
            is_init: false,
164
9.81k
        }
165
9.81k
    }
<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<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<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
    }
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::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<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::mutex::WaitEntry>>::uninit
Line
Count
Source
160
9.77k
    pub fn uninit() -> Self {
161
9.77k
        Self {
162
9.77k
            value: MaybeUninit::uninit(),
163
9.77k
            is_init: false,
164
9.77k
        }
165
9.77k
    }
<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::WaitEntry>>::uninit
Line
Count
Source
160
10.5k
    pub fn uninit() -> Self {
161
10.5k
        Self {
162
10.5k
            value: MaybeUninit::uninit(),
163
10.5k
            is_init: false,
164
10.5k
        }
165
10.5k
    }
<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<static_init::mutex::WaitEntry>>::uninit
Line
Count
Source
160
10.5k
    pub fn uninit() -> Self {
161
10.5k
        Self {
162
10.5k
            value: MaybeUninit::uninit(),
163
10.5k
            is_init: false,
164
10.5k
        }
165
10.5k
    }
<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
    }
166
167
    /// Initializes the contents and returns the result.
168
    #[inline]
169
40.8k
    pub fn init<E>(self: Pin<&mut Self>, init: impl PinInit<T, E>) -> Result<Pin<&mut T>, E> {
170
40.8k
        // SAFETY: We never move out of `this`.
171
40.8k
        let this = unsafe { Pin::into_inner_unchecked(self) };
172
40.8k
        // The value is currently initialized, so it needs to be dropped before we can reuse
173
40.8k
        // the memory (this is a safety guarantee of `Pin`).
174
40.8k
        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
40.8k
        }
179
        // SAFETY: The memory slot is valid and this type ensures that it will stay pinned.
180
40.8k
        unsafe { init.__pinned_init(this.value.as_mut_ptr())
?2
};
181
        // INVARIANT: `this.value` is initialized above.
182
40.8k
        this.is_init = true;
183
40.8k
        // SAFETY: The slot is now pinned, since we will never give access to `&mut T`.
184
40.8k
        Ok(unsafe { Pin::new_unchecked(this.value.assume_init_mut()) })
185
40.8k
    }
<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::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.81k
    pub fn init<E>(self: Pin<&mut Self>, init: impl PinInit<T, E>) -> Result<Pin<&mut T>, E> {
170
9.81k
        // SAFETY: We never move out of `this`.
171
9.81k
        let this = unsafe { Pin::into_inner_unchecked(self) };
172
9.81k
        // The value is currently initialized, so it needs to be dropped before we can reuse
173
9.81k
        // the memory (this is a safety guarantee of `Pin`).
174
9.81k
        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.81k
        }
179
        // SAFETY: The memory slot is valid and this type ensures that it will stay pinned.
180
9.81k
        unsafe { init.__pinned_init(this.value.as_mut_ptr())
?0
};
181
        // INVARIANT: `this.value` is initialized above.
182
9.81k
        this.is_init = true;
183
9.81k
        // SAFETY: The slot is now pinned, since we will never give access to `&mut T`.
184
9.81k
        Ok(unsafe { Pin::new_unchecked(this.value.assume_init_mut()) })
185
9.81k
    }
<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::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<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<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::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<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
9.77k
    pub fn init<E>(self: Pin<&mut Self>, init: impl PinInit<T, E>) -> Result<Pin<&mut T>, E> {
170
9.77k
        // SAFETY: We never move out of `this`.
171
9.77k
        let this = unsafe { Pin::into_inner_unchecked(self) };
172
9.77k
        // The value is currently initialized, so it needs to be dropped before we can reuse
173
9.77k
        // the memory (this is a safety guarantee of `Pin`).
174
9.77k
        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.77k
        }
179
        // SAFETY: The memory slot is valid and this type ensures that it will stay pinned.
180
9.77k
        unsafe { init.__pinned_init(this.value.as_mut_ptr())
?0
};
181
        // INVARIANT: `this.value` is initialized above.
182
9.77k
        this.is_init = true;
183
9.77k
        // SAFETY: The slot is now pinned, since we will never give access to `&mut T`.
184
9.77k
        Ok(unsafe { Pin::new_unchecked(this.value.assume_init_mut()) })
185
9.77k
    }
<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<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::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.5k
    pub fn init<E>(self: Pin<&mut Self>, init: impl PinInit<T, E>) -> Result<Pin<&mut T>, E> {
170
10.5k
        // SAFETY: We never move out of `this`.
171
10.5k
        let this = unsafe { Pin::into_inner_unchecked(self) };
172
10.5k
        // The value is currently initialized, so it needs to be dropped before we can reuse
173
10.5k
        // the memory (this is a safety guarantee of `Pin`).
174
10.5k
        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.5k
        }
179
        // SAFETY: The memory slot is valid and this type ensures that it will stay pinned.
180
10.5k
        unsafe { init.__pinned_init(this.value.as_mut_ptr())
?0
};
181
        // INVARIANT: `this.value` is initialized above.
182
10.5k
        this.is_init = true;
183
10.5k
        // SAFETY: The slot is now pinned, since we will never give access to `&mut T`.
184
10.5k
        Ok(unsafe { Pin::new_unchecked(this.value.assume_init_mut()) })
185
10.5k
    }
<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<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
10.5k
    pub fn init<E>(self: Pin<&mut Self>, init: impl PinInit<T, E>) -> Result<Pin<&mut T>, E> {
170
10.5k
        // SAFETY: We never move out of `this`.
171
10.5k
        let this = unsafe { Pin::into_inner_unchecked(self) };
172
10.5k
        // The value is currently initialized, so it needs to be dropped before we can reuse
173
10.5k
        // the memory (this is a safety guarantee of `Pin`).
174
10.5k
        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.5k
        }
179
        // SAFETY: The memory slot is valid and this type ensures that it will stay pinned.
180
10.5k
        unsafe { init.__pinned_init(this.value.as_mut_ptr())
?0
};
181
        // INVARIANT: `this.value` is initialized above.
182
10.5k
        this.is_init = true;
183
10.5k
        // SAFETY: The slot is now pinned, since we will never give access to `&mut T`.
184
10.5k
        Ok(unsafe { Pin::new_unchecked(this.value.assume_init_mut()) })
185
10.5k
    }
<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
        }));
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
        }));
Unexecuted instantiation: pinned_init::__internal::stack_init_reuse::{closure#0}::{closure#0}
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#2}
Line
Count
Source
205
1
        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 {
206
1
            a: 24,
207
1
            b: "world!".to_owned(),
208
1
        }));
Unexecuted instantiation: pinned_init::__internal::stack_init_reuse::{closure#2}::{closure#0}
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
        }));
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
204k
    pub unsafe fn new(ptr: *mut T) -> Self {
233
204k
        Self { ptr }
234
204k
    }
<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<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::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::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<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<[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<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<alloc_fail::ring_buf::mutex::linked_list::ListHead>>::new
Line
Count
Source
232
9.81k
    pub unsafe fn new(ptr: *mut T) -> Self {
233
9.81k
        Self { ptr }
234
9.81k
    }
<pinned_init::__internal::DropGuard<std::thread::Thread>>::new
Line
Count
Source
232
9.81k
    pub unsafe fn new(ptr: *mut T) -> Self {
233
9.81k
        Self { ptr }
234
9.81k
    }
<pinned_init::__internal::DropGuard<core::marker::PhantomPinned>>::new
Line
Count
Source
232
9.82k
    pub unsafe fn new(ptr: *mut T) -> Self {
233
9.82k
        Self { ptr }
234
9.82k
    }
<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<alloc::string::String>>::new
Line
Count
Source
232
11
    pub unsafe fn new(ptr: *mut T) -> Self {
233
11
        Self { ptr }
234
11
    }
Unexecuted instantiation: <pinned_init::__internal::DropGuard<[core::mem::maybe_uninit::MaybeUninit<u8>; 1099511627776usize]>>::new
<pinned_init::__internal::DropGuard<alloc_fail::ring_buf::mutex::linked_list::Link>>::new
Line
Count
Source
232
19.6k
    pub unsafe fn new(ptr: *mut T) -> Self {
233
19.6k
        Self { ptr }
234
19.6k
    }
<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<[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<*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<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::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::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<*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::linked_list::Link>>::new
Line
Count
Source
232
19.5k
    pub unsafe fn new(ptr: *mut T) -> Self {
233
19.5k
        Self { ptr }
234
19.5k
    }
<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<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<std::thread::Thread>>::new
Line
Count
Source
232
9.77k
    pub unsafe fn new(ptr: *mut T) -> Self {
233
9.77k
        Self { ptr }
234
9.77k
    }
<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
9.78k
    pub unsafe fn new(ptr: *mut T) -> Self {
233
9.78k
        Self { ptr }
234
9.78k
    }
<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<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::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::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<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<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<*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<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<ring_buf::mutex::linked_list::ListHead>>::new
Line
Count
Source
232
9.77k
    pub unsafe fn new(ptr: *mut T) -> Self {
233
9.77k
        Self { ptr }
234
9.77k
    }
<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<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<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::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<mutex::linked_list::ListHead>>::new
Line
Count
Source
232
10.5k
    pub unsafe fn new(ptr: *mut T) -> Self {
233
10.5k
        Self { ptr }
234
10.5k
    }
<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<mutex::linked_list::Link>>::new
Line
Count
Source
232
21.0k
    pub unsafe fn new(ptr: *mut T) -> Self {
233
21.0k
        Self { ptr }
234
21.0k
    }
<pinned_init::__internal::DropGuard<core::marker::PhantomPinned>>::new
Line
Count
Source
232
10.5k
    pub unsafe fn new(ptr: *mut T) -> Self {
233
10.5k
        Self { ptr }
234
10.5k
    }
<pinned_init::__internal::DropGuard<std::thread::Thread>>::new
Line
Count
Source
232
10.5k
    pub unsafe fn new(ptr: *mut T) -> Self {
233
10.5k
        Self { ptr }
234
10.5k
    }
<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<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::ListHead>>::new
Line
Count
Source
232
10.5k
    pub unsafe fn new(ptr: *mut T) -> Self {
233
10.5k
        Self { ptr }
234
10.5k
    }
<pinned_init::__internal::DropGuard<core::marker::PhantomPinned>>::new
Line
Count
Source
232
10.6k
    pub unsafe fn new(ptr: *mut T) -> Self {
233
10.6k
        Self { ptr }
234
10.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<std::thread::Thread>>::new
Line
Count
Source
232
10.5k
    pub unsafe fn new(ptr: *mut T) -> Self {
233
10.5k
        Self { ptr }
234
10.5k
    }
<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::linked_list::Link>>::new
Line
Count
Source
232
21.2k
    pub unsafe fn new(ptr: *mut T) -> Self {
233
21.2k
        Self { ptr }
234
21.2k
    }
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<std::thread::Thread> 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<[u8; 1048576usize]> 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<alloc_fail::ring_buf::EvenU64>; 4usize]> 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<alloc_fail::ring_buf::mutex::SpinLock> 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<alloc_fail::ring_buf::mutex::linked_list::Link> 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<[core::mem::maybe_uninit::MaybeUninit<alloc_fail::ring_buf::BigStruct>; 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<_> 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<ring_buf::mutex::SpinLock> 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<ring_buf::BigStruct>; 64usize]> 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::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<*mut ring_buf::EvenU64> 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
Unexecuted instantiation: <pinned_init::__internal::DropGuard<ring_buf::mutex::linked_list::Link> 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<*mut ring_buf::BigStruct> 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<core::cell::Cell<bool>> 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::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<mutex::SpinLock> 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<std::thread::Thread> 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::linked_list::Link> 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::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
40.7k
    pub unsafe fn new() -> Self {
257
40.7k
        Self(())
258
40.7k
    }
<pinned_init::__internal::OnlyCallFromDrop>::new
Line
Count
Source
256
40.7k
    pub unsafe fn new() -> Self {
257
40.7k
        Self(())
258
40.7k
    }
Unexecuted instantiation: <pinned_init::__internal::OnlyCallFromDrop>::new
259
}
\ No newline at end of file diff --git a/coverage/0cc6627eb51ae23c34d0682cbcaa611a9ade80bb/coverage/home/runner/work/pinned-init/pinned-init/src/lib.rs.html b/coverage/0cc6627eb51ae23c34d0682cbcaa611a9ade80bb/coverage/home/runner/work/pinned-init/pinned-init/src/lib.rs.html new file mode 100644 index 0000000..712723a --- /dev/null +++ b/coverage/0cc6627eb51ae23c34d0682cbcaa611a9ade80bb/coverage/home/runner/work/pinned-init/pinned-init/src/lib.rs.html @@ -0,0 +1 @@ +

Coverage Report

Created: 2023-07-19 13:34

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

Coverage Report

Created: 2023-07-19 13:34

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

Coverage Report

Created: 2023-07-19 13:34

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
  85.71% (6/7)
  96.97% (32/33)
  88.89% (8/9)
- (0/0)
Totals
  76.00% (38/50)
  69.75% (219/314)
  62.18% (74/119)
- (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/0cc6627eb51ae23c34d0682cbcaa611a9ade80bb/style.css b/coverage/0cc6627eb51ae23c34d0682cbcaa611a9ade80bb/style.css new file mode 100644 index 0000000..d95ffe2 --- /dev/null +++ b/coverage/0cc6627eb51ae23c34d0682cbcaa611a9ade80bb/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; +}