Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit af8a998

Browse files
committed
Rename AsyncCoroutineKind to CoroutineSource
similar to how we have `MatchSource`, it explains where the desugaring came from.
1 parent eb03d40 commit af8a998

File tree

19 files changed

+59
-59
lines changed

19 files changed

+59
-59
lines changed

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
188188
e.id,
189189
None,
190190
e.span,
191-
hir::AsyncCoroutineKind::Block,
191+
hir::CoroutineSource::Block,
192192
|this| this.with_new_scopes(|this| this.lower_block_expr(block)),
193193
),
194194
ExprKind::Await(expr, await_kw_span) => self.lower_expr_await(*await_kw_span, expr),
@@ -598,7 +598,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
598598
closure_node_id: NodeId,
599599
ret_ty: Option<hir::FnRetTy<'hir>>,
600600
span: Span,
601-
async_gen_kind: hir::AsyncCoroutineKind,
601+
async_gen_kind: hir::CoroutineSource,
602602
body: impl FnOnce(&mut Self) -> hir::Expr<'hir>,
603603
) -> hir::ExprKind<'hir> {
604604
let output = ret_ty.unwrap_or_else(|| hir::FnRetTy::DefaultReturn(self.lower_span(span)));
@@ -1005,7 +1005,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
10051005
inner_closure_id,
10061006
async_ret_ty,
10071007
body.span,
1008-
hir::AsyncCoroutineKind::Closure,
1008+
hir::CoroutineSource::Closure,
10091009
|this| this.with_new_scopes(|this| this.lower_expr_mut(body)),
10101010
);
10111011
let hir_id = this.lower_node_id(inner_closure_id);

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
12061206
closure_id,
12071207
None,
12081208
body.span,
1209-
hir::AsyncCoroutineKind::Fn,
1209+
hir::CoroutineSource::Fn,
12101210
|this| {
12111211
// Create a block from the user's function body:
12121212
let user_body = this.lower_block_expr(body);

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_errors::{
88
use rustc_hir as hir;
99
use rustc_hir::def::{DefKind, Res};
1010
use rustc_hir::intravisit::{walk_block, walk_expr, Visitor};
11-
use rustc_hir::{AsyncCoroutineKind, CoroutineKind, LangItem};
11+
use rustc_hir::{CoroutineKind, CoroutineSource, LangItem};
1212
use rustc_infer::traits::ObligationCause;
1313
use rustc_middle::hir::nested_filter::OnlyBodies;
1414
use rustc_middle::mir::tcx::PlaceTy;
@@ -2506,8 +2506,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
25062506
let kind = match use_span.coroutine_kind() {
25072507
Some(coroutine_kind) => match coroutine_kind {
25082508
CoroutineKind::Async(async_kind) => match async_kind {
2509-
AsyncCoroutineKind::Block => "async block",
2510-
AsyncCoroutineKind::Closure => "async closure",
2509+
CoroutineSource::Block => "async block",
2510+
CoroutineSource::Closure => "async closure",
25112511
_ => bug!("async block/closure expected, but async function found."),
25122512
},
25132513
CoroutineKind::Coroutine => "coroutine",

compiler/rustc_borrowck/src/diagnostics/region_name.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -682,9 +682,9 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
682682
};
683683
let mir_description = match hir.body(body).coroutine_kind {
684684
Some(hir::CoroutineKind::Async(gen)) => match gen {
685-
hir::AsyncCoroutineKind::Block => " of async block",
686-
hir::AsyncCoroutineKind::Closure => " of async closure",
687-
hir::AsyncCoroutineKind::Fn => {
685+
hir::CoroutineSource::Block => " of async block",
686+
hir::CoroutineSource::Closure => " of async closure",
687+
hir::CoroutineSource::Fn => {
688688
let parent_item =
689689
hir.get_by_def_id(hir.get_parent_item(mir_hir_id).def_id);
690690
let output = &parent_item

compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rustc_data_structures::fx::FxHashSet;
1515
use rustc_data_structures::stable_hasher::{Hash64, HashStable, StableHasher};
1616
use rustc_hir::def_id::DefId;
1717
use rustc_hir::definitions::{DefPathData, DefPathDataName, DisambiguatedDefPathData};
18-
use rustc_hir::{AsyncCoroutineKind, CoroutineKind, Mutability};
18+
use rustc_hir::{CoroutineKind, CoroutineSource, Mutability};
1919
use rustc_middle::ty::layout::{IntegerExt, TyAndLayout};
2020
use rustc_middle::ty::{self, ExistentialProjection, ParamEnv, Ty, TyCtxt};
2121
use rustc_middle::ty::{GenericArgKind, GenericArgsRef};
@@ -560,9 +560,9 @@ pub fn push_item_name(tcx: TyCtxt<'_>, def_id: DefId, qualified: bool, output: &
560560

561561
fn coroutine_kind_label(coroutine_kind: Option<CoroutineKind>) -> &'static str {
562562
match coroutine_kind {
563-
Some(CoroutineKind::Async(AsyncCoroutineKind::Block)) => "async_block",
564-
Some(CoroutineKind::Async(AsyncCoroutineKind::Closure)) => "async_closure",
565-
Some(CoroutineKind::Async(AsyncCoroutineKind::Fn)) => "async_fn",
563+
Some(CoroutineKind::Async(CoroutineSource::Block)) => "async_block",
564+
Some(CoroutineKind::Async(CoroutineSource::Closure)) => "async_closure",
565+
Some(CoroutineKind::Async(CoroutineSource::Fn)) => "async_fn",
566566
Some(CoroutineKind::Coroutine) => "coroutine",
567567
None => "closure",
568568
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallUnstable {
360360
pub struct Coroutine(pub hir::CoroutineKind);
361361
impl<'tcx> NonConstOp<'tcx> for Coroutine {
362362
fn status_in_item(&self, _: &ConstCx<'_, 'tcx>) -> Status {
363-
if let hir::CoroutineKind::Async(hir::AsyncCoroutineKind::Block) = self.0 {
363+
if let hir::CoroutineKind::Async(hir::CoroutineSource::Block) = self.0 {
364364
Status::Unstable(sym::const_async_blocks)
365365
} else {
366366
Status::Forbidden
@@ -373,7 +373,7 @@ impl<'tcx> NonConstOp<'tcx> for Coroutine {
373373
span: Span,
374374
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
375375
let msg = format!("{}s are not allowed in {}s", self.0.descr(), ccx.const_kind());
376-
if let hir::CoroutineKind::Async(hir::AsyncCoroutineKind::Block) = self.0 {
376+
if let hir::CoroutineKind::Async(hir::CoroutineSource::Block) = self.0 {
377377
ccx.tcx.sess.create_feature_err(
378378
errors::UnallowedOpInConstContext { span, msg },
379379
sym::const_async_blocks,

compiler/rustc_hir/src/hir.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,7 +1511,7 @@ impl<'hir> Body<'hir> {
15111511
#[derive(HashStable_Generic, Encodable, Decodable)]
15121512
pub enum CoroutineKind {
15131513
/// An explicit `async` block or the body of an async function.
1514-
Async(AsyncCoroutineKind),
1514+
Async(CoroutineSource),
15151515

15161516
/// A coroutine literal created via a `yield` inside a closure.
15171517
Coroutine,
@@ -1535,40 +1535,40 @@ impl CoroutineKind {
15351535
}
15361536
}
15371537

1538-
/// In the case of a coroutine created as part of an async construct,
1539-
/// which kind of async construct caused it to be created?
1538+
/// In the case of a coroutine created as part of an async/gen construct,
1539+
/// which kind of async/gen construct caused it to be created?
15401540
///
15411541
/// This helps error messages but is also used to drive coercions in
15421542
/// type-checking (see #60424).
15431543
#[derive(Clone, PartialEq, Eq, Hash, Debug, Copy)]
15441544
#[derive(HashStable_Generic, Encodable, Decodable)]
1545-
pub enum AsyncCoroutineKind {
1546-
/// An explicit `async` block written by the user.
1545+
pub enum CoroutineSource {
1546+
/// An explicit `async`/`gen` block written by the user.
15471547
Block,
15481548

1549-
/// An explicit `async` closure written by the user.
1549+
/// An explicit `async`/`gen` closure written by the user.
15501550
Closure,
15511551

1552-
/// The `async` block generated as the body of an async function.
1552+
/// The `async`/`gen` block generated as the body of an async/gen function.
15531553
Fn,
15541554
}
15551555

1556-
impl fmt::Display for AsyncCoroutineKind {
1556+
impl fmt::Display for CoroutineSource {
15571557
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
15581558
f.write_str(match self {
1559-
AsyncCoroutineKind::Block => "async block",
1560-
AsyncCoroutineKind::Closure => "async closure body",
1561-
AsyncCoroutineKind::Fn => "async fn body",
1559+
CoroutineSource::Block => "async block",
1560+
CoroutineSource::Closure => "async closure body",
1561+
CoroutineSource::Fn => "async fn body",
15621562
})
15631563
}
15641564
}
15651565

1566-
impl AsyncCoroutineKind {
1566+
impl CoroutineSource {
15671567
pub fn descr(&self) -> &'static str {
15681568
match self {
1569-
AsyncCoroutineKind::Block => "`async` block",
1570-
AsyncCoroutineKind::Closure => "`async` closure body",
1571-
AsyncCoroutineKind::Fn => "`async fn` body",
1569+
CoroutineSource::Block => "`async` block",
1570+
CoroutineSource::Closure => "`async` closure body",
1571+
CoroutineSource::Fn => "`async fn` body",
15721572
}
15731573
}
15741574
}

compiler/rustc_hir_typeck/src/callee.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
305305
) = (parent_node, callee_node)
306306
{
307307
let fn_decl_span = if hir.body(body).coroutine_kind
308-
== Some(hir::CoroutineKind::Async(hir::AsyncCoroutineKind::Closure))
308+
== Some(hir::CoroutineKind::Async(hir::CoroutineSource::Closure))
309309
{
310310
// Actually need to unwrap one more layer of HIR to get to
311311
// the _real_ closure...

compiler/rustc_hir_typeck/src/closure.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
636636
// In the case of the async block that we create for a function body,
637637
// we expect the return type of the block to match that of the enclosing
638638
// function.
639-
Some(hir::CoroutineKind::Async(hir::AsyncCoroutineKind::Fn)) => {
639+
Some(hir::CoroutineKind::Async(hir::CoroutineSource::Fn)) => {
640640
debug!("closure is async fn body");
641641
let def_id = self.tcx.hir().body_owner_def_id(body.id());
642642
self.deduce_future_output_from_obligations(expr_def_id, def_id).unwrap_or_else(

compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ use rustc_hir::def::Res;
1010
use rustc_hir::def::{CtorKind, CtorOf, DefKind};
1111
use rustc_hir::lang_items::LangItem;
1212
use rustc_hir::{
13-
AsyncCoroutineKind, CoroutineKind, Expr, ExprKind, GenericBound, HirId, Node, Path, QPath,
14-
Stmt, StmtKind, TyKind, WherePredicate,
13+
CoroutineKind, CoroutineSource, Expr, ExprKind, GenericBound, HirId, Node, Path, QPath, Stmt,
14+
StmtKind, TyKind, WherePredicate,
1515
};
1616
use rustc_hir_analysis::astconv::AstConv;
1717
use rustc_infer::traits::{self, StatementAsExpression};
@@ -536,7 +536,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
536536
ty::Coroutine(def_id, ..)
537537
if matches!(
538538
self.tcx.coroutine_kind(def_id),
539-
Some(CoroutineKind::Async(AsyncCoroutineKind::Closure))
539+
Some(CoroutineKind::Async(CoroutineSource::Closure))
540540
) =>
541541
{
542542
errors::SuggestBoxing::AsyncBody

0 commit comments

Comments
 (0)