about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2023-10-20 21:26:57 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2023-10-27 13:05:48 +0000
commita3be235fccea89aed17043c917c7fb52c4a57894 (patch)
tree3c11f4b0bf5cff0eb572b113310fc66eea3ef49a
parentd5bf53b454ca07de38a89fb6be6431344de0297f (diff)
downloadrust-a3be235fccea89aed17043c917c7fb52c4a57894.tar.gz
rust-a3be235fccea89aed17043c917c7fb52c4a57894.zip
Add gen blocks to ast and do some broken ast lowering
-rw-r--r--src/closures.rs2
-rw-r--r--src/expr.rs8
-rw-r--r--src/utils.rs2
3 files changed, 6 insertions, 6 deletions
diff --git a/src/closures.rs b/src/closures.rs
index a09146e9592..16b8ce7a916 100644
--- a/src/closures.rs
+++ b/src/closures.rs
@@ -188,7 +188,7 @@ fn rewrite_closure_expr(
     fn allow_multi_line(expr: &ast::Expr) -> bool {
         match expr.kind {
             ast::ExprKind::Match(..)
-            | ast::ExprKind::Async(..)
+            | ast::ExprKind::Gen(..)
             | ast::ExprKind::Block(..)
             | ast::ExprKind::TryBlock(..)
             | ast::ExprKind::Loop(..)
diff --git a/src/expr.rs b/src/expr.rs
index acde8809329..8c2262fde81 100644
--- a/src/expr.rs
+++ b/src/expr.rs
@@ -367,7 +367,7 @@ pub(crate) fn format_expr(
                 ))
             }
         }
-        ast::ExprKind::Async(capture_by, ref block) => {
+        ast::ExprKind::Gen(capture_by, ref block, ref kind) => {
             let mover = if capture_by == ast::CaptureBy::Value {
                 "move "
             } else {
@@ -375,7 +375,7 @@ pub(crate) fn format_expr(
             };
             if let rw @ Some(_) = rewrite_single_line_block(
                 context,
-                format!("async {mover}").as_str(),
+                format!("{kind} {mover}").as_str(),
                 block,
                 Some(&expr.attrs),
                 None,
@@ -386,7 +386,7 @@ pub(crate) fn format_expr(
                 // 6 = `async `
                 let budget = shape.width.saturating_sub(6);
                 Some(format!(
-                    "async {mover}{}",
+                    "{kind} {mover}{}",
                     rewrite_block(
                         block,
                         Some(&expr.attrs),
@@ -1371,7 +1371,7 @@ pub(crate) fn can_be_overflowed_expr(
         }
 
         // Handle always block-like expressions
-        ast::ExprKind::Async(..) | ast::ExprKind::Block(..) | ast::ExprKind::Closure(..) => true,
+        ast::ExprKind::Gen(..) | ast::ExprKind::Block(..) | ast::ExprKind::Closure(..) => true,
 
         // Handle `[]` and `{}`-like expressions
         ast::ExprKind::Array(..) | ast::ExprKind::Struct(..) => {
diff --git a/src/utils.rs b/src/utils.rs
index 79a759d68ce..fd49030bf1b 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -473,7 +473,7 @@ pub(crate) fn is_block_expr(context: &RewriteContext<'_>, expr: &ast::Expr, repr
         | ast::ExprKind::If(..)
         | ast::ExprKind::Block(..)
         | ast::ExprKind::ConstBlock(..)
-        | ast::ExprKind::Async(..)
+        | ast::ExprKind::Gen(..)
         | ast::ExprKind::Loop(..)
         | ast::ExprKind::ForLoop(..)
         | ast::ExprKind::TryBlock(..)