rustc_middle::ty::sty

Trait CoroutineArgsExt

source
pub trait CoroutineArgsExt<'tcx> {
    const UNRESUMED: usize;
    const RETURNED: usize;
    const POISONED: usize;
    const RESERVED_VARIANTS: usize;
    const UNRESUMED_NAME: &'static str;
    const RETURNED_NAME: &'static str;
    const POISONED_NAME: &'static str;

    // Required methods
    fn variant_range(
        &self,
        def_id: DefId,
        tcx: TyCtxt<'tcx>,
    ) -> Range<VariantIdx>;
    fn discriminant_for_variant(
        &self,
        def_id: DefId,
        tcx: TyCtxt<'tcx>,
        variant_index: VariantIdx,
    ) -> Discr<'tcx>;
    fn discriminants(
        self,
        def_id: DefId,
        tcx: TyCtxt<'tcx>,
    ) -> impl Iterator<Item = (VariantIdx, Discr<'tcx>)> + Captures<'tcx>;
    fn variant_name(v: VariantIdx) -> Cow<'static, str>;
    fn discr_ty(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx>;
    fn state_tys(
        self,
        def_id: DefId,
        tcx: TyCtxt<'tcx>,
    ) -> impl Iterator<Item: Iterator<Item = Ty<'tcx>> + Captures<'tcx>>;
    fn prefix_tys(self) -> &'tcx List<Ty<'tcx>>;
}

Required Associated Constants§

source

const UNRESUMED: usize

Coroutine has not been resumed yet.

source

const RETURNED: usize

Coroutine has returned or is completed.

source

const POISONED: usize

Coroutine has been poisoned.

source

const RESERVED_VARIANTS: usize

Number of variants to reserve in coroutine state. Corresponds to UNRESUMED (beginning of a coroutine) and RETURNED/POISONED (end of a coroutine) states.

source

const UNRESUMED_NAME: &'static str

source

const RETURNED_NAME: &'static str

source

const POISONED_NAME: &'static str

Required Methods§

source

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

The valid variant indices of this coroutine.

source

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

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

source

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

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

source

fn variant_name(v: VariantIdx) -> Cow<'static, str>

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

source

fn discr_ty(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx>

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

source

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

This returns the types of the MIR locals which had to be stored across suspension points. It is calculated in rustc_mir_transform::coroutine::StateTransform. All the types here must be in the tuple in CoroutineInterior.

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

source

fn prefix_tys(self) -> &'tcx List<Ty<'tcx>>

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

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<'tcx> CoroutineArgsExt<'tcx> for CoroutineArgs<TyCtxt<'tcx>>

source§

const UNRESUMED: usize = 0usize

source§

const RETURNED: usize = 1usize

source§

const POISONED: usize = 2usize

source§

const RESERVED_VARIANTS: usize = 3usize

source§

const UNRESUMED_NAME: &'static str = "Unresumed"

source§

const RETURNED_NAME: &'static str = "Returned"

source§

const POISONED_NAME: &'static str = "Panicked"