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§
sourceconst RESERVED_VARIANTS: usize
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.
const UNRESUMED_NAME: &'static str
const RETURNED_NAME: &'static str
const POISONED_NAME: &'static str
Required Methods§
sourcefn variant_range(&self, def_id: DefId, tcx: TyCtxt<'tcx>) -> Range<VariantIdx>
fn variant_range(&self, def_id: DefId, tcx: TyCtxt<'tcx>) -> Range<VariantIdx>
The valid variant indices of this coroutine.
sourcefn discriminant_for_variant(
&self,
def_id: DefId,
tcx: TyCtxt<'tcx>,
variant_index: VariantIdx,
) -> Discr<'tcx>
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.
sourcefn discriminants(
self,
def_id: DefId,
tcx: TyCtxt<'tcx>,
) -> impl Iterator<Item = (VariantIdx, Discr<'tcx>)> + Captures<'tcx>
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.
sourcefn variant_name(v: VariantIdx) -> Cow<'static, str>
fn variant_name(v: VariantIdx) -> Cow<'static, str>
Calls f
with a reference to the name of the enumerator for the given
variant v
.
sourcefn discr_ty(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx>
fn discr_ty(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx>
The type of the state discriminant used in the coroutine type.
sourcefn state_tys(
self,
def_id: DefId,
tcx: TyCtxt<'tcx>,
) -> impl Iterator<Item: Iterator<Item = Ty<'tcx>> + Captures<'tcx>>
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.
sourcefn prefix_tys(self) -> &'tcx List<Ty<'tcx>>
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.