Struct rustc_middle::ty::sty::GeneratorSubsts[][src]

pub struct GeneratorSubsts<'tcx> {
    pub substs: SubstsRef<'tcx>,
}

Similar to ClosureSubsts; see the above documentation for more.

Fields

substs: SubstsRef<'tcx>

Implementations

impl<'tcx> GeneratorSubsts<'tcx>[src]

pub fn new(
    tcx: TyCtxt<'tcx>,
    parts: GeneratorSubstsParts<'tcx, Ty<'tcx>>
) -> GeneratorSubsts<'tcx>
[src]

Construct GeneratorSubsts from GeneratorSubstsParts, containing Substs for the generator parent, alongside additional generator-specific components.

fn split(self) -> GeneratorSubstsParts<'tcx, GenericArg<'tcx>>[src]

Divides the generator substs into their respective components. The ordering assumed here must match that used by GeneratorSubsts::new above.

pub fn is_valid(self) -> bool[src]

Returns true only if enough of the synthetic types are known to allow using all of the methods on GeneratorSubsts without panicking.

Used primarily by ty::print::pretty to be able to handle generator types that haven’t had their synthetic types substituted in.

pub fn parent_substs(self) -> &'tcx [GenericArg<'tcx>]

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
[src]

Returns the substitutions of the generator’s parent.

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

This describes the types that can be contained in a generator. It will be a type variable initially and unified in the last stages of typeck of a body. It contains a tuple of all the types that could end up on a generator frame. The state transformation MIR pass may only produce layouts which mention types in this tuple. Upvars are not counted here.

pub fn upvar_tys(self) -> impl Iterator<Item = Ty<'tcx>> + 'tcx[src]

Returns an iterator over the list of types of captured paths by the generator. In case there was a type error in figuring out the types of the captured path, an empty iterator is returned.

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

Returns the tuple type representing the upvars for this generator.

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

Returns the type representing the resume type of the generator.

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

Returns the type representing the yield type of the generator.

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

Returns the type representing the return type of the generator.

pub fn poly_sig(self) -> PolyGenSig<'tcx>[src]

Returns the “generator signature”, which consists of its yield and return types.

N.B., some bits of the code prefers to see this wrapped in a binder, but it never contains bound regions. Probably this function should be removed.

pub fn sig(self) -> GenSig<'tcx>[src]

Returns the “generator signature”, which consists of its resume, yield and return types.

impl<'tcx> GeneratorSubsts<'tcx>[src]

pub const UNRESUMED: usize[src]

Generator has not been resumed yet.

pub const RETURNED: usize[src]

Generator has returned or is completed.

pub const POISONED: usize[src]

Generator has been poisoned.

const UNRESUMED_NAME: &'static str[src]

const RETURNED_NAME: &'static str[src]

const POISONED_NAME: &'static str[src]

pub fn variant_range(
    &self,
    def_id: DefId,
    tcx: TyCtxt<'tcx>
) -> Range<VariantIdx>
[src]

The valid variant indices of this generator.

pub fn discriminant_for_variant(
    &self,
    def_id: DefId,
    tcx: TyCtxt<'tcx>,
    variant_index: VariantIdx
) -> Discr<'tcx>
[src]

The discriminant for the given variant. Panics if the variant_index is out of range.

pub fn discriminants(
    self,
    def_id: DefId,
    tcx: TyCtxt<'tcx>
) -> impl Iterator<Item = (VariantIdx, Discr<'tcx>)> + Captures<'tcx>
[src]

The set of all discriminants for the generator, enumerated with their variant indices.

pub fn variant_name(v: VariantIdx) -> Cow<'static, str>[src]

Calls f with a reference to the name of the enumerator for the given variant v.

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

The type of the state discriminant used in the generator type.

pub fn state_tys(
    self,
    def_id: DefId,
    tcx: TyCtxt<'tcx>
) -> impl Iterator<Item = impl Iterator<Item = Ty<'tcx>> + Captures<'tcx>>
[src]

This returns the types of the MIR locals which had to be stored across suspension points. It is calculated in rustc_mir::transform::generator::StateTransform. All the types here must be in the tuple in GeneratorInterior.

The locals are grouped by their variant number. Note that some locals may be repeated in multiple variants.

pub fn prefix_tys(self) -> impl Iterator<Item = Ty<'tcx>>[src]

This is the types of the fields of a generator which are not stored in a variant.

Trait Implementations

impl<'tcx> Clone for GeneratorSubsts<'tcx>[src]

impl<'tcx> Copy for GeneratorSubsts<'tcx>[src]

impl<'tcx> Debug for GeneratorSubsts<'tcx>[src]

impl<'a, 'tcx> Lift<'tcx> for GeneratorSubsts<'a>[src]

type Lifted = GeneratorSubsts<'tcx>

impl<'tcx> Relate<'tcx> for GeneratorSubsts<'tcx>[src]

impl<'tcx> TypeFoldable<'tcx> for GeneratorSubsts<'tcx>[src]

Auto Trait Implementations

impl<'tcx> !RefUnwindSafe for GeneratorSubsts<'tcx>

impl<'tcx> !Send for GeneratorSubsts<'tcx>

impl<'tcx> !Sync for GeneratorSubsts<'tcx>

impl<'tcx> Unpin for GeneratorSubsts<'tcx>

impl<'tcx> !UnwindSafe for GeneratorSubsts<'tcx>

Blanket Implementations

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

impl<'tcx, T> ArenaAllocatable<'tcx, ()> 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> 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 = !

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, 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]