Struct rustc_middle::ty::subst::EarlyBinder
source · pub struct EarlyBinder<T>(pub T);
Expand description
Similar to super::Binder
except that it tracks early bound generics, i.e. struct Foo<T>(T)
needs T
substituted immediately. This type primarily exists to avoid forgetting to call
subst
.
If you don’t have anything to subst
, you may be looking for
subst_identity
or skip_binder
.
Tuple Fields§
§0: T
Implementations§
source§impl<T> EarlyBinder<T>
impl<T> EarlyBinder<T>
pub fn as_ref(&self) -> EarlyBinder<&T>
pub fn map_bound_ref<F, U>(&self, f: F) -> EarlyBinder<U>where F: FnOnce(&T) -> U,
pub fn map_bound<F, U>(self, f: F) -> EarlyBinder<U>where F: FnOnce(T) -> U,
pub fn try_map_bound<F, U, E>(self, f: F) -> Result<EarlyBinder<U>, E>where F: FnOnce(T) -> Result<U, E>,
pub fn rebind<U>(&self, value: U) -> EarlyBinder<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
subst_identity
.
See also Binder::skip_binder
, which is
the analogous operation on super::Binder
.
source§impl<T> EarlyBinder<Option<T>>
impl<T> EarlyBinder<Option<T>>
pub fn transpose(self) -> Option<EarlyBinder<T>>
source§impl<T, U> EarlyBinder<(T, U)>
impl<T, U> EarlyBinder<(T, U)>
pub fn transpose_tuple2(self) -> (EarlyBinder<T>, EarlyBinder<U>)
source§impl<'tcx, 's, I: IntoIterator> EarlyBinder<I>where
I::Item: TypeFoldable<TyCtxt<'tcx>>,
impl<'tcx, 's, I: IntoIterator> EarlyBinder<I>where I::Item: TypeFoldable<TyCtxt<'tcx>>,
pub fn subst_iter( self, tcx: TyCtxt<'tcx>, substs: &'s [GenericArg<'tcx>] ) -> SubstIter<'s, 'tcx, I> ⓘ
source§impl<'tcx, 's, I: IntoIterator> EarlyBinder<I>where
I::Item: Deref,
<<I as IntoIterator>::Item as Deref>::Target: Copy + TypeFoldable<TyCtxt<'tcx>>,
impl<'tcx, 's, I: IntoIterator> EarlyBinder<I>where I::Item: Deref, <<I as IntoIterator>::Item as Deref>::Target: Copy + TypeFoldable<TyCtxt<'tcx>>,
pub fn subst_iter_copied( self, tcx: TyCtxt<'tcx>, substs: &'s [GenericArg<'tcx>] ) -> SubstIterCopied<'s, 'tcx, I> ⓘ
source§impl<T: IntoIterator> EarlyBinder<T>
impl<T: IntoIterator> EarlyBinder<T>
pub fn transpose_iter(self) -> EarlyBinderIter<T::IntoIter> ⓘ
source§impl<'tcx, T: TypeFoldable<TyCtxt<'tcx>>> EarlyBinder<T>
impl<'tcx, T: TypeFoldable<TyCtxt<'tcx>>> EarlyBinder<T>
pub fn subst(self, tcx: TyCtxt<'tcx>, substs: &[GenericArg<'tcx>]) -> T
sourcepub fn subst_identity(self) -> T
pub fn subst_identity(self) -> T
Makes the identity substitution 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 callingsubst_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<T: Clone> Clone for EarlyBinder<T>
impl<T: Clone> Clone for EarlyBinder<T>
source§fn clone(&self) -> EarlyBinder<T>
fn clone(&self) -> EarlyBinder<T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<T: Debug> Debug for EarlyBinder<T>
impl<T: Debug> Debug for EarlyBinder<T>
source§impl<T: Hash> Hash for EarlyBinder<T>
impl<T: Hash> Hash for EarlyBinder<T>
source§impl<'__ctx, T> HashStable<StableHashingContext<'__ctx>> for EarlyBinder<T>where
T: HashStable<StableHashingContext<'__ctx>>,
impl<'__ctx, T> HashStable<StableHashingContext<'__ctx>> for EarlyBinder<T>where T: HashStable<StableHashingContext<'__ctx>>,
fn hash_stable( &self, __hcx: &mut StableHashingContext<'__ctx>, __hasher: &mut StableHasher )
source§impl<T: Ord> Ord for EarlyBinder<T>
impl<T: Ord> Ord for EarlyBinder<T>
source§fn cmp(&self, other: &EarlyBinder<T>) -> Ordering
fn cmp(&self, other: &EarlyBinder<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> ParameterizedOverTcx for EarlyBinder<T>
impl<T: ParameterizedOverTcx> ParameterizedOverTcx for EarlyBinder<T>
type Value<'tcx> = EarlyBinder<<T as ParameterizedOverTcx>::Value<'tcx>>
source§impl<T: PartialEq> PartialEq<EarlyBinder<T>> for EarlyBinder<T>
impl<T: PartialEq> PartialEq<EarlyBinder<T>> for EarlyBinder<T>
source§fn eq(&self, other: &EarlyBinder<T>) -> bool
fn eq(&self, other: &EarlyBinder<T>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<T: PartialOrd> PartialOrd<EarlyBinder<T>> for EarlyBinder<T>
impl<T: PartialOrd> PartialOrd<EarlyBinder<T>> for EarlyBinder<T>
source§fn partial_cmp(&self, other: &EarlyBinder<T>) -> Option<Ordering>
fn partial_cmp(&self, other: &EarlyBinder<T>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<'tcx, T> !TypeFoldable<TyCtxt<'tcx>> for EarlyBinder<T>
impl<'tcx, T> !TypeFoldable<TyCtxt<'tcx>> for EarlyBinder<T>
For early binders, you should first call subst
before using any visitors.
source§fn try_fold_with<F>(
self,
folder: &mut F
) -> Result<Self, <F as FallibleTypeFolder<I>>::Error>where
F: FallibleTypeFolder<I>,
fn try_fold_with<F>( self, folder: &mut F ) -> Result<Self, <F as FallibleTypeFolder<I>>::Error>where F: FallibleTypeFolder<I>,
source§fn fold_with<F>(self, folder: &mut F) -> Selfwhere
F: TypeFolder<I>,
fn fold_with<F>(self, folder: &mut F) -> Selfwhere F: TypeFolder<I>,
try_fold_with
for use with infallible
folders. Do not override this method, to ensure coherence with
try_fold_with
.source§impl<'tcx, T> !TypeVisitable<TyCtxt<'tcx>> for EarlyBinder<T>
impl<'tcx, T> !TypeVisitable<TyCtxt<'tcx>> for EarlyBinder<T>
source§fn visit_with<V>(
&self,
visitor: &mut V
) -> ControlFlow<<V as TypeVisitor<I>>::BreakTy, ()>where
V: TypeVisitor<I>,
fn visit_with<V>( &self, visitor: &mut V ) -> ControlFlow<<V as TypeVisitor<I>>::BreakTy, ()>where V: TypeVisitor<I>,
impl<T: Copy> Copy for EarlyBinder<T>
impl<T: Eq> Eq for EarlyBinder<T>
impl<T> StructuralEq for EarlyBinder<T>
impl<T> StructuralPartialEq for EarlyBinder<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for EarlyBinder<T>where T: RefUnwindSafe,
impl<T> Send for EarlyBinder<T>where T: Send,
impl<T> Sync for EarlyBinder<T>where T: Sync,
impl<T> Unpin for EarlyBinder<T>where T: Unpin,
impl<T> UnwindSafe for EarlyBinder<T>where T: 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<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
source§impl<Tcx, T> DepNodeParams<Tcx> for Twhere
Tcx: DepContext,
T: for<'a> HashStable<StableHashingContext<'a>> + Debug,
impl<Tcx, T> DepNodeParams<Tcx> for Twhere Tcx: DepContext, T: for<'a> HashStable<StableHashingContext<'a>> + Debug,
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<<Tcx as DepContext>::DepKind>
) -> Option<T>
default fn recover( _: Tcx, _: &DepNode<<Tcx as DepContext>::DepKind> ) -> 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<T> MaybeResult<T> for T
impl<T> MaybeResult<T> for T
source§impl<'tcx, T> ToPredicate<'tcx, T> for T
impl<'tcx, T> ToPredicate<'tcx, T> for T
fn to_predicate(self, _tcx: TyCtxt<'tcx>) -> T
source§impl<Tcx, T, D> Value<Tcx, D> for Twhere
Tcx: DepContext,
D: DepKind,
impl<Tcx, T, D> Value<Tcx, D> for Twhere Tcx: DepContext, D: DepKind,
default fn from_cycle_error(tcx: Tcx, _: &[QueryInfo<D>]) -> 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.