Add gen blocks to ast and do some broken ast lowering
This commit is contained in:
parent
d5bf53b454
commit
a3be235fcc
@ -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(..)
|
||||
|
@ -367,7 +367,7 @@ fn needs_space_after_range(rhs: &ast::Expr) -> bool {
|
||||
))
|
||||
}
|
||||
}
|
||||
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 @@ fn needs_space_after_range(rhs: &ast::Expr) -> bool {
|
||||
};
|
||||
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 @@ fn needs_space_after_range(rhs: &ast::Expr) -> bool {
|
||||
// 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(..) => {
|
||||
|
@ -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(..)
|
||||
|
Loading…
Reference in New Issue
Block a user