Skip to content

Commit 49713c0

Browse files
committed
Add visit_coroutine_kind
1 parent 6295686 commit 49713c0

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

compiler/rustc_ast/src/visit.rs

+16-3
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,8 @@ pub trait Visitor<'ast>: Sized {
268268
fn visit_fn_ret_ty(&mut self, ret_ty: &'ast FnRetTy) -> Self::Result {
269269
walk_fn_ret_ty(self, ret_ty)
270270
}
271-
fn visit_fn_header(&mut self, _header: &'ast FnHeader) -> Self::Result {
272-
Self::Result::output()
271+
fn visit_fn_header(&mut self, header: &'ast FnHeader) -> Self::Result {
272+
walk_fn_header(self, header)
273273
}
274274
fn visit_expr_field(&mut self, f: &'ast ExprField) -> Self::Result {
275275
walk_expr_field(self, f)
@@ -292,6 +292,9 @@ pub trait Visitor<'ast>: Sized {
292292
fn visit_capture_by(&mut self, _capture_by: &'ast CaptureBy) -> Self::Result {
293293
Self::Result::output()
294294
}
295+
fn visit_coroutine_kind(&mut self, _coroutine_kind: &'ast CoroutineKind) -> Self::Result {
296+
Self::Result::output()
297+
}
295298
}
296299

297300
pub fn walk_crate<'a, V: Visitor<'a>>(visitor: &mut V, krate: &'a Crate) -> V::Result {
@@ -817,6 +820,15 @@ pub fn walk_fn_ret_ty<'a, V: Visitor<'a>>(visitor: &mut V, ret_ty: &'a FnRetTy)
817820
V::Result::output()
818821
}
819822

823+
pub fn walk_fn_header<'a, V: Visitor<'a>>(
824+
visitor: &mut V,
825+
fn_header: &'a FnHeader
826+
) -> V::Result {
827+
let FnHeader { safety: _, coroutine_kind, constness: _, ext: _ } = fn_header;
828+
visit_opt!(visitor, visit_coroutine_kind, coroutine_kind.as_ref());
829+
V::Result::output()
830+
}
831+
820832
pub fn walk_fn_decl<'a, V: Visitor<'a>>(
821833
visitor: &mut V,
822834
FnDecl { inputs, output }: &'a FnDecl,
@@ -834,8 +846,9 @@ pub fn walk_fn<'a, V: Visitor<'a>>(visitor: &mut V, kind: FnKind<'a>) -> V::Resu
834846
try_visit!(walk_fn_decl(visitor, decl));
835847
visit_opt!(visitor, visit_block, body);
836848
}
837-
FnKind::Closure(binder, _coroutine_kind, decl, body) => {
849+
FnKind::Closure(binder, coroutine_kind, decl, body) => {
838850
try_visit!(visitor.visit_closure_binder(binder));
851+
visit_opt!(visitor, visit_coroutine_kind, coroutine_kind.as_ref());
839852
try_visit!(walk_fn_decl(visitor, decl));
840853
try_visit!(visitor.visit_expr(body));
841854
}

0 commit comments

Comments
 (0)