about summary refs log tree commit diff
path: root/src/tools/rustfmt
diff options
context:
space:
mode:
authorEric Holk <ericholk@microsoft.com>2023-12-04 13:43:38 -0800
committerEric Holk <ericholk@microsoft.com>2023-12-04 14:33:46 -0800
commit50ef8006eb68682471894c99b49eb4e39b48c745 (patch)
treee64b78caa9226fb5267e38afffebf0813f228a33 /src/tools/rustfmt
parent26f9954971a2895580e02578fe18bc6f9adea3c9 (diff)
downloadrust-50ef8006eb68682471894c99b49eb4e39b48c745.tar.gz
rust-50ef8006eb68682471894c99b49eb4e39b48c745.zip
Address code review feedback
Diffstat (limited to 'src/tools/rustfmt')
-rw-r--r--src/tools/rustfmt/src/closures.rs21
1 files changed, 6 insertions, 15 deletions
diff --git a/src/tools/rustfmt/src/closures.rs b/src/tools/rustfmt/src/closures.rs
index d79218e78ee..c1ce87eadcb 100644
--- a/src/tools/rustfmt/src/closures.rs
+++ b/src/tools/rustfmt/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') {