Skip to content

Commit 8d98feb

Browse files
coro_kind -> coroutine_kind
1 parent f202125 commit 8d98feb

File tree

23 files changed

+90
-75
lines changed

23 files changed

+90
-75
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,7 +1311,7 @@ pub struct Closure {
13111311
pub binder: ClosureBinder,
13121312
pub capture_clause: CaptureBy,
13131313
pub constness: Const,
1314-
pub coro_kind: Option<CoroutineKind>,
1314+
pub coroutine_kind: Option<CoroutineKind>,
13151315
pub movability: Movability,
13161316
pub fn_decl: P<FnDecl>,
13171317
pub body: P<Expr>,
@@ -2840,7 +2840,7 @@ pub struct FnHeader {
28402840
/// The `unsafe` keyword, if any
28412841
pub unsafety: Unsafe,
28422842
/// Whether this is `async`, `gen`, or nothing.
2843-
pub coro_kind: Option<CoroutineKind>,
2843+
pub coroutine_kind: Option<CoroutineKind>,
28442844
/// The `const` keyword, if any
28452845
pub constness: Const,
28462846
/// The `extern` keyword and corresponding ABI string, if any
@@ -2850,17 +2850,22 @@ pub struct FnHeader {
28502850
impl FnHeader {
28512851
/// Does this function header have any qualifiers or is it empty?
28522852
pub fn has_qualifiers(&self) -> bool {
2853-
let Self { unsafety, coro_kind, constness, ext } = self;
2853+
let Self { unsafety, coroutine_kind, constness, ext } = self;
28542854
matches!(unsafety, Unsafe::Yes(_))
2855-
|| coro_kind.is_some()
2855+
|| coroutine_kind.is_some()
28562856
|| matches!(constness, Const::Yes(_))
28572857
|| !matches!(ext, Extern::None)
28582858
}
28592859
}
28602860

28612861
impl Default for FnHeader {
28622862
fn default() -> FnHeader {
2863-
FnHeader { unsafety: Unsafe::No, coro_kind: None, constness: Const::No, ext: Extern::None }
2863+
FnHeader {
2864+
unsafety: Unsafe::No,
2865+
coroutine_kind: None,
2866+
constness: Const::No,
2867+
ext: Extern::None,
2868+
}
28642869
}
28652870
}
28662871

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ pub trait MutVisitor: Sized {
121121
noop_visit_fn_decl(d, self);
122122
}
123123

124-
fn visit_coro_kind(&mut self, a: &mut CoroutineKind) {
125-
noop_visit_coro_kind(a, self);
124+
fn visit_coroutine_kind(&mut self, a: &mut CoroutineKind) {
125+
noop_visit_coroutine_kind(a, self);
126126
}
127127

128128
fn visit_closure_binder(&mut self, b: &mut ClosureBinder) {
@@ -871,8 +871,8 @@ pub fn noop_visit_closure_binder<T: MutVisitor>(binder: &mut ClosureBinder, vis:
871871
}
872872
}
873873

874-
pub fn noop_visit_coro_kind<T: MutVisitor>(coro_kind: &mut CoroutineKind, vis: &mut T) {
875-
match coro_kind {
874+
pub fn noop_visit_coroutine_kind<T: MutVisitor>(coroutine_kind: &mut CoroutineKind, vis: &mut T) {
875+
match coroutine_kind {
876876
CoroutineKind::Async { span, closure_id, return_impl_trait_id }
877877
| CoroutineKind::Gen { span, closure_id, return_impl_trait_id } => {
878878
vis.visit_span(span);
@@ -1171,9 +1171,9 @@ fn visit_const_item<T: MutVisitor>(
11711171
}
11721172

11731173
pub fn noop_visit_fn_header<T: MutVisitor>(header: &mut FnHeader, vis: &mut T) {
1174-
let FnHeader { unsafety, coro_kind, constness, ext: _ } = header;
1174+
let FnHeader { unsafety, coroutine_kind, constness, ext: _ } = header;
11751175
visit_constness(constness, vis);
1176-
coro_kind.as_mut().map(|coro_kind| vis.visit_coro_kind(coro_kind));
1176+
coroutine_kind.as_mut().map(|coroutine_kind| vis.visit_coroutine_kind(coroutine_kind));
11771177
visit_unsafety(unsafety, vis);
11781178
}
11791179

@@ -1407,7 +1407,7 @@ pub fn noop_visit_expr<T: MutVisitor>(
14071407
binder,
14081408
capture_clause,
14091409
constness,
1410-
coro_kind,
1410+
coroutine_kind,
14111411
movability: _,
14121412
fn_decl,
14131413
body,
@@ -1416,7 +1416,7 @@ pub fn noop_visit_expr<T: MutVisitor>(
14161416
}) => {
14171417
vis.visit_closure_binder(binder);
14181418
visit_constness(constness, vis);
1419-
coro_kind.as_mut().map(|coro_kind| vis.visit_coro_kind(coro_kind));
1419+
coroutine_kind.as_mut().map(|coroutine_kind| vis.visit_coroutine_kind(coroutine_kind));
14201420
vis.visit_capture_by(capture_clause);
14211421
vis.visit_fn_decl(fn_decl);
14221422
vis.visit_expr(body);

compiler/rustc_ast/src/visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) {
861861
ExprKind::Closure(box Closure {
862862
binder,
863863
capture_clause,
864-
coro_kind: _,
864+
coroutine_kind: _,
865865
constness: _,
866866
movability: _,
867867
fn_decl,

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
195195
binder,
196196
capture_clause,
197197
constness,
198-
coro_kind,
198+
coroutine_kind,
199199
movability,
200200
fn_decl,
201201
body,
202202
fn_decl_span,
203203
fn_arg_span,
204-
}) => match coro_kind {
204+
}) => match coroutine_kind {
205205
Some(
206206
CoroutineKind::Async { closure_id, .. }
207207
| CoroutineKind::Gen { closure_id, .. },

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -206,19 +206,25 @@ impl<'hir> LoweringContext<'_, 'hir> {
206206
// `impl Future<Output = T>` here because lower_body
207207
// only cares about the input argument patterns in the function
208208
// declaration (decl), not the return types.
209-
let coro_kind = header.coro_kind;
209+
let coroutine_kind = header.coroutine_kind;
210210
let body_id = this.lower_maybe_coroutine_body(
211211
span,
212212
hir_id,
213213
decl,
214-
coro_kind,
214+
coroutine_kind,
215215
body.as_deref(),
216216
);
217217

218218
let itctx = ImplTraitContext::Universal;
219219
let (generics, decl) =
220220
this.lower_generics(generics, header.constness, id, &itctx, |this| {
221-
this.lower_fn_decl(decl, id, *fn_sig_span, FnDeclKind::Fn, coro_kind)
221+
this.lower_fn_decl(
222+
decl,
223+
id,
224+
*fn_sig_span,
225+
FnDeclKind::Fn,
226+
coroutine_kind,
227+
)
222228
});
223229
let sig = hir::FnSig {
224230
decl,
@@ -735,7 +741,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
735741
sig,
736742
i.id,
737743
FnDeclKind::Trait,
738-
sig.header.coro_kind,
744+
sig.header.coroutine_kind,
739745
);
740746
(generics, hir::TraitItemKind::Fn(sig, hir::TraitFn::Required(names)), false)
741747
}
@@ -744,15 +750,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
744750
i.span,
745751
hir_id,
746752
&sig.decl,
747-
sig.header.coro_kind,
753+
sig.header.coroutine_kind,
748754
Some(body),
749755
);
750756
let (generics, sig) = self.lower_method_sig(
751757
generics,
752758
sig,
753759
i.id,
754760
FnDeclKind::Trait,
755-
sig.header.coro_kind,
761+
sig.header.coroutine_kind,
756762
);
757763
(generics, hir::TraitItemKind::Fn(sig, hir::TraitFn::Provided(body_id)), true)
758764
}
@@ -845,15 +851,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
845851
i.span,
846852
hir_id,
847853
&sig.decl,
848-
sig.header.coro_kind,
854+
sig.header.coroutine_kind,
849855
body.as_deref(),
850856
);
851857
let (generics, sig) = self.lower_method_sig(
852858
generics,
853859
sig,
854860
i.id,
855861
if self.is_in_trait_impl { FnDeclKind::Impl } else { FnDeclKind::Inherent },
856-
sig.header.coro_kind,
862+
sig.header.coroutine_kind,
857863
);
858864

859865
(generics, hir::ImplItemKind::Fn(sig, body_id))
@@ -1024,13 +1030,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
10241030
span: Span,
10251031
fn_id: hir::HirId,
10261032
decl: &FnDecl,
1027-
coro_kind: Option<CoroutineKind>,
1033+
coroutine_kind: Option<CoroutineKind>,
10281034
body: Option<&Block>,
10291035
) -> hir::BodyId {
1030-
let (Some(coro_kind), Some(body)) = (coro_kind, body) else {
1036+
let (Some(coroutine_kind), Some(body)) = (coroutine_kind, body) else {
10311037
return self.lower_fn_body_block(span, decl, body);
10321038
};
1033-
let closure_id = match coro_kind {
1039+
let closure_id = match coroutine_kind {
10341040
CoroutineKind::Async { closure_id, .. } | CoroutineKind::Gen { closure_id, .. } => {
10351041
closure_id
10361042
}
@@ -1201,7 +1207,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
12011207

12021208
this.expr_block(body)
12031209
};
1204-
let coroutine_expr = match coro_kind {
1210+
let coroutine_expr = match coroutine_kind {
12051211
CoroutineKind::Async { .. } => this.make_async_expr(
12061212
CaptureBy::Value { move_kw: rustc_span::DUMMY_SP },
12071213
closure_id,
@@ -1234,19 +1240,19 @@ impl<'hir> LoweringContext<'_, 'hir> {
12341240
sig: &FnSig,
12351241
id: NodeId,
12361242
kind: FnDeclKind,
1237-
coro_kind: Option<CoroutineKind>,
1243+
coroutine_kind: Option<CoroutineKind>,
12381244
) -> (&'hir hir::Generics<'hir>, hir::FnSig<'hir>) {
12391245
let header = self.lower_fn_header(sig.header);
12401246
let itctx = ImplTraitContext::Universal;
12411247
let (generics, decl) =
12421248
self.lower_generics(generics, sig.header.constness, id, &itctx, |this| {
1243-
this.lower_fn_decl(&sig.decl, id, sig.span, kind, coro_kind)
1249+
this.lower_fn_decl(&sig.decl, id, sig.span, kind, coroutine_kind)
12441250
});
12451251
(generics, hir::FnSig { header, decl, span: self.lower_span(sig.span) })
12461252
}
12471253

12481254
fn lower_fn_header(&mut self, h: FnHeader) -> hir::FnHeader {
1249-
let asyncness = if let Some(CoroutineKind::Async { span, .. }) = h.coro_kind {
1255+
let asyncness = if let Some(CoroutineKind::Async { span, .. }) = h.coroutine_kind {
12501256
hir::IsAsync::Async(span)
12511257
} else {
12521258
hir::IsAsync::NotAsync

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1271,7 +1271,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
12711271
// Functions cannot both be `const async` or `const gen`
12721272
if let Some(&FnHeader {
12731273
constness: Const::Yes(cspan),
1274-
coro_kind:
1274+
coroutine_kind:
12751275
Some(
12761276
CoroutineKind::Async { span: aspan, .. }
12771277
| CoroutineKind::Gen { span: aspan, .. },

compiler/rustc_ast_pretty/src/pprust/state.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,8 +1490,8 @@ impl<'a> State<'a> {
14901490
}
14911491
}
14921492

1493-
fn print_coro_kind(&mut self, coro_kind: ast::CoroutineKind) {
1494-
match coro_kind {
1493+
fn print_coroutine_kind(&mut self, coroutine_kind: ast::CoroutineKind) {
1494+
match coroutine_kind {
14951495
ast::CoroutineKind::Gen { .. } => {
14961496
self.word_nbsp("gen");
14971497
}
@@ -1690,7 +1690,7 @@ impl<'a> State<'a> {
16901690

16911691
fn print_fn_header_info(&mut self, header: ast::FnHeader) {
16921692
self.print_constness(header.constness);
1693-
header.coro_kind.map(|coro_kind| self.print_coro_kind(coro_kind));
1693+
header.coroutine_kind.map(|coroutine_kind| self.print_coroutine_kind(coroutine_kind));
16941694
self.print_unsafety(header.unsafety);
16951695

16961696
match header.ext {

compiler/rustc_ast_pretty/src/pprust/state/expr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ impl<'a> State<'a> {
413413
binder,
414414
capture_clause,
415415
constness,
416-
coro_kind,
416+
coroutine_kind,
417417
movability,
418418
fn_decl,
419419
body,
@@ -423,7 +423,7 @@ impl<'a> State<'a> {
423423
self.print_closure_binder(binder);
424424
self.print_constness(*constness);
425425
self.print_movability(*movability);
426-
coro_kind.map(|coro_kind| self.print_coro_kind(coro_kind));
426+
coroutine_kind.map(|coroutine_kind| self.print_coroutine_kind(coroutine_kind));
427427
self.print_capture_clause(*capture_clause);
428428

429429
self.print_fn_params_and_ret(fn_decl, true);

compiler/rustc_builtin_macros/src/test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,11 +541,11 @@ fn check_test_signature(
541541
return Err(sd.emit_err(errors::TestBadFn { span: i.span, cause: span, kind: "unsafe" }));
542542
}
543543

544-
if let Some(ast::CoroutineKind::Async { span, .. }) = f.sig.header.coro_kind {
544+
if let Some(ast::CoroutineKind::Async { span, .. }) = f.sig.header.coroutine_kind {
545545
return Err(sd.emit_err(errors::TestBadFn { span: i.span, cause: span, kind: "async" }));
546546
}
547547

548-
if let Some(ast::CoroutineKind::Gen { span, .. }) = f.sig.header.coro_kind {
548+
if let Some(ast::CoroutineKind::Gen { span, .. }) = f.sig.header.coroutine_kind {
549549
return Err(sd.emit_err(errors::TestBadFn { span: i.span, cause: span, kind: "gen" }));
550550
}
551551

compiler/rustc_expand/src/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ impl<'a> ExtCtxt<'a> {
547547
binder: ast::ClosureBinder::NotPresent,
548548
capture_clause: ast::CaptureBy::Ref,
549549
constness: ast::Const::No,
550-
coro_kind: None,
550+
coroutine_kind: None,
551551
movability: ast::Movability::Movable,
552552
fn_decl,
553553
body,

compiler/rustc_lint/src/early.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T>
165165
if let Some(
166166
ast::CoroutineKind::Async { closure_id, .. }
167167
| ast::CoroutineKind::Gen { closure_id, .. },
168-
) = sig.header.coro_kind
168+
) = sig.header.coroutine_kind
169169
{
170170
self.check_id(closure_id);
171171
}
@@ -227,7 +227,7 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T>
227227
// it does not have a corresponding AST node
228228
match e.kind {
229229
ast::ExprKind::Closure(box ast::Closure {
230-
coro_kind:
230+
coroutine_kind:
231231
Some(
232232
ast::CoroutineKind::Async { closure_id, .. }
233233
| ast::CoroutineKind::Gen { closure_id, .. },

compiler/rustc_parse/src/parser/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2285,7 +2285,7 @@ impl<'a> Parser<'a> {
22852285
binder,
22862286
capture_clause,
22872287
constness,
2288-
coro_kind: asyncness,
2288+
coroutine_kind: asyncness,
22892289
movability,
22902290
fn_decl,
22912291
body,

compiler/rustc_parse/src/parser/item.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2559,7 +2559,7 @@ impl<'a> Parser<'a> {
25592559
return Ok(FnHeader {
25602560
constness: recover_constness,
25612561
unsafety: recover_unsafety,
2562-
coro_kind: recover_asyncness,
2562+
coroutine_kind: recover_asyncness,
25632563
ext,
25642564
});
25652565
}
@@ -2569,13 +2569,13 @@ impl<'a> Parser<'a> {
25692569
}
25702570
}
25712571

2572-
let coro_kind = match asyncness {
2572+
let coroutine_kind = match asyncness {
25732573
Some(CoroutineKind::Async { .. }) => asyncness,
25742574
Some(CoroutineKind::Gen { .. }) => unreachable!("asycness cannot be Gen"),
25752575
None => genness,
25762576
};
25772577

2578-
Ok(FnHeader { constness, unsafety, coro_kind, ext })
2578+
Ok(FnHeader { constness, unsafety, coroutine_kind, ext })
25792579
}
25802580

25812581
/// Parses the parameter list and result type of a function declaration.

compiler/rustc_parse/src/parser/ty.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ impl<'a> Parser<'a> {
596596
tokens: None,
597597
};
598598
let span_start = self.token.span;
599-
let ast::FnHeader { ext, unsafety, constness, coro_kind } =
599+
let ast::FnHeader { ext, unsafety, constness, coroutine_kind } =
600600
self.parse_fn_front_matter(&inherited_vis, Case::Sensitive)?;
601601
if self.may_recover() && self.token.kind == TokenKind::Lt {
602602
self.recover_fn_ptr_with_generics(lo, &mut params, param_insertion_point)?;
@@ -609,7 +609,7 @@ impl<'a> Parser<'a> {
609609
// cover it.
610610
self.sess.emit_err(FnPointerCannotBeConst { span: whole_span, qualifier: span });
611611
}
612-
if let Some(ast::CoroutineKind::Async { span, .. }) = coro_kind {
612+
if let Some(ast::CoroutineKind::Async { span, .. }) = coroutine_kind {
613613
self.sess.emit_err(FnPointerCannotBeAsync { span: whole_span, qualifier: span });
614614
}
615615
// FIXME(gen_blocks): emit a similar error for `gen fn()`

0 commit comments

Comments
 (0)