rustc_middle::ty

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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so 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"