Skip to content

Commit 507595c

Browse files
committed
Rename CoroutineKind::Gen to ::Coroutine
1 parent 63f104d commit 507595c

File tree

14 files changed

+29
-25
lines changed

14 files changed

+29
-25
lines changed

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
712712
let full_span = expr.span.to(await_kw_span);
713713
match self.coroutine_kind {
714714
Some(hir::CoroutineKind::Async(_)) => {}
715-
Some(hir::CoroutineKind::Gen) | None => {
715+
Some(hir::CoroutineKind::Coroutine) | None => {
716716
self.tcx.sess.emit_err(AwaitOnlyInAsyncFnAndBlocks {
717717
await_kw_span,
718718
item_span: self.current_item,
@@ -930,7 +930,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
930930
movability: Movability,
931931
) -> Option<hir::Movability> {
932932
match coroutine_kind {
933-
Some(hir::CoroutineKind::Gen) => {
933+
Some(hir::CoroutineKind::Coroutine) => {
934934
if decl.inputs.len() > 1 {
935935
self.tcx.sess.emit_err(CoroutineTooManyParameters { fn_decl_span });
936936
}
@@ -1445,11 +1445,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
14451445

14461446
fn lower_expr_yield(&mut self, span: Span, opt_expr: Option<&Expr>) -> hir::ExprKind<'hir> {
14471447
match self.coroutine_kind {
1448-
Some(hir::CoroutineKind::Gen) => {}
1448+
Some(hir::CoroutineKind::Coroutine) => {}
14491449
Some(hir::CoroutineKind::Async(_)) => {
14501450
self.tcx.sess.emit_err(AsyncCoroutinesNotSupported { span });
14511451
}
1452-
None => self.coroutine_kind = Some(hir::CoroutineKind::Gen),
1452+
None => self.coroutine_kind = Some(hir::CoroutineKind::Coroutine),
14531453
}
14541454

14551455
let expr =

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2488,7 +2488,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
24882488
AsyncCoroutineKind::Closure => "async closure",
24892489
_ => bug!("async block/closure expected, but async function found."),
24902490
},
2491-
CoroutineKind::Gen => "coroutine",
2491+
CoroutineKind::Coroutine => "coroutine",
24922492
},
24932493
None => "closure",
24942494
};

compiler/rustc_borrowck/src/diagnostics/region_name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
698698
" of async function"
699699
}
700700
},
701-
Some(hir::CoroutineKind::Gen) => " of coroutine",
701+
Some(hir::CoroutineKind::Coroutine) => " of coroutine",
702702
None => " of closure",
703703
};
704704
(span, mir_description, hir_ty)

compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ fn coroutine_kind_label(coroutine_kind: Option<CoroutineKind>) -> &'static str {
563563
Some(CoroutineKind::Async(AsyncCoroutineKind::Block)) => "async_block",
564564
Some(CoroutineKind::Async(AsyncCoroutineKind::Closure)) => "async_closure",
565565
Some(CoroutineKind::Async(AsyncCoroutineKind::Fn)) => "async_fn",
566-
Some(CoroutineKind::Gen) => "coroutine",
566+
Some(CoroutineKind::Coroutine) => "coroutine",
567567
None => "closure",
568568
}
569569
}

compiler/rustc_const_eval/src/transform/check_consts/check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
10431043
TerminatorKind::InlineAsm { .. } => self.check_op(ops::InlineAsm),
10441044

10451045
TerminatorKind::CoroutineDrop | TerminatorKind::Yield { .. } => {
1046-
self.check_op(ops::Coroutine(hir::CoroutineKind::Gen))
1046+
self.check_op(ops::Coroutine(hir::CoroutineKind::Coroutine))
10471047
}
10481048

