[][src]Struct rustc::ty::Binder

pub struct Binder<T>(T);
⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

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).

Methods

impl<'tcx> Binder<TraitRef<'tcx>>[src]

pub fn print_only_trait_path(self) -> Binder<TraitRefPrintOnlyTraitPath<'tcx>>[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

impl<'tcx> Binder<ExistentialPredicate<'tcx>>[src]

pub fn with_self_ty(
    &self,
    tcx: TyCtxt<'tcx>,
    self_ty: Ty<'tcx>
) -> Predicate<'tcx>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

impl<'tcx> Binder<&'tcx List<ExistentialPredicate<'tcx>>>[src]

pub fn principal(&self) -> Option<Binder<ExistentialTraitRef<'tcx>>>[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

pub fn principal_def_id(&self) -> Option<DefId>[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

pub fn projection_bounds<'a>(
    &'a self
) -> impl Iterator<Item = PolyExistentialProjection<'tcx>> + 'a
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

pub fn auto_traits<'a>(&'a self) -> impl Iterator<Item = DefId> + 'a[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

pub fn iter<'a>(
    &'a self
) -> impl DoubleEndedIterator<Item = Binder<ExistentialPredicate<'tcx>>> + 'tcx
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

impl<'tcx> Binder<TraitRef<'tcx>>[src]

pub fn self_ty(&self) -> Ty<'tcx>[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

pub fn def_id(&self) -> DefId[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

pub fn to_poly_trait_predicate(&self) -> PolyTraitPredicate<'tcx>[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

impl<'tcx> Binder<ExistentialTraitRef<'tcx>>[src]

pub fn def_id(&self) -> DefId[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

pub fn with_self_ty(
    &self,
    tcx: TyCtxt<'tcx>,
    self_ty: Ty<'tcx>
) -> PolyTraitRef<'tcx>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

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]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

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]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Wraps value in a binder, binding higher-ranked vars (if any).

pub fn skip_binder(&self) -> &T[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

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 DefId 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

pub fn as_ref(&self) -> Binder<&T>[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

pub fn map_bound_ref<F, U>(&self, f: F) -> Binder<U> where
    F: FnOnce(&T) -> U, 
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

pub fn map_bound<F, U>(self, f: F) -> Binder<U> where
    F: FnOnce(T) -> U, 
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

pub fn no_bound_vars<'tcx>(self) -> Option<T> where
    T: TypeFoldable<'tcx>, 
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

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]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

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]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

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<'tcx> Binder<GenSig<'tcx>>[src]

pub fn yield_ty(&self) -> Binder<Ty<'tcx>>[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

pub fn return_ty(&self) -> Binder<Ty<'tcx>>[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

impl<'tcx> Binder<FnSig<'tcx>>[src]

pub fn inputs(&self) -> Binder<&'tcx [Ty<'tcx>]>[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

pub fn input(&self, index: usize) -> Binder<Ty<'tcx>>[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

pub fn inputs_and_output(&self) -> Binder<&'tcx List<Ty<'tcx>>>[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

pub fn output(&self) -> Binder<Ty<'tcx>>[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

pub fn c_variadic(&self) -> bool[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

pub fn unsafety(&self) -> Unsafety[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

pub fn abi(&self) -> Abi[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

impl<'tcx> Binder<ExistentialProjection<'tcx>>[src]

pub fn with_self_ty(
    &self,
    tcx: TyCtxt<'tcx>,
    self_ty: Ty<'tcx>
) -> PolyProjectionPredicate<'tcx>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

pub fn item_def_id(&self) -> DefId[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

impl<'tcx> Binder<TraitPredicate<'tcx>>[src]

pub fn def_id(&self) -> DefId[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

impl<'tcx> Binder<ProjectionPredicate<'tcx>>[src]

pub fn item_def_id(&self) -> DefId[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Returns the DefId of the associated item being projected.

pub fn to_poly_trait_ref(&self, tcx: TyCtxt<'tcx>) -> PolyTraitRef<'tcx>[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

pub fn ty(&self) -> Binder<Ty<'tcx>>[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

pub fn projection_def_id(&self) -> DefId[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

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<T: Clone> Clone for Binder<T>[src]

impl<T: Copy> Copy for Binder<T>[src]

impl<T: Debug> Debug for Binder<T>[src]

impl<T: Decodable> Decodable for Binder<T>[src]

impl<'tcx> Display for Binder<&'tcx List<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<T: Encodable> Encodable for Binder<T>[src]

impl<T: Eq> Eq for Binder<T>[src]

impl<T: Hash> Hash for Binder<T>[src]

impl<'a, T> HashStable<StableHashingContext<'a>> for Binder<T> where
    T: HashStable<StableHashingContext<'a>>, 
[src]

impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for Binder<T>[src]

type Lifted = Binder<T::Lifted>

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

impl<T: Ord> Ord for Binder<T>[src]

impl<T: PartialEq> PartialEq<Binder<T>> for Binder<T>[src]

impl<T: PartialOrd> PartialOrd<Binder<T>> for Binder<T>[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]

type Output = P

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

type Error = P::Error

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

impl<'tcx, T: Relate<'tcx>> Relate<'tcx> for Binder<T>[src]

impl<T> StructuralEq for Binder<T>[src]

impl<T> StructuralPartialEq for Binder<T>[src]

impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Binder<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Binder<T> where
    T: RefUnwindSafe

impl<T> Send for Binder<T> where
    T: Send

impl<T> Sync for Binder<T> where
    T: Sync

impl<T> Unpin for Binder<T> where
    T: Unpin

impl<T> UnwindSafe for Binder<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> ArenaAllocatable for T where
    T: Copy
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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

impl<T> Decodable for T where
    T: UseSpecializedDecodable
[src]

impl<T> Encodable for T where
    T: UseSpecializedEncodable + ?Sized
[src]

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

impl<T> Erased for T[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> MaybeResult<T> for T[src]

type Error = !

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

impl<E> SpecializationError for E[src]

impl<'tcx, T> Subst<'tcx> for T where
    T: TypeFoldable<'tcx>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> WithConstness for T[src]