Struct rustc_infer::infer::canonical::ir::EarlyBinder
source · 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§
source§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>
sourcepub 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
.
source§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>>
source§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> ⓘ
sourcepub 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.
source§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> ⓘ
sourcepub fn iter_identity_copied(
self,
) -> impl Iterator<Item = <<Iter as IntoIterator>::Item as Deref>::Target>
pub fn iter_identity_copied( self, ) -> impl Iterator<Item = <<Iter as IntoIterator>::Item as Deref>::Target>
Similar to instantiate_identity
,
but on an iterator of values that deref to a TypeFoldable
.
source§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> ⓘ
source§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
sourcepub 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
.
sourcepub 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§
source§impl<I, T> Clone for EarlyBinder<I, T>
impl<I, T> Clone for EarlyBinder<I, T>
source§fn clone(&self) -> EarlyBinder<I, T>
fn clone(&self) -> EarlyBinder<I, T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<I, T> Debug for EarlyBinder<I, T>
impl<I, T> Debug for EarlyBinder<I, T>
source§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>
source§impl<I, T, __E> Encodable<__E> for EarlyBinder<I, T>
impl<I, T, __E> Encodable<__E> for EarlyBinder<I, T>
source§impl<I, T> Hash for EarlyBinder<I, T>
impl<I, T> Hash for EarlyBinder<I, T>
source§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>, )
source§impl<I, T> Ord for EarlyBinder<I, T>
impl<I, T> Ord for EarlyBinder<I, T>
source§fn cmp(&self, __other: &EarlyBinder<I, T>) -> Ordering
fn cmp(&self, __other: &EarlyBinder<I, T>) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
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>>
source§impl<I, T> PartialEq for EarlyBinder<I, T>
impl<I, T> PartialEq for EarlyBinder<I, T>
source§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> 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§
source§impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere
T: Copy,
impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere
T: Copy,
fn allocate_on<'a>(self, arena: &'a Arena<'tcx>) -> &'a mut T
fn allocate_from_iter<'a>( arena: &'a Arena<'tcx>, iter: impl IntoIterator<Item = T>, ) -> &'a 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<'a>(self, arena: &'a Arena<'tcx>) -> &'a mut T
fn allocate_from_iter<'a>( arena: &'a Arena<'tcx>, iter: impl IntoIterator<Item = T>, ) -> &'a 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
)source§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<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>,
source§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.