10491049
TerminatorKind::UnwindTerminate(_) => {

compiler/rustc_hir/src/hir.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,14 +1514,14 @@ pub enum CoroutineKind {
15141514
Async(AsyncCoroutineKind),
15151515

15161516
/// A coroutine literal created via a `yield` inside a closure.
1517-
Gen,
1517+
Coroutine,
15181518
}
15191519

15201520
impl fmt::Display for CoroutineKind {
15211521
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
15221522
match self {
15231523
CoroutineKind::Async(k) => fmt::Display::fmt(k, f),
1524-
CoroutineKind::Gen => f.write_str("coroutine"),
1524+
CoroutineKind::Coroutine => f.write_str("coroutine"),
15251525
}
15261526
}
15271527
}
@@ -1530,7 +1530,7 @@ impl CoroutineKind {
15301530
pub fn descr(&self) -> &'static str {
15311531
match self {
15321532
CoroutineKind::Async(ask) => ask.descr(),
1533-
CoroutineKind::Gen => "coroutine",
1533+
CoroutineKind::Coroutine => "coroutine",
15341534
}
15351535
}
15361536
}
@@ -2251,7 +2251,7 @@ impl From<CoroutineKind> for YieldSource {
22512251
fn from(kind: CoroutineKind) -> Self {
22522252
match kind {
22532253
// Guess based on the kind of the current coroutine.
2254-
CoroutineKind::Gen => Self::Yield,
2254+
CoroutineKind::Coroutine => Self::Yield,
22552255
CoroutineKind::Async(_) => Self::Await { expr: None },
22562256
}
22572257
}

compiler/rustc_hir_typeck/src/check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub(super) fn check_fn<'a, 'tcx>(
5858
if let Some(kind) = body.coroutine_kind
5959
&& can_be_coroutine.is_some()
6060
{
61-
let yield_ty = if kind == hir::CoroutineKind::Gen {
61+
let yield_ty = if kind == hir::CoroutineKind::Coroutine {
6262
let yield_ty = fcx.next_ty_var(TypeVariableOrigin {
6363
kind: TypeVariableOriginKind::TypeInference,
6464
span,

compiler/rustc_middle/src/mir/terminator.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ impl<O> AssertKind<O> {
139139
Overflow(op, _, _) => bug!("{:?} cannot overflow", op),
140140
DivisionByZero(_) => "attempt to divide by zero",
141141
RemainderByZero(_) => "attempt to calculate the remainder with a divisor of zero",
142-
ResumedAfterReturn(CoroutineKind::Gen) => "coroutine resumed after completion",
142+
ResumedAfterReturn(CoroutineKind::Coroutine) => "coroutine resumed after completion",
143143
ResumedAfterReturn(CoroutineKind::Async(_)) => "`async fn` resumed after completion",
144-
ResumedAfterPanic(CoroutineKind::Gen) => "coroutine resumed after panicking",
144+
ResumedAfterPanic(CoroutineKind::Coroutine) => "coroutine resumed after panicking",
145145
ResumedAfterPanic(CoroutineKind::Async(_)) => "`async fn` resumed after panicking",
146146
BoundsCheck { .. } | MisalignedPointerDereference { .. } => {
147147
bug!("Unexpected AssertKind")
@@ -229,9 +229,13 @@ impl<O> AssertKind<O> {
229229
DivisionByZero(_) => middle_assert_divide_by_zero,
230230
RemainderByZero(_) => middle_assert_remainder_by_zero,
231231
ResumedAfterReturn(CoroutineKind::Async(_)) => middle_assert_async_resume_after_return,
232-
ResumedAfterReturn(CoroutineKind::Gen) => middle_assert_coroutine_resume_after_return,
232+
ResumedAfterReturn(CoroutineKind::Coroutine) => {
233+
middle_assert_coroutine_resume_after_return
234+
}
233235
ResumedAfterPanic(CoroutineKind::Async(_)) => middle_assert_async_resume_after_panic,
234-
ResumedAfterPanic(CoroutineKind::Gen) => middle_assert_coroutine_resume_after_panic,
236+
ResumedAfterPanic(CoroutineKind::Coroutine) => {
237+
middle_assert_coroutine_resume_after_panic
238+
}
235239

236240
MisalignedPointerDereference { .. } => middle_assert_misaligned_ptr_deref,
237241
}

compiler/rustc_middle/src/ty/print/pretty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
788788
p!(write("{{"));
789789
let coroutine_kind = self.tcx().coroutine_kind(did).unwrap();
790790
let should_print_movability =
791-
self.should_print_verbose() || coroutine_kind == hir::CoroutineKind::Gen;
791+
self.should_print_verbose() || coroutine_kind == hir::CoroutineKind::Coroutine;
792792

793793
if should_print_movability {
794794
match movability {

compiler/rustc_middle/src/ty/util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ impl<'tcx> TyCtxt<'tcx> {
748748
DefKind::AssocFn if self.associated_item(def_id).fn_has_self_parameter => "method",
749749
DefKind::Coroutine => match self.coroutine_kind(def_id).unwrap() {
750750
rustc_hir::CoroutineKind::Async(..) => "async closure",
751-
rustc_hir::CoroutineKind::Gen => "coroutine",
751+
rustc_hir::CoroutineKind::Coroutine => "coroutine",
752752
},
753753
_ => def_kind.descr(def_id),
754754
}
@@ -765,7 +765,7 @@ impl<'tcx> TyCtxt<'tcx> {
765765
DefKind::AssocFn if self.associated_item(def_id).fn_has_self_parameter => "a",
766766
DefKind::Coroutine => match self.coroutine_kind(def_id).unwrap() {
767767
rustc_hir::CoroutineKind::Async(..) => "an",
768-
rustc_hir::CoroutineKind::Gen => "a",
768+
rustc_hir::CoroutineKind::Coroutine => "a",
769769
},
770770
_ => def_kind.article(),
771771
}

compiler/rustc_smir/src/rustc_smir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@ impl<'tcx> Stable<'tcx> for rustc_hir::CoroutineKind {
873873
};
874874
stable_mir::mir::CoroutineKind::Async(async_gen)
875875
}
876-
CoroutineKind::Gen => stable_mir::mir::CoroutineKind::Gen,
876+
CoroutineKind::Coroutine => stable_mir::mir::CoroutineKind::Coroutine,
877877
}
878878
}
879879
}

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2409,7 +2409,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
24092409
let message = outer_coroutine
24102410
.and_then(|coroutine_did| {
24112411
Some(match self.tcx.coroutine_kind(coroutine_did).unwrap() {
2412-
CoroutineKind::Gen => format!("coroutine is not {trait_name}"),
2412+
CoroutineKind::Coroutine => format!("coroutine is not {trait_name}"),
24132413
CoroutineKind::Async(AsyncCoroutineKind::Fn) => self
24142414
.tcx
24152415
.parent(coroutine_did)
@@ -2882,7 +2882,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
28822882
}
28832883
ObligationCauseCode::SizedCoroutineInterior(coroutine_def_id) => {
28842884
let what = match self.tcx.coroutine_kind(coroutine_def_id) {
2885-
None | Some(hir::CoroutineKind::Gen) => "yield",
2885+
None | Some(hir::CoroutineKind::Coroutine) => "yield",
28862886
Some(hir::CoroutineKind::Async(..)) => "await",
28872887
};
28882888
err.note(format!(

compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1615,7 +1615,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
16151615

16161616
fn describe_coroutine(&self, body_id: hir::BodyId) -> Option<&'static str> {
16171617
self.tcx.hir().body(body_id).coroutine_kind.map(|gen_kind| match gen_kind {
1618-
hir::CoroutineKind::Gen => "a coroutine",
1618+
hir::CoroutineKind::Coroutine => "a coroutine",
16191619
hir::CoroutineKind::Async(hir::AsyncCoroutineKind::Block) => "an async block",
16201620
hir::CoroutineKind::Async(hir::AsyncCoroutineKind::Fn) => "an async function",
16211621
hir::CoroutineKind::Async(hir::AsyncCoroutineKind::Closure) => "an async closure",

compiler/stable_mir/src/mir/body.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ pub enum UnOp {
134134
#[derive(Clone, Debug)]
135135
pub enum CoroutineKind {
136136
Async(AsyncCoroutineKind),
137-
Gen,
137+
Coroutine,
138138
}
139139

140140
#[derive(Clone, Debug)]

0 commit comments

Comments
 (0)