pub struct EarlyBinder<T> {
    value: T,
}
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

Implementations§

source§

impl<T> EarlyBinder<T>

source

pub fn bind(value: T) -> EarlyBinder<T>

source

pub fn as_ref(&self) -> EarlyBinder<&T>

source

pub fn map_bound_ref<F, U>(&self, f: F) -> EarlyBinder<U>
where F: FnOnce(&T) -> U,

source

pub fn map_bound<F, U>(self, f: F) -> EarlyBinder<U>
where F: FnOnce(T) -> U,

source

pub fn try_map_bound<F, U, E>(self, f: F) -> Result<EarlyBinder<U>, E>
where F: FnOnce(T) -> Result<U, E>,

source

pub fn rebind<U>(&self, value: U) -> EarlyBinder<U>

source

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<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<T> EarlyBinder<Option<T>>

source

pub fn transpose(self) -> Option<EarlyBinder<T>>

source§

impl<'tcx, 's, I: IntoIterator> EarlyBinder<I>
where I::Item: TypeFoldable<TyCtxt<'tcx>>,

source

pub fn iter_instantiated( self, tcx: TyCtxt<'tcx>, args: &'s [GenericArg<'tcx>] ) -> IterInstantiated<'s, 'tcx, I>

source

pub fn instantiate_identity_iter(self) -> I::IntoIter

Similar to instantiate_identity, but on an iterator of TypeFoldable values.

source§

impl<'tcx, 's, I: IntoIterator> EarlyBinder<I>
where I::Item: Deref, <<I as IntoIterator>::Item as Deref>::Target: Copy + TypeFoldable<TyCtxt<'tcx>>,

source

pub fn iter_instantiated_copied( self, tcx: TyCtxt<'tcx>, args: &'s [GenericArg<'tcx>] ) -> IterInstantiatedCopied<'s, 'tcx, I>

source

pub fn instantiate_identity_iter_copied( self ) -> impl Iterator<Item = <<I as IntoIterator>::Item as Deref>::Target>

Similar to instantiate_identity, but on an iterator of values that deref to a TypeFoldable.

source§

impl<T: IntoIterator> EarlyBinder<T>

source§

impl<'tcx, T: TypeFoldable<TyCtxt<'tcx>>> EarlyBinder<T>

source

pub fn instantiate(self, tcx: TyCtxt<'tcx>, args: &[GenericArg<'tcx>]) -> T

source

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 of EarlyBinder).
  • Inside of the body of foo, we treat T as a placeholder by calling instantiate_identity to discharge the EarlyBinder.
source

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>

source§

fn clone(&self) -> EarlyBinder<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Debug> Debug for EarlyBinder<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T, __D: SpanDecoder> Decodable<__D> for EarlyBinder<T>
where T: Decodable<__D>,

source§

fn decode(__decoder: &mut __D) -> Self

source§

impl<T, __E: SpanEncoder> Encodable<__E> for EarlyBinder<T>
where T: Encodable<__E>,

source§

fn encode(&self, __encoder: &mut __E)

source§

impl<T: EraseType> EraseType for EarlyBinder<T>

§

type Result = <T as EraseType>::Result

source§

impl<T: Hash> Hash for EarlyBinder<T>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<'__ctx, T> HashStable<StableHashingContext<'__ctx>> for EarlyBinder<T>
where T: HashStable<StableHashingContext<'__ctx>>,

source§

fn hash_stable( &self, __hcx: &mut StableHashingContext<'__ctx>, __hasher: &mut StableHasher )

source§

impl<T: Ord> Ord for EarlyBinder<T>

source§

fn cmp(&self, other: &EarlyBinder<T>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl<T: ParameterizedOverTcx> ParameterizedOverTcx for EarlyBinder<T>

§

type Value<'tcx> = EarlyBinder<<T as ParameterizedOverTcx>::Value<'tcx>>

source§

impl<T: PartialEq> PartialEq for EarlyBinder<T>

source§

fn eq(&self, other: &EarlyBinder<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: PartialOrd> PartialOrd for EarlyBinder<T>

source§

fn partial_cmp(&self, other: &EarlyBinder<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<'tcx, T> !TypeFoldable<TyCtxt<'tcx>> for EarlyBinder<T>

For early binders, you should first call instantiate 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>,

The entry point for folding. To fold a value t with a folder f call: t.try_fold_with(f). Read more
source§

fn fold_with<F>(self, folder: &mut F) -> Self
where F: TypeFolder<I>,

A convenient alternative to 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>

source§

fn visit_with<V>( &self, visitor: &mut V ) -> ControlFlow<<V as TypeVisitor<I>>::BreakTy>
where V: TypeVisitor<I>,

The entry point for visiting. To visit a value t with a visitor v call: t.visit_with(v). Read more
source§

impl<'tcx> Value<TyCtxt<'tcx>> for EarlyBinder<Binder<'_, FnSig<'_>>>

source§

fn from_cycle_error( tcx: TyCtxt<'tcx>, cycle_error: &CycleError, guar: ErrorGuaranteed ) -> Self

source§

impl<'tcx> Value<TyCtxt<'tcx>> for EarlyBinder<Ty<'_>>

source§

fn from_cycle_error( tcx: TyCtxt<'tcx>, cycle_error: &CycleError, guar: ErrorGuaranteed ) -> Self

source§

impl<T: Copy> Copy for EarlyBinder<T>

source§

impl<T: Eq> Eq for EarlyBinder<T>

source§

impl<T> StructuralPartialEq for EarlyBinder<T>

Auto Trait Implementations§

§

impl<T> DynSend for EarlyBinder<T>
where T: DynSend,

§

impl<T> DynSync for EarlyBinder<T>
where T: DynSync,

§

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<T> Aligned for T

source§

const ALIGN: Alignment = _

Alignment of Self.
source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> AnyEq for T
where T: Any + PartialEq,

§

fn equals(&self, other: &(dyn Any + 'static)) -> bool

§

fn as_any(&self) -> &(dyn Any + 'static)

source§

impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for T
where T: Copy,

source§

fn allocate_on<'a>(self, arena: &'a Arena<'tcx>) -> &'a mut T

source§

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 T
where T: Copy,

source§

fn allocate_on<'a>(self, arena: &'a Arena<'tcx>) -> &'a mut T

source§

fn allocate_from_iter<'a>( arena: &'a Arena<'tcx>, iter: impl IntoIterator<Item = T> ) -> &'a mut [T]

source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, R> CollectAndApply<T, R> for T

source§

fn collect_and_apply<I, F>(iter: I, f: F) -> R
where I: Iterator<Item = T>, F: FnOnce(&[T]) -> R,

Equivalent to f(&iter.collect::<Vec<_>>()).

§

type Output = R

§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
source§

impl<Tcx, T> DepNodeParams<Tcx> for T
where Tcx: DepContext, T: for<'a> HashStable<StableHashingContext<'a>> + Debug,

source§

default fn fingerprint_style() -> FingerprintStyle

source§

default fn to_fingerprint(&self, tcx: Tcx) -> Fingerprint

This method turns the parameters of a DepNodeConstructor into an opaque Fingerprint to be used in DepNode. Not all DepNodeParams support being turned into a Fingerprint (they don’t need to if the corresponding DepNode is anonymous).
source§

default fn to_debug_str(&self, _: Tcx) -> String

source§

default fn recover(_: Tcx, _: &DepNode) -> Option<T>

This method tries to recover the query key from the given DepNode, something which is needed when forcing DepNodes 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
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<T> Filterable for T

§

fn filterable( self, filter_name: &'static str ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>

Creates a filterable data provider with the given name for debugging. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<P> IntoQueryParam<P> for P

source§

impl<T> MaybeResult<T> for T

§

type Error = !

source§

fn from(_: Result<T, <T as MaybeResult<T>>::Error>) -> T

source§

fn to_result(self) -> Result<T, <T as MaybeResult<T>>::Error>

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<'tcx, T> ToPredicate<'tcx, T> for T

source§

fn to_predicate(self, _tcx: TyCtxt<'tcx>) -> T

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<Tcx, T> Value<Tcx> for T
where Tcx: DepContext,

source§

default fn from_cycle_error( tcx: Tcx, cycle_error: &CycleError, _guar: ErrorGuaranteed ) -> T

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<'a, T> Captures<'a> for T
where T: ?Sized,

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T
where T: Send + Sync,

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.