From f114bb42ec9220a488e9cab120dadf2587196fec Mon Sep 17 00:00:00 2001 From: Eric Holk Date: Mon, 4 Dec 2023 13:43:38 -0800 Subject: [PATCH] Address code review feedback --- src/closures.rs | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/closures.rs b/src/closures.rs index d79218e78ee..c1ce87eadcb 100644 --- a/src/closures.rs +++ b/src/closures.rs @@ -263,12 +263,10 @@ fn rewrite_closure_fn_decl( } else { "" }; - let (is_async, is_gen) = if let Some(coro_kind) = coro_kind { - let is_async = if coro_kind.is_async() { "async " } else { "" }; - let is_gen = if coro_kind.is_gen() { "gen " } else { "" }; - (is_async, is_gen) - } else { - ("", "") + let coro = match coro_kind { + Some(ast::CoroutineKind::Async { .. }) => "async ", + Some(ast::CoroutineKind::Gen { .. }) => "gen ", + None => "", }; let mover = if matches!(capture, ast::CaptureBy::Value { .. }) { "move " @@ -278,14 +276,7 @@ fn rewrite_closure_fn_decl( // 4 = "|| {".len(), which is overconservative when the closure consists of // a single expression. let nested_shape = shape - .shrink_left( - binder.len() - + const_.len() - + immovable.len() - + is_async.len() - + is_gen.len() - + mover.len(), - )? + .shrink_left(binder.len() + const_.len() + immovable.len() + coro.len() + mover.len())? .sub_width(4)?; // 1 = | @@ -323,7 +314,7 @@ fn rewrite_closure_fn_decl( .tactic(tactic) .preserve_newline(true); let list_str = write_list(&item_vec, &fmt)?; - let mut prefix = format!("{binder}{const_}{immovable}{is_async}{is_gen}{mover}|{list_str}|"); + let mut prefix = format!("{binder}{const_}{immovable}{coro}{mover}|{list_str}|"); if !ret_str.is_empty() { if prefix.contains('\n') {