@@ -29,7 +29,7 @@ pub(crate) fn rewrite_closure(
2929 binder : & ast:: ClosureBinder ,
3030 constness : ast:: Const ,
3131 capture : ast:: CaptureBy ,
32- is_async : & ast:: Async ,
32+ coro_kind : & ast:: CoroutineKind ,
3333 movability : ast:: Movability ,
3434 fn_decl : & ast:: FnDecl ,
3535 body : & ast:: Expr ,
@@ -40,7 +40,7 @@ pub(crate) fn rewrite_closure(
4040 debug ! ( "rewrite_closure {:?}" , body) ;
4141
4242 let ( prefix, extra_offset) = rewrite_closure_fn_decl (
43- binder, constness, capture, is_async , movability, fn_decl, body, span, context, shape,
43+ binder, constness, capture, coro_kind , movability, fn_decl, body, span, context, shape,
4444 ) ?;
4545 // 1 = space between `|...|` and body.
4646 let body_shape = shape. offset_left ( extra_offset) ?;
@@ -233,7 +233,7 @@ fn rewrite_closure_fn_decl(
233233 binder : & ast:: ClosureBinder ,
234234 constness : ast:: Const ,
235235 capture : ast:: CaptureBy ,
236- asyncness : & ast:: Async ,
236+ coro_kind : & ast:: CoroutineKind ,
237237 movability : ast:: Movability ,
238238 fn_decl : & ast:: FnDecl ,
239239 body : & ast:: Expr ,
@@ -263,7 +263,8 @@ fn rewrite_closure_fn_decl(
263263 } else {
264264 ""
265265 } ;
266- let is_async = if asyncness. is_async ( ) { "async " } else { "" } ;
266+ let is_async = if coro_kind. is_async ( ) { "async " } else { "" } ;
267+ let is_gen = if coro_kind. is_gen ( ) { "gen " } else { "" } ;
267268 let mover = if matches ! ( capture, ast:: CaptureBy :: Value { .. } ) {
268269 "move "
269270 } else {
@@ -272,7 +273,14 @@ fn rewrite_closure_fn_decl(
272273 // 4 = "|| {".len(), which is overconservative when the closure consists of
273274 // a single expression.
274275 let nested_shape = shape
275- . shrink_left ( binder. len ( ) + const_. len ( ) + immovable. len ( ) + is_async. len ( ) + mover. len ( ) ) ?
276+ . shrink_left (
277+ binder. len ( )
278+ + const_. len ( )
279+ + immovable. len ( )
280+ + is_async. len ( )
281+ + is_gen. len ( )
282+ + mover. len ( ) ,
283+ ) ?
276284 . sub_width ( 4 ) ?;
277285
278286 // 1 = |
@@ -310,7 +318,7 @@ fn rewrite_closure_fn_decl(
310318 . tactic ( tactic)
311319 . preserve_newline ( true ) ;
312320 let list_str = write_list ( & item_vec, & fmt) ?;
313- let mut prefix = format ! ( "{binder}{const_}{immovable}{is_async}{mover}|{list_str}|" ) ;
321+ let mut prefix = format ! ( "{binder}{const_}{immovable}{is_async}{is_gen}{ mover}|{list_str}|" ) ;
314322
315323 if !ret_str. is_empty ( ) {
316324 if prefix. contains ( '\n' ) {
@@ -339,7 +347,7 @@ pub(crate) fn rewrite_last_closure(
339347 ref binder,
340348 constness,
341349 capture_clause,
342- ref asyncness ,
350+ ref coro_kind ,
343351 movability,
344352 ref fn_decl,
345353 ref body,
@@ -360,7 +368,7 @@ pub(crate) fn rewrite_last_closure(
360368 binder,
361369 constness,
362370 capture_clause,
363- asyncness ,
371+ coro_kind ,
364372 movability,
365373 fn_decl,
366374 body,
0 commit comments