Struct rustc_middle::ty::sty::Binder [−][src]
Binder is a binder for higher-ranked lifetimes or types. It is part of the
compiler’s representation for things like for<'a> Fn(&'a isize)
(which would be represented by the type PolyTraitRef == Binder<TraitRef>). Note that when we instantiate,
erase, or otherwise “discharge” these bound vars, we change the
type from Binder<T> to just T (see
e.g., liberate_late_bound_regions).
Decodable and Encodable are implemented for Binder<T> using the impl_binder_encode_decode! macro.
Implementations
impl<'tcx> Binder<TraitRef<'tcx>>[src]
pub fn print_only_trait_path(self) -> Binder<TraitRefPrintOnlyTraitPath<'tcx>>[src]
impl<'tcx> Binder<ExistentialPredicate<'tcx>>[src]
pub fn with_self_ty(
&self,
tcx: TyCtxt<'tcx>,
self_ty: Ty<'tcx>
) -> Predicate<'tcx>[src]
&self,
tcx: TyCtxt<'tcx>,
self_ty: Ty<'tcx>
) -> Predicate<'tcx>
impl<'tcx> Binder<TraitRef<'tcx>>[src]
pub fn self_ty(&self) -> Binder<Ty<'tcx>>[src]
pub fn def_id(&self) -> DefId[src]
pub fn to_poly_trait_predicate(&self) -> PolyTraitPredicate<'tcx>[src]
impl<'tcx> Binder<ExistentialTraitRef<'tcx>>[src]
pub fn def_id(&self) -> DefId[src]
pub fn with_self_ty(
&self,
tcx: TyCtxt<'tcx>,
self_ty: Ty<'tcx>
) -> PolyTraitRef<'tcx>[src]
&self,
tcx: TyCtxt<'tcx>,
self_ty: Ty<'tcx>
) -> PolyTraitRef<'tcx>
Object types don’t have a self type specified. Therefore, when
we convert the principal trait-ref into a normal trait-ref,
you must give some self type. A common choice is mk_err()
or some placeholder type.
impl<T> Binder<T>[src]
pub fn dummy<'tcx>(value: T) -> Binder<T> where
T: TypeFoldable<'tcx>, [src]
T: TypeFoldable<'tcx>,
Wraps value in a binder, asserting that value does not
contain any bound vars that would be bound by the
binder. This is commonly used to ‘inject’ a value T into a
different binding level.
pub fn bind(value: T) -> Binder<T>[src]
Wraps value in a binder, binding higher-ranked vars (if any).
pub fn wrap_nonbinding<'tcx>(tcx: TyCtxt<'tcx>, value: T) -> Binder<T> where
T: TypeFoldable<'tcx>, [src]
T: TypeFoldable<'tcx>,
Wraps value in a binder without actually binding any currently
unbound variables.
Note that this will shift all debrujin indices of escaping bound variables by 1 to avoid accidential captures.
pub fn skip_binder(self) -> T[src]
Skips the binder and returns the “bound” value. This is a
risky thing to do because it’s easy to get confused about
De Bruijn indices and the like. It is usually better to
discharge the binder using no_bound_vars or
replace_late_bound_regions or something like
that. skip_binder is only valid when you are either
extracting data that has nothing to do with bound vars, you
are doing some sort of test that does not involve bound
regions, or you are being very careful about your depth
accounting.
Some examples where skip_binder is reasonable:
- extracting the
DefIdfrom a PolyTraitRef; - comparing the self type of a PolyTraitRef to see if it is equal to
a type parameter
X, since the typeXdoes not reference any regions
pub fn as_ref(&self) -> Binder<&T>[src]
pub fn map_bound_ref<F, U>(&self, f: F) -> Binder<U> where
F: FnOnce(&T) -> U, [src]
F: FnOnce(&T) -> U,
pub fn map_bound<F, U>(self, f: F) -> Binder<U> where
F: FnOnce(T) -> U, [src]
F: FnOnce(T) -> U,
pub fn rebind<U>(&self, value: U) -> Binder<U>[src]
Wraps a value in a binder, using the same bound variables as the
current Binder. This should not be used if the new value changes
the bound variables. Note: the (old or new) value itself does not
necessarily need to name all the bound variables.
This currently doesn’t do anything different than bind, because we
don’t actually track bound vars. However, semantically, it is different
because bound vars aren’t allowed to change here, whereas they are
in bind. This may be (debug) asserted in the future.
pub fn no_bound_vars<'tcx>(self) -> Option<T> where
T: TypeFoldable<'tcx>, [src]
T: TypeFoldable<'tcx>,
Unwraps and returns the value within, but only if it contains
no bound vars at all. (In other words, if this binder –
and indeed any enclosing binder – doesn’t bind anything at
all.) Otherwise, returns None.
(One could imagine having a method that just unwraps a single binder, but permits late-bound vars bound by enclosing binders, but that would require adjusting the debruijn indices, and given the shallow binding structure we often use, would not be that useful.)
pub fn fuse<U, F, R>(self, u: Binder<U>, f: F) -> Binder<R> where
F: FnOnce(T, U) -> R, [src]
F: FnOnce(T, U) -> R,
Given two things that have the same binder level, and an operation that wraps on their contents, executes the operation and then wraps its result.
f should consider bound regions at depth 1 to be free, and
anything it produces with bound regions at depth 1 will be
bound in the resulting return value.
pub fn split<U, V, F>(self, f: F) -> (Binder<U>, Binder<V>) where
F: FnOnce(T) -> (U, V), [src]
F: FnOnce(T) -> (U, V),
Splits the contents into two things that share the same binder level as the original, returning two distinct binders.
f should consider bound regions at depth 1 to be free, and
anything it produces with bound regions at depth 1 will be
bound in the resulting return values.
impl<T> Binder<Option<T>>[src]
impl<'tcx> Binder<GenSig<'tcx>>[src]
pub fn resume_ty(&self) -> Binder<Ty<'tcx>>[src]
pub fn yield_ty(&self) -> Binder<Ty<'tcx>>[src]
pub fn return_ty(&self) -> Binder<Ty<'tcx>>[src]
impl<'tcx> Binder<FnSig<'tcx>>[src]
pub fn inputs(&self) -> Binder<&'tcx [Ty<'tcx>]>[src]
pub fn input(&self, index: usize) -> Binder<Ty<'tcx>>[src]
pub fn inputs_and_output(&self) -> Binder<&'tcx List<Ty<'tcx>>>[src]
pub fn output(&self) -> Binder<Ty<'tcx>>[src]
pub fn c_variadic(&self) -> bool[src]
pub fn unsafety(&self) -> Unsafety[src]
pub fn abi(&self) -> Abi[src]
impl<'tcx> Binder<ExistentialProjection<'tcx>>[src]
pub fn with_self_ty(
&self,
tcx: TyCtxt<'tcx>,
self_ty: Ty<'tcx>
) -> PolyProjectionPredicate<'tcx>[src]
&self,
tcx: TyCtxt<'tcx>,
self_ty: Ty<'tcx>
) -> PolyProjectionPredicate<'tcx>
pub fn item_def_id(&self) -> DefId[src]
impl<'tcx> Binder<TraitPredicate<'tcx>>[src]
impl<'tcx> Binder<ProjectionPredicate<'tcx>>[src]
pub fn item_def_id(&self) -> DefId[src]
Returns the DefId of the associated item being projected.
pub fn trait_def_id(&self, tcx: TyCtxt<'tcx>) -> DefId[src]
Returns the DefId of the trait of the associated item being projected.
pub fn projection_self_ty(&self) -> Binder<Ty<'tcx>>[src]
pub fn required_poly_trait_ref(&self, tcx: TyCtxt<'tcx>) -> PolyTraitRef<'tcx>[src]
Get the PolyTraitRef required for this projection to be well formed. Note that for generic associated types the predicates of the associated type also need to be checked.
pub fn ty(&self) -> Binder<Ty<'tcx>>[src]
pub fn projection_def_id(&self) -> DefId[src]
The DefId of the TraitItem for the associated type.
Note that this is not the DefId of the TraitRef containing this
associated type, which is in tcx.associated_item(projection_def_id()).container.
Trait Implementations
impl<'tcx> Borrow<Binder<PredicateKind<'tcx>>> for Interned<'tcx, PredicateInner<'tcx>>[src]
fn borrow<'a>(&'a self) -> &'a Binder<PredicateKind<'tcx>>[src]
impl<T: Clone> Clone for Binder<T>[src]
impl<T: Copy> Copy for Binder<T>[src]
impl<T: Debug> Debug for Binder<T>[src]
impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for Binder<PredicateKind<'tcx>>[src]
impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for Binder<&'tcx List<Ty<'tcx>>>[src]
impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for Binder<FnSig<'tcx>>[src]
impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for Binder<ExistentialPredicate<'tcx>>[src]
impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for Binder<TraitRef<'tcx>>[src]
impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for Binder<Vec<GeneratorInteriorTypeCause<'tcx>>>[src]
impl<'tcx> Display for Binder<ExistentialPredicate<'tcx>>[src]
impl<'tcx> Display for Binder<TraitRef<'tcx>>[src]
impl<'tcx> Display for Binder<TraitRefPrintOnlyTraitPath<'tcx>>[src]
impl<'tcx> Display for Binder<FnSig<'tcx>>[src]
impl<'tcx> Display for Binder<TraitPredicate<'tcx>>[src]
impl<'tcx> Display for Binder<SubtypePredicate<'tcx>>[src]
impl<'tcx> Display for Binder<ProjectionPredicate<'tcx>>[src]
impl<'tcx> Display for Binder<OutlivesPredicate<Ty<'tcx>, Region<'tcx>>>[src]
impl<'tcx> Display for Binder<OutlivesPredicate<Region<'tcx>, Region<'tcx>>>[src]
impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for Binder<PredicateKind<'tcx>>[src]
impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for Binder<&'tcx List<Ty<'tcx>>>[src]
impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for Binder<FnSig<'tcx>>[src]
impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for Binder<ExistentialPredicate<'tcx>>[src]
impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for Binder<TraitRef<'tcx>>[src]
impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for Binder<Vec<GeneratorInteriorTypeCause<'tcx>>>[src]
impl<T: Eq> Eq for Binder<T>[src]
impl<T: Hash> Hash for Binder<T>[src]
fn hash<__H: Hasher>(&self, state: &mut __H)[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
impl<'a, T> HashStable<StableHashingContext<'a>> for Binder<T> where
T: HashStable<StableHashingContext<'a>>, [src]
T: HashStable<StableHashingContext<'a>>,
fn hash_stable(
&self,
hcx: &mut StableHashingContext<'a>,
hasher: &mut StableHasher
)[src]
&self,
hcx: &mut StableHashingContext<'a>,
hasher: &mut StableHasher
)
impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for Binder<T>[src]
impl<T: Ord> Ord for Binder<T>[src]
fn cmp(&self, other: &Binder<T>) -> Ordering[src]
#[must_use]pub fn max(self, other: Self) -> Self1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self1.50.0[src]
impl<T: PartialEq> PartialEq<Binder<T>> for Binder<T>[src]
impl<T: PartialOrd> PartialOrd<Binder<T>> for Binder<T>[src]
fn partial_cmp(&self, other: &Binder<T>) -> Option<Ordering>[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl<'tcx, T, P: PrettyPrinter<'tcx>> Print<'tcx, P> for Binder<T> where
T: Print<'tcx, P, Output = P, Error = P::Error> + TypeFoldable<'tcx>, [src]
T: Print<'tcx, P, Output = P, Error = P::Error> + TypeFoldable<'tcx>,
type Output = P
type Error = P::Error
fn print(&self, cx: P) -> Result<Self::Output, Self::Error>[src]
impl<'tcx, T: Relate<'tcx>> Relate<'tcx> for Binder<T>[src]
fn relate<R: TypeRelation<'tcx>>(
relation: &mut R,
a: Binder<T>,
b: Binder<T>
) -> RelateResult<'tcx, Binder<T>>[src]
relation: &mut R,
a: Binder<T>,
b: Binder<T>
) -> RelateResult<'tcx, Binder<T>>
impl<T> StructuralEq for Binder<T>[src]
impl<T> StructuralPartialEq for Binder<T>[src]
impl<'tcx> ToPredicate<'tcx> for Binder<PredicateKind<'tcx>>[src]
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx>[src]
impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Binder<T>[src]
fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self[src]
fn fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self[src]
fn super_visit_with<V: TypeVisitor<'tcx>>(
&self,
visitor: &mut V
) -> ControlFlow<V::BreakTy>[src]
&self,
visitor: &mut V
) -> ControlFlow<V::BreakTy>
fn visit_with<V: TypeVisitor<'tcx>>(
&self,
visitor: &mut V
) -> ControlFlow<V::BreakTy>[src]
&self,
visitor: &mut V
) -> ControlFlow<V::BreakTy>
fn has_vars_bound_at_or_above(&self, binder: DebruijnIndex) -> bool[src]
fn has_vars_bound_above(&self, binder: DebruijnIndex) -> bool[src]
fn has_escaping_bound_vars(&self) -> bool[src]
fn has_type_flags(&self, flags: TypeFlags) -> bool[src]
fn has_projections(&self) -> bool[src]
fn has_opaque_types(&self) -> bool[src]
fn references_error(&self) -> bool[src]
fn has_param_types_or_consts(&self) -> bool[src]
fn has_infer_regions(&self) -> bool[src]
fn has_infer_types(&self) -> bool[src]
fn has_infer_types_or_consts(&self) -> bool[src]
fn needs_infer(&self) -> bool[src]
fn has_placeholders(&self) -> bool[src]
fn needs_subst(&self) -> bool[src]
fn has_free_regions(&self) -> bool[src]
fn has_erased_regions(&self) -> bool[src]
fn has_erasable_regions(&self) -> bool[src]
fn is_global(&self) -> bool[src]
fn has_late_bound_regions(&self) -> bool[src]
fn still_further_specializable(&self) -> bool[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for Binder<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Binder<T> where
T: Send,
T: Send,
impl<T> Sync for Binder<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Binder<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Binder<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<'tcx, T> ArenaAllocatable<'tcx, ()> for T where
T: Copy, [src]
T: Copy,
pub fn allocate_on(Self, &'a Arena<'tcx>) -> &'a mut T[src]
pub fn allocate_from_iter(
&'a Arena<'tcx>,
impl IntoIterator<Item = T>
) -> &'a mut [T]ⓘ[src]
&'a Arena<'tcx>,
impl IntoIterator<Item = T>
) -> &'a mut [T]ⓘ
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<'a, T> Captures<'a> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> MaybeResult<T> for T[src]
type Error = !
pub fn from(Result<T, <T as MaybeResult<T>>::Error>) -> T[src]
pub fn to_result(self) -> Result<T, <T as MaybeResult<T>>::Error>[src]
impl<'tcx, T> Subst<'tcx> for T where
T: TypeFoldable<'tcx>, [src]
T: TypeFoldable<'tcx>,
pub fn subst_spanned(Self, TyCtxt<'tcx>, &[GenericArg<'tcx>], Option<Span>) -> T[src]
fn subst(self, tcx: TyCtxt<'tcx>, substs: &[GenericArg<'tcx>]) -> Self[src]
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T> ToString for T where
T: Display + ?Sized, [src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.