Less magic number for corountine
This commit is contained in:
parent
2db4ff40af
commit
4930937960
@ -68,6 +68,10 @@ impl<'tcx> ty::CoroutineArgs<TyCtxt<'tcx>> {
|
|||||||
const RETURNED: usize = 1;
|
const RETURNED: usize = 1;
|
||||||
/// Coroutine has been poisoned.
|
/// Coroutine has been poisoned.
|
||||||
const POISONED: usize = 2;
|
const POISONED: usize = 2;
|
||||||
|
/// Number of variants to reserve in coroutine state. Corresponds to
|
||||||
|
/// `UNRESUMED` (beginning of a coroutine) and `RETURNED`/`POISONED`
|
||||||
|
/// (end of a coroutine) states.
|
||||||
|
const RESERVED_VARIANTS: usize = 3;
|
||||||
|
|
||||||
const UNRESUMED_NAME: &'static str = "Unresumed";
|
const UNRESUMED_NAME: &'static str = "Unresumed";
|
||||||
const RETURNED_NAME: &'static str = "Returned";
|
const RETURNED_NAME: &'static str = "Returned";
|
||||||
@ -116,7 +120,7 @@ fn variant_name(v: VariantIdx) -> Cow<'static, str> {
|
|||||||
Self::UNRESUMED => Cow::from(Self::UNRESUMED_NAME),
|
Self::UNRESUMED => Cow::from(Self::UNRESUMED_NAME),
|
||||||
Self::RETURNED => Cow::from(Self::RETURNED_NAME),
|
Self::RETURNED => Cow::from(Self::RETURNED_NAME),
|
||||||
Self::POISONED => Cow::from(Self::POISONED_NAME),
|
Self::POISONED => Cow::from(Self::POISONED_NAME),
|
||||||
_ => Cow::from(format!("Suspend{}", v.as_usize() - 3)),
|
_ => Cow::from(format!("Suspend{}", v.as_usize() - Self::RESERVED_VARIANTS)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,11 +208,8 @@ fn replace_base<'tcx>(place: &mut Place<'tcx>, new_base: Place<'tcx>, tcx: TyCtx
|
|||||||
const RETURNED: usize = CoroutineArgs::RETURNED;
|
const RETURNED: usize = CoroutineArgs::RETURNED;
|
||||||
/// Coroutine has panicked and is poisoned.
|
/// Coroutine has panicked and is poisoned.
|
||||||
const POISONED: usize = CoroutineArgs::POISONED;
|
const POISONED: usize = CoroutineArgs::POISONED;
|
||||||
|
/// Number of reserved variants of coroutine state.
|
||||||
/// Number of variants to reserve in coroutine state. Corresponds to
|
const RESERVED_VARIANTS: usize = CoroutineArgs::RESERVED_VARIANTS;
|
||||||
/// `UNRESUMED` (beginning of a coroutine) and `RETURNED`/`POISONED`
|
|
||||||
/// (end of a coroutine) states.
|
|
||||||
const RESERVED_VARIANTS: usize = 3;
|
|
||||||
|
|
||||||
/// A `yield` point in the coroutine.
|
/// A `yield` point in the coroutine.
|
||||||
struct SuspensionPoint<'tcx> {
|
struct SuspensionPoint<'tcx> {
|
||||||
|
Loading…
Reference in New Issue
Block a user