pub struct ClosureData {
pub min_captures: FxIndexMap<BindingId, Vec<CapturedPlace>>,
pub fake_reads: Box<[(Place, FakeReadCause, SmallVec<[CaptureSourceStack; 2]>)]>,
pub liberated_sig: StoredFnSig,
}Fields§
§min_captures: FxIndexMap<BindingId, Vec<CapturedPlace>>Tracks the minimum captures required for a closure;
see MinCaptureInformationMap for more details.
fake_reads: Box<[(Place, FakeReadCause, SmallVec<[CaptureSourceStack; 2]>)]>Tracks the fake reads required for a closure and the reason for the fake read. When performing pattern matching for closures, there are times we don’t end up reading places that are mentioned in a closure (because of _ patterns). However, to ensure the places are initialized, we introduce fake reads. Consider these two examples:
let x: u8;
let c = || match x { _ => () };In this example, we don’t need to actually read/borrow x in c, and so we don’t
want to capture it. However, we do still want an error here, because x should have
to be initialized at the point where c is created. Therefore, we add a “fake read”
instead.
let c = || {
let (t1, t2) = t;
}In the second example, we capture the disjoint fields of t (t.0 & t.1), but
we never capture t. This becomes an issue when we build MIR as we require
information on t in order to create place t.0 and t.1. We can solve this
issue by fake reading t.
liberated_sig: StoredFnSigFor each fn, records the “liberated” types of its arguments and return type. Liberated means that all bound regions (including late-bound regions) are replaced with free equivalents. This table is not used in codegen (since regions are erased there) and hence is not serialized to metadata.
This table also contains the “revealed” values for any impl Trait
that appear in the signature and whose values are being inferred
by this function.
§Example
fn foo(x: &u32) -> impl Debug { *x }The function signature here would be:
for<'a> fn(&'a u32) -> Foowhere Foo is an opaque type created for this function.
The liberated form of this would be
fn(&'a u32) -> u32Note that 'a is not bound (it would be an ReLateParam) and
that the Foo opaque type is replaced by its hidden type.
Trait Implementations§
Source§impl Clone for ClosureData
impl Clone for ClosureData
Source§fn clone(&self) -> ClosureData
fn clone(&self) -> ClosureData
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ClosureData
impl Debug for ClosureData
impl Eq for ClosureData
Source§impl PartialEq for ClosureData
impl PartialEq for ClosureData
Source§fn eq(&self, other: &ClosureData) -> bool
fn eq(&self, other: &ClosureData) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for ClosureData
Auto Trait Implementations§
impl Freeze for ClosureData
impl RefUnwindSafe for ClosureData
impl Send for ClosureData
impl Sync for ClosureData
impl Unpin for ClosureData
impl UnsafeUnpin for ClosureData
impl UnwindSafe for ClosureData
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more