Skip to content

Commit ad0b41c

Browse files
committed
Refactor YieldKind so postfix yield must have an expression
1 parent 96f68d1 commit ad0b41c

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/chains.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ impl ChainItemKind {
259259
let span = mk_sp(nested.span.hi(), expr.span.hi());
260260
(ChainItemKind::Await, span)
261261
}
262-
ast::ExprKind::Yield(Some(ref nested), ast::YieldKind::Postfix) => {
262+
ast::ExprKind::Yield(ast::YieldKind::Postfix(ref nested)) => {
263263
let span = mk_sp(nested.span.hi(), expr.span.hi());
264264
(ChainItemKind::Yield, span)
265265
}
@@ -516,7 +516,7 @@ impl Chain {
516516
ast::ExprKind::Field(ref subexpr, _)
517517
| ast::ExprKind::Try(ref subexpr)
518518
| ast::ExprKind::Await(ref subexpr, _)
519-
| ast::ExprKind::Yield(Some(ref subexpr), ast::YieldKind::Postfix) => Some(SubExpr {
519+
| ast::ExprKind::Yield(ast::YieldKind::Postfix(ref subexpr)) => Some(SubExpr {
520520
expr: Self::convert_try(subexpr, context),
521521
is_method_call_receiver: false,
522522
}),

src/expr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ pub(crate) fn format_expr(
221221
Ok(format!("break{id_str}"))
222222
}
223223
}
224-
ast::ExprKind::Yield(ref opt_expr, ast::YieldKind::Prefix) => {
224+
ast::ExprKind::Yield(ast::YieldKind::Prefix(ref opt_expr)) => {
225225
if let Some(ref expr) = *opt_expr {
226226
rewrite_unary_prefix(context, "yield ", &**expr, shape)
227227
} else {
@@ -244,7 +244,7 @@ pub(crate) fn format_expr(
244244
| ast::ExprKind::Field(..)
245245
| ast::ExprKind::MethodCall(..)
246246
| ast::ExprKind::Await(_, _)
247-
| ast::ExprKind::Yield(_, ast::YieldKind::Postfix) => rewrite_chain(expr, context, shape),
247+
| ast::ExprKind::Yield(ast::YieldKind::Postfix(_)) => rewrite_chain(expr, context, shape),
248248
ast::ExprKind::MacCall(ref mac) => {
249249
rewrite_macro(mac, None, context, shape, MacroPosition::Expression).or_else(|_| {
250250
wrap_str(

src/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ pub(crate) fn is_block_expr(context: &RewriteContext<'_>, expr: &ast::Expr, repr
485485
| ast::ExprKind::Index(_, ref expr, _)
486486
| ast::ExprKind::Unary(_, ref expr)
487487
| ast::ExprKind::Try(ref expr)
488-
| ast::ExprKind::Yield(Some(ref expr), YieldKind::Prefix) => {
488+
| ast::ExprKind::Yield(YieldKind::Prefix(Some(ref expr))) => {
489489
is_block_expr(context, expr, repr)
490490
}
491491
ast::ExprKind::Closure(ref closure) => is_block_expr(context, &closure.body, repr),
@@ -517,7 +517,7 @@ pub(crate) fn is_block_expr(context: &RewriteContext<'_>, expr: &ast::Expr, repr
517517
| ast::ExprKind::Tup(..)
518518
| ast::ExprKind::Use(..)
519519
| ast::ExprKind::Type(..)
520-
| ast::ExprKind::Yield(_, _)
520+
| ast::ExprKind::Yield(..)
521521
| ast::ExprKind::Underscore => false,
522522
}
523523
}

0 commit comments

Comments
 (0)