Struct rustc_typeck::middle::ty::BinderUnstable
[-] [+]
[src]
pub struct Binder<T>(pub T);
Binder is a binder for higher-ranked lifetimes. 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 skolemize, instantiate,
erase, or otherwise "discharge" these bound regions, we change the
type from Binder<T>
to just T
(see
e.g. liberate_late_bound_regions
).
Methods
impl<'tcx> Binder<FnOutput<'tcx>>
impl<'tcx> Binder<FnSig<'tcx>>
fn inputs(&self) -> Binder<Vec<&'tcx TyS<'tcx>>>
fn input(&self, index: usize) -> Binder<&'tcx TyS<'tcx>>
fn output(&self) -> Binder<FnOutput<'tcx>>
fn variadic(&self) -> bool
impl<'tcx> Binder<Rc<TraitRef<'tcx>>>
fn self_ty(&self) -> &'tcx TyS<'tcx>
fn def_id(&self) -> DefId
fn substs(&self) -> &'tcx Substs<'tcx>
fn input_types(&self) -> &[&'tcx TyS<'tcx>]
fn to_poly_trait_predicate(&self) -> Binder<TraitPredicate<'tcx>>
impl<T> Binder<T>
fn skip_binder(&self) -> &T
Skips the binder and returns the "bound" value. This is a
risky thing to do because it's easy to get confused about
debruijn indices and the like. It is usually better to
discharge the binder using no_late_bound_regions
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 regions, 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 def-id from a PolyTraitRef;
- comparing the self type of a PolyTraitRef to see if it is equal to
a type parameter X
, since the type X
does not reference any regions