Rename CoroutineKind::Gen
to ::Coroutine
This commit is contained in:
parent
e96ce20b34
commit
2d91c76d5d
14 changed files with 29 additions and 25 deletions
|
@ -712,7 +712,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||
let full_span = expr.span.to(await_kw_span);
|
||||
match self.coroutine_kind {
|
||||
Some(hir::CoroutineKind::Async(_)) => {}
|
||||
Some(hir::CoroutineKind::Gen) | None => {
|
||||
Some(hir::CoroutineKind::Coroutine) | None => {
|
||||
self.tcx.sess.emit_err(AwaitOnlyInAsyncFnAndBlocks {
|
||||
await_kw_span,
|
||||
item_span: self.current_item,
|
||||
|
@ -930,7 +930,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||
movability: Movability,
|
||||
) -> Option<hir::Movability> {
|
||||
match coroutine_kind {
|
||||
Some(hir::CoroutineKind::Gen) => {
|
||||
Some(hir::CoroutineKind::Coroutine) => {
|
||||
if decl.inputs.len() > 1 {
|
||||
self.tcx.sess.emit_err(CoroutineTooManyParameters { fn_decl_span });
|
||||
}
|
||||
|
@ -1445,11 +1445,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||
|
||||
fn lower_expr_yield(&mut self, span: Span, opt_expr: Option<&Expr>) -> hir::ExprKind<'hir> {
|
||||
match self.coroutine_kind {
|
||||
Some(hir::CoroutineKind::Gen) => {}
|
||||
Some(hir::CoroutineKind::Coroutine) => {}
|
||||
Some(hir::CoroutineKind::Async(_)) => {
|
||||
self.tcx.sess.emit_err(AsyncCoroutinesNotSupported { span });
|
||||
}
|
||||
None => self.coroutine_kind = Some(hir::CoroutineKind::Gen),
|
||||
None => self.coroutine_kind = Some(hir::CoroutineKind::Coroutine),
|
||||
}
|
||||
|
||||
let expr =
|
||||
|
|
|
@ -2488,7 +2488,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||
AsyncCoroutineKind::Closure => "async closure",
|
||||
_ => bug!("async block/closure expected, but async function found."),
|
||||
},
|
||||
CoroutineKind::Gen => "coroutine",
|
||||
CoroutineKind::Coroutine => "coroutine",
|
||||
},
|
||||
None => "closure",
|
||||
};
|
||||
|
|
|
@ -698,7 +698,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
|
|||
" of async function"
|
||||
}
|
||||
},
|
||||
Some(hir::CoroutineKind::Gen) => " of coroutine",
|
||||
Some(hir::CoroutineKind::Coroutine) => " of coroutine",
|
||||
None => " of closure",
|
||||
};
|
||||
(span, mir_description, hir_ty)
|
||||
|
|
|
@ -563,7 +563,7 @@ fn coroutine_kind_label(coroutine_kind: Option<CoroutineKind>) -> &'static str {
|
|||
Some(CoroutineKind::Async(AsyncCoroutineKind::Block)) => "async_block",
|
||||
Some(CoroutineKind::Async(AsyncCoroutineKind::Closure)) => "async_closure",
|
||||
Some(CoroutineKind::Async(AsyncCoroutineKind::Fn)) => "async_fn",
|
||||
Some(CoroutineKind::Gen) => "coroutine",
|
||||
Some(CoroutineKind::Coroutine) => "coroutine",
|
||||
None => "closure",
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1043,7 +1043,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
|
|||
TerminatorKind::InlineAsm { .. } => self.check_op(ops::InlineAsm),
|
||||
|
||||
TerminatorKind::CoroutineDrop | TerminatorKind::Yield { .. } => {
|
||||
self.check_op(ops::Coroutine(hir::CoroutineKind::Gen))
|
||||
self.check_op(ops::Coroutine(hir::CoroutineKind::Coroutine))
|
||||
}
|
||||
|
||||
TerminatorKind::UnwindTerminate(_) => {
|
||||
|
|
|
@ -1514,14 +1514,14 @@ pub enum CoroutineKind {
|
|||
Async(AsyncCoroutineKind),
|
||||
|
||||
/// A coroutine literal created via a `yield` inside a closure.
|
||||
Gen,
|
||||
Coroutine,
|
||||
}
|
||||
|
||||
impl fmt::Display for CoroutineKind {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
CoroutineKind::Async(k) => fmt::Display::fmt(k, f),
|
||||
CoroutineKind::Gen => f.write_str("coroutine"),
|
||||
CoroutineKind::Coroutine => f.write_str("coroutine"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1530,7 +1530,7 @@ impl CoroutineKind {
|
|||
pub fn descr(&self) -> &'static str {
|
||||
match self {
|
||||
CoroutineKind::Async(ask) => ask.descr(),
|
||||
CoroutineKind::Gen => "coroutine",
|
||||
CoroutineKind::Coroutine => "coroutine",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2251,7 +2251,7 @@ impl From<CoroutineKind> for YieldSource {
|
|||
fn from(kind: CoroutineKind) -> Self {
|
||||
match kind {
|
||||
// Guess based on the kind of the current coroutine.
|
||||
CoroutineKind::Gen => Self::Yield,
|
||||
CoroutineKind::Coroutine => Self::Yield,
|
||||
CoroutineKind::Async(_) => Self::Await { expr: None },
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ pub(super) fn check_fn<'a, 'tcx>(
|
|||
if let Some(kind) = body.coroutine_kind
|
||||
&& can_be_coroutine.is_some()
|
||||
{
|
||||
let yield_ty = if kind == hir::CoroutineKind::Gen {
|
||||
let yield_ty = if kind == hir::CoroutineKind::Coroutine {
|
||||
let yield_ty = fcx.next_ty_var(TypeVariableOrigin {
|
||||
kind: TypeVariableOriginKind::TypeInference,
|
||||
span,
|
||||
|
|
|
@ -139,9 +139,9 @@ impl<O> AssertKind<O> {
|
|||
Overflow(op, _, _) => bug!("{:?} cannot overflow", op),
|
||||
DivisionByZero(_) => "attempt to divide by zero",
|
||||
RemainderByZero(_) => "attempt to calculate the remainder with a divisor of zero",
|
||||
ResumedAfterReturn(CoroutineKind::Gen) => "coroutine resumed after completion",
|
||||
ResumedAfterReturn(CoroutineKind::Coroutine) => "coroutine resumed after completion",
|
||||
ResumedAfterReturn(CoroutineKind::Async(_)) => "`async fn` resumed after completion",
|
||||
ResumedAfterPanic(CoroutineKind::Gen) => "coroutine resumed after panicking",
|
||||
ResumedAfterPanic(CoroutineKind::Coroutine) => "coroutine resumed after panicking",
|
||||
ResumedAfterPanic(CoroutineKind::Async(_)) => "`async fn` resumed after panicking",
|
||||
BoundsCheck { .. } | MisalignedPointerDereference { .. } => {
|
||||
bug!("Unexpected AssertKind")
|
||||
|
@ -229,9 +229,13 @@ impl<O> AssertKind<O> {
|
|||
DivisionByZero(_) => middle_assert_divide_by_zero,
|
||||
RemainderByZero(_) => middle_assert_remainder_by_zero,
|
||||
ResumedAfterReturn(CoroutineKind::Async(_)) => middle_assert_async_resume_after_return,
|
||||
ResumedAfterReturn(CoroutineKind::Gen) => middle_assert_coroutine_resume_after_return,
|
||||
ResumedAfterReturn(CoroutineKind::Coroutine) => {
|
||||
middle_assert_coroutine_resume_after_return
|
||||
}
|
||||
ResumedAfterPanic(CoroutineKind::Async(_)) => middle_assert_async_resume_after_panic,
|
||||
ResumedAfterPanic(CoroutineKind::Gen) => middle_assert_coroutine_resume_after_panic,
|
||||
ResumedAfterPanic(CoroutineKind::Coroutine) => {
|
||||
middle_assert_coroutine_resume_after_panic
|
||||
}
|
||||
|
||||
MisalignedPointerDereference { .. } => middle_assert_misaligned_ptr_deref,
|
||||
}
|
||||
|
|
|
@ -788,7 +788,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
|
|||
p!(write("{{"));
|
||||
let coroutine_kind = self.tcx().coroutine_kind(did).unwrap();
|
||||
let should_print_movability =
|
||||
self.should_print_verbose() || coroutine_kind == hir::CoroutineKind::Gen;
|
||||
self.should_print_verbose() || coroutine_kind == hir::CoroutineKind::Coroutine;
|
||||
|
||||
if should_print_movability {
|
||||
match movability {
|
||||
|
|
|
@ -748,7 +748,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
DefKind::AssocFn if self.associated_item(def_id).fn_has_self_parameter => "method",
|
||||
DefKind::Coroutine => match self.coroutine_kind(def_id).unwrap() {
|
||||
rustc_hir::CoroutineKind::Async(..) => "async closure",
|
||||
rustc_hir::CoroutineKind::Gen => "coroutine",
|
||||
rustc_hir::CoroutineKind::Coroutine => "coroutine",
|
||||
},
|
||||
_ => def_kind.descr(def_id),
|
||||
}
|
||||
|
@ -765,7 +765,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
DefKind::AssocFn if self.associated_item(def_id).fn_has_self_parameter => "a",
|
||||
DefKind::Coroutine => match self.coroutine_kind(def_id).unwrap() {
|
||||
rustc_hir::CoroutineKind::Async(..) => "an",
|
||||
rustc_hir::CoroutineKind::Gen => "a",
|
||||
rustc_hir::CoroutineKind::Coroutine => "a",
|
||||
},
|
||||
_ => def_kind.article(),
|
||||
}
|
||||
|
|
|
@ -873,7 +873,7 @@ impl<'tcx> Stable<'tcx> for rustc_hir::CoroutineKind {
|
|||
};
|
||||
stable_mir::mir::CoroutineKind::Async(async_gen)
|
||||
}
|
||||
CoroutineKind::Gen => stable_mir::mir::CoroutineKind::Gen,
|
||||
CoroutineKind::Coroutine => stable_mir::mir::CoroutineKind::Coroutine,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2409,7 +2409,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
let message = outer_coroutine
|
||||
.and_then(|coroutine_did| {
|
||||
Some(match self.tcx.coroutine_kind(coroutine_did).unwrap() {
|
||||
CoroutineKind::Gen => format!("coroutine is not {trait_name}"),
|
||||
CoroutineKind::Coroutine => format!("coroutine is not {trait_name}"),
|
||||
CoroutineKind::Async(AsyncCoroutineKind::Fn) => self
|
||||
.tcx
|
||||
.parent(coroutine_did)
|
||||
|
@ -2882,7 +2882,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
}
|
||||
ObligationCauseCode::SizedCoroutineInterior(coroutine_def_id) => {
|
||||
let what = match self.tcx.coroutine_kind(coroutine_def_id) {
|
||||
None | Some(hir::CoroutineKind::Gen) => "yield",
|
||||
None | Some(hir::CoroutineKind::Coroutine) => "yield",
|
||||
Some(hir::CoroutineKind::Async(..)) => "await",
|
||||
};
|
||||
err.note(format!(
|
||||
|
|
|
@ -1615,7 +1615,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
|
||||
fn describe_coroutine(&self, body_id: hir::BodyId) -> Option<&'static str> {
|
||||
self.tcx.hir().body(body_id).coroutine_kind.map(|gen_kind| match gen_kind {
|
||||
hir::CoroutineKind::Gen => "a coroutine",
|
||||
hir::CoroutineKind::Coroutine => "a coroutine",
|
||||
hir::CoroutineKind::Async(hir::AsyncCoroutineKind::Block) => "an async block",
|
||||
hir::CoroutineKind::Async(hir::AsyncCoroutineKind::Fn) => "an async function",
|
||||
hir::CoroutineKind::Async(hir::AsyncCoroutineKind::Closure) => "an async closure",
|
||||
|
|
|
@ -134,7 +134,7 @@ pub enum UnOp {
|
|||
#[derive(Clone, Debug)]
|
||||
pub enum CoroutineKind {
|
||||
Async(AsyncCoroutineKind),
|
||||
Gen,
|
||||
Coroutine,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue