Struct EarlyBinder
pub struct EarlyBinder<I, T>where
I: Interner,{
value: T,
_tcx: PhantomData<I>,
}
Expand description
Similar to super::Binder
except that it tracks early bound generics, i.e. struct Foo<T>(T)
needs T
instantiated immediately. This type primarily exists to avoid forgetting to call
instantiate
.
If you don’t have anything to instantiate
, you may be looking for
instantiate_identity
or skip_binder
.
Fields§
§value: T
§_tcx: PhantomData<I>
Implementations§
§impl<I, T> EarlyBinder<I, T>where
I: Interner,
impl<I, T> EarlyBinder<I, T>where
I: Interner,
pub fn bind(value: T) -> EarlyBinder<I, T>
pub fn as_ref(&self) -> EarlyBinder<I, &T>
pub fn map_bound_ref<F, U>(&self, f: F) -> EarlyBinder<I, U>
pub fn map_bound<F, U>(self, f: F) -> EarlyBinder<I, U>where
F: FnOnce(T) -> U,
pub fn try_map_bound<F, U, E>(self, f: F) -> Result<EarlyBinder<I, U>, E>
pub fn rebind<U>(&self, value: U) -> EarlyBinder<I, U>
pub fn skip_binder(self) -> T
pub fn skip_binder(self) -> T
Skips the binder and returns the “bound” value.
This can be used to extract data that does not depend on generic parameters
(e.g., getting the DefId
of the inner value or getting the number of
arguments of an FnSig
). Otherwise, consider using
instantiate_identity
.
To skip the binder on x: &EarlyBinder<I, T>
to obtain &T
, leverage
EarlyBinder::as_ref
: x.as_ref().skip_binder()
.
See also Binder::skip_binder
, which is
the analogous operation on super::Binder
.
§impl<I, T> EarlyBinder<I, Option<T>>where
I: Interner,
impl<I, T> EarlyBinder<I, Option<T>>where
I: Interner,
pub fn transpose(self) -> Option<EarlyBinder<I, T>>
§impl<I, Iter> EarlyBinder<I, Iter>
impl<I, Iter> EarlyBinder<I, Iter>
pub fn iter_instantiated<A>( self, cx: I, args: A, ) -> IterInstantiated<I, Iter, A> ⓘ
pub fn iter_identity(self) -> <Iter as IntoIterator>::IntoIter
pub fn iter_identity(self) -> <Iter as IntoIterator>::IntoIter
Similar to instantiate_identity
,
but on an iterator of TypeFoldable
values.
§impl<'s, I, Iter> EarlyBinder<I, Iter>where
I: Interner,
Iter: IntoIterator,
<Iter as IntoIterator>::Item: Deref,
<<Iter as IntoIterator>::Item as Deref>::Target: Copy + TypeFoldable<I>,
impl<'s, I, Iter> EarlyBinder<I, Iter>where
I: Interner,
Iter: IntoIterator,
<Iter as IntoIterator>::Item: Deref,
<<Iter as IntoIterator>::Item as Deref>::Target: Copy + TypeFoldable<I>,
pub fn iter_instantiated_copied( self, cx: I, args: &'s [<I as Interner>::GenericArg], ) -> IterInstantiatedCopied<'s, I, Iter> ⓘ
pub fn iter_identity_copied(self) -> IterIdentityCopied<Iter> ⓘ
pub fn iter_identity_copied(self) -> IterIdentityCopied<Iter> ⓘ
Similar to instantiate_identity
,
but on an iterator of values that deref to a TypeFoldable
.
§impl<I, T> EarlyBinder<I, T>where
I: Interner,
T: IntoIterator,
impl<I, T> EarlyBinder<I, T>where
I: Interner,
T: IntoIterator,
pub fn transpose_iter(self) -> EarlyBinderIter<I, <T as IntoIterator>::IntoIter> ⓘ
§impl<I, T> EarlyBinder<I, T>where
I: Interner,
T: TypeFoldable<I>,
impl<I, T> EarlyBinder<I, T>where
I: Interner,
T: TypeFoldable<I>,
pub fn instantiate<A>(self, cx: I, args: A) -> T
pub fn instantiate_identity(self) -> T
pub fn instantiate_identity(self) -> T
Makes the identity replacement T0 => T0, ..., TN => TN
.
Conceptually, this converts universally bound variables into placeholders
when inside of a given item.
For example, consider for<T> fn foo<T>(){ .. }
:
- Outside of
foo
,T
is bound (represented by the presence ofEarlyBinder
). - Inside of the body of
foo
, we treatT
as a placeholder by callinginstantiate_identity
to discharge theEarlyBinder
.
pub fn no_bound_vars(self) -> Option<T>
pub fn no_bound_vars(self) -> Option<T>
Returns the inner value, but only if it contains no bound vars.
Trait Implementations§
§impl<I, T> Clone for EarlyBinder<I, T>
impl<I, T> Clone for EarlyBinder<I, T>
§fn clone(&self) -> EarlyBinder<I, T>
fn clone(&self) -> EarlyBinder<I, T>
Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl<I, T> Debug for EarlyBinder<I, T>
impl<I, T> Debug for EarlyBinder<I, T>
§impl<I, T, __D> Decodable<__D> for EarlyBinder<I, T>
impl<I, T, __D> Decodable<__D> for EarlyBinder<I, T>
fn decode(__decoder: &mut __D) -> EarlyBinder<I, T>
§impl<I, T, __E> Encodable<__E> for EarlyBinder<I, T>
impl<I, T, __E> Encodable<__E> for EarlyBinder<I, T>
§impl<I, T> Hash for EarlyBinder<I, T>
impl<I, T> Hash for EarlyBinder<I, T>
§impl<I, T, __CTX> HashStable<__CTX> for EarlyBinder<I, T>
impl<I, T, __CTX> HashStable<__CTX> for EarlyBinder<I, T>
fn hash_stable( &self, __hcx: &mut __CTX, __hasher: &mut StableHasher<SipHasher128>, )
§impl<I, T> Ord for EarlyBinder<I, T>
impl<I, T> Ord for EarlyBinder<I, T>
Source§impl<T> ParameterizedOverTcx for EarlyBinder<TyCtxt<'static>, T>where
T: ParameterizedOverTcx,
impl<T> ParameterizedOverTcx for EarlyBinder<TyCtxt<'static>, T>where
T: ParameterizedOverTcx,
type Value<'tcx> = EarlyBinder<TyCtxt<'tcx>, <T as ParameterizedOverTcx>::Value<'tcx>>
§impl<I, T> PartialEq for EarlyBinder<I, T>
impl<I, T> PartialEq for EarlyBinder<I, T>
§impl<I, T> PartialOrd for EarlyBinder<I, T>
impl<I, T> PartialOrd for EarlyBinder<I, T>
Source§impl<'tcx> Value<TyCtxt<'tcx>> for EarlyBinder<TyCtxt<'_>, Binder<TyCtxt<'_>, FnSig<TyCtxt<'_>>>>
impl<'tcx> Value<TyCtxt<'tcx>> for EarlyBinder<TyCtxt<'_>, Binder<TyCtxt<'_>, FnSig<TyCtxt<'_>>>>
fn from_cycle_error( tcx: TyCtxt<'tcx>, cycle_error: &CycleError, guar: ErrorGuaranteed, ) -> EarlyBinder<TyCtxt<'_>, Binder<TyCtxt<'_>, FnSig<TyCtxt<'_>>>>
Source§impl<'tcx> Value<TyCtxt<'tcx>> for EarlyBinder<TyCtxt<'_>, Ty<'_>>
impl<'tcx> Value<TyCtxt<'tcx>> for EarlyBinder<TyCtxt<'_>, Ty<'_>>
fn from_cycle_error( tcx: TyCtxt<'tcx>, cycle_error: &CycleError, guar: ErrorGuaranteed, ) -> EarlyBinder<TyCtxt<'_>, Ty<'_>>
impl<I, T> Copy for EarlyBinder<I, T>
impl<I, T> Eq for EarlyBinder<I, T>
impl<I, T> !TypeFoldable<I> for EarlyBinder<I, T>where
I: Interner,
For early binders, you should first call instantiate
before using any visitors.
impl<I, T> !TypeVisitable<I> for EarlyBinder<I, T>where
I: Interner,
For early binders, you should first call instantiate
before using any visitors.
Auto Trait Implementations§
impl<I, T> DynSend for EarlyBinder<I, T>
impl<I, T> DynSync for EarlyBinder<I, T>
impl<I, T> Freeze for EarlyBinder<I, T>where
T: Freeze,
impl<I, T> RefUnwindSafe for EarlyBinder<I, T>where
T: RefUnwindSafe,
I: RefUnwindSafe,
impl<I, T> Send for EarlyBinder<I, T>
impl<I, T> Sync for EarlyBinder<I, T>
impl<I, T> Unpin for EarlyBinder<I, T>
impl<I, T> UnwindSafe for EarlyBinder<I, T>where
T: UnwindSafe,
I: UnwindSafe,
Blanket Implementations§
§impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere
T: Copy,
impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere
T: Copy,
fn allocate_on(self, arena: &'tcx Arena<'tcx>) -> &'tcx mut T
fn allocate_from_iter( arena: &'tcx Arena<'tcx>, iter: impl IntoIterator<Item = T>, ) -> &'tcx mut [T]
Source§impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere
T: Copy,
impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere
T: Copy,
fn allocate_on(self, arena: &'tcx Arena<'tcx>) -> &'tcx mut T
fn allocate_from_iter( arena: &'tcx Arena<'tcx>, iter: impl IntoIterator<Item = T>, ) -> &'tcx mut [T]
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,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Tcx, T> DepNodeParams<Tcx> for T
impl<Tcx, T> DepNodeParams<Tcx> for T
default fn fingerprint_style() -> FingerprintStyle
Source§default fn to_fingerprint(&self, tcx: Tcx) -> Fingerprint
default fn to_fingerprint(&self, tcx: Tcx) -> Fingerprint
default fn to_debug_str(&self, _: Tcx) -> String
Source§default fn recover(_: Tcx, _: &DepNode) -> Option<T>
default fn recover(_: Tcx, _: &DepNode) -> Option<T>
DepNode
,
something which is needed when forcing DepNode
s during red-green
evaluation. The query system will only call this method if
fingerprint_style()
is not FingerprintStyle::Opaque
.
It is always valid to return None
here, in which case incremental
compilation will treat the query as having changed instead of forcing it.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> Filterable for T
impl<T> Filterable for T
Source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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 moreSource§impl<P> IntoQueryParam<P> for P
impl<P> IntoQueryParam<P> for P
fn into_query_param(self) -> P
Source§impl<T> MaybeResult<T> for T
impl<T> MaybeResult<T> for T
Source§impl<T> Pointable for T
impl<T> Pointable for T
§impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
§impl<I, T> UpcastFrom<I, T> for T
impl<I, T> UpcastFrom<I, T> for T
fn upcast_from(from: T, _tcx: I) -> T
Source§impl<Tcx, T> Value<Tcx> for Twhere
Tcx: DepContext,
impl<Tcx, T> Value<Tcx> for Twhere
Tcx: DepContext,
default fn from_cycle_error( tcx: Tcx, cycle_error: &CycleError, _guar: ErrorGuaranteed, ) -> T
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> MaybeSendSync for T
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.