coro_kind -> coroutine_kind

This commit is contained in:
Michael Goulet 2023-12-05 21:39:36 +00:00
parent f114bb42ec
commit 6ebb66cea9
4 changed files with 23 additions and 14 deletions

View File

@ -29,7 +29,7 @@ pub(crate) fn rewrite_closure(
binder: &ast::ClosureBinder, binder: &ast::ClosureBinder,
constness: ast::Const, constness: ast::Const,
capture: ast::CaptureBy, capture: ast::CaptureBy,
coro_kind: &Option<ast::CoroutineKind>, coroutine_kind: &Option<ast::CoroutineKind>,
movability: ast::Movability, movability: ast::Movability,
fn_decl: &ast::FnDecl, fn_decl: &ast::FnDecl,
body: &ast::Expr, body: &ast::Expr,
@ -40,7 +40,16 @@ pub(crate) fn rewrite_closure(
debug!("rewrite_closure {:?}", body); debug!("rewrite_closure {:?}", body);
let (prefix, extra_offset) = rewrite_closure_fn_decl( let (prefix, extra_offset) = rewrite_closure_fn_decl(
binder, constness, capture, coro_kind, movability, fn_decl, body, span, context, shape, binder,
constness,
capture,
coroutine_kind,
movability,
fn_decl,
body,
span,
context,
shape,
)?; )?;
// 1 = space between `|...|` and body. // 1 = space between `|...|` and body.
let body_shape = shape.offset_left(extra_offset)?; let body_shape = shape.offset_left(extra_offset)?;
@ -233,7 +242,7 @@ fn rewrite_closure_fn_decl(
binder: &ast::ClosureBinder, binder: &ast::ClosureBinder,
constness: ast::Const, constness: ast::Const,
capture: ast::CaptureBy, capture: ast::CaptureBy,
coro_kind: &Option<ast::CoroutineKind>, coroutine_kind: &Option<ast::CoroutineKind>,
movability: ast::Movability, movability: ast::Movability,
fn_decl: &ast::FnDecl, fn_decl: &ast::FnDecl,
body: &ast::Expr, body: &ast::Expr,
@ -263,7 +272,7 @@ fn rewrite_closure_fn_decl(
} else { } else {
"" ""
}; };
let coro = match coro_kind { let coro = match coroutine_kind {
Some(ast::CoroutineKind::Async { .. }) => "async ", Some(ast::CoroutineKind::Async { .. }) => "async ",
Some(ast::CoroutineKind::Gen { .. }) => "gen ", Some(ast::CoroutineKind::Gen { .. }) => "gen ",
None => "", None => "",
@ -343,7 +352,7 @@ pub(crate) fn rewrite_last_closure(
ref binder, ref binder,
constness, constness,
capture_clause, capture_clause,
ref coro_kind, ref coroutine_kind,
movability, movability,
ref fn_decl, ref fn_decl,
ref body, ref body,
@ -364,7 +373,7 @@ pub(crate) fn rewrite_last_closure(
binder, binder,
constness, constness,
capture_clause, capture_clause,
coro_kind, coroutine_kind,
movability, movability,
fn_decl, fn_decl,
body, body,

View File

@ -212,7 +212,7 @@ pub(crate) fn format_expr(
&cl.binder, &cl.binder,
cl.constness, cl.constness,
cl.capture_clause, cl.capture_clause,
&cl.coro_kind, &cl.coroutine_kind,
cl.movability, cl.movability,
&cl.fn_decl, &cl.fn_decl,
&cl.body, &cl.body,

View File

@ -287,7 +287,7 @@ pub(crate) struct FnSig<'a> {
decl: &'a ast::FnDecl, decl: &'a ast::FnDecl,
generics: &'a ast::Generics, generics: &'a ast::Generics,
ext: ast::Extern, ext: ast::Extern,
coro_kind: Cow<'a, Option<ast::CoroutineKind>>, coroutine_kind: Cow<'a, Option<ast::CoroutineKind>>,
constness: ast::Const, constness: ast::Const,
defaultness: ast::Defaultness, defaultness: ast::Defaultness,
unsafety: ast::Unsafe, unsafety: ast::Unsafe,
@ -302,7 +302,7 @@ impl<'a> FnSig<'a> {
) -> FnSig<'a> { ) -> FnSig<'a> {
FnSig { FnSig {
unsafety: method_sig.header.unsafety, unsafety: method_sig.header.unsafety,
coro_kind: Cow::Borrowed(&method_sig.header.coro_kind), coroutine_kind: Cow::Borrowed(&method_sig.header.coroutine_kind),
constness: method_sig.header.constness, constness: method_sig.header.constness,
defaultness: ast::Defaultness::Final, defaultness: ast::Defaultness::Final,
ext: method_sig.header.ext, ext: method_sig.header.ext,
@ -328,7 +328,7 @@ impl<'a> FnSig<'a> {
generics, generics,
ext: fn_sig.header.ext, ext: fn_sig.header.ext,
constness: fn_sig.header.constness, constness: fn_sig.header.constness,
coro_kind: Cow::Borrowed(&fn_sig.header.coro_kind), coroutine_kind: Cow::Borrowed(&fn_sig.header.coroutine_kind),
defaultness, defaultness,
unsafety: fn_sig.header.unsafety, unsafety: fn_sig.header.unsafety,
visibility: vis, visibility: vis,
@ -343,8 +343,8 @@ impl<'a> FnSig<'a> {
result.push_str(&*format_visibility(context, self.visibility)); result.push_str(&*format_visibility(context, self.visibility));
result.push_str(format_defaultness(self.defaultness)); result.push_str(format_defaultness(self.defaultness));
result.push_str(format_constness(self.constness)); result.push_str(format_constness(self.constness));
self.coro_kind self.coroutine_kind
.map(|coro_kind| result.push_str(format_coro(&coro_kind))); .map(|coroutine_kind| result.push_str(format_coro(&coroutine_kind)));
result.push_str(format_unsafety(self.unsafety)); result.push_str(format_unsafety(self.unsafety));
result.push_str(&format_extern( result.push_str(&format_extern(
self.ext, self.ext,

View File

@ -75,8 +75,8 @@ pub(crate) fn format_visibility(
} }
#[inline] #[inline]
pub(crate) fn format_coro(coro_kind: &ast::CoroutineKind) -> &'static str { pub(crate) fn format_coro(coroutine_kind: &ast::CoroutineKind) -> &'static str {
match coro_kind { match coroutine_kind {
ast::CoroutineKind::Async { .. } => "async ", ast::CoroutineKind::Async { .. } => "async ",
ast::CoroutineKind::Gen { .. } => "gen ", ast::CoroutineKind::Gen { .. } => "gen ",
} }