diff options
| author | Eric Holk <ericholk@microsoft.com> | 2025-03-18 12:19:43 -0700 |
|---|---|---|
| committer | Eric Holk <ericholk@microsoft.com> | 2025-03-18 12:19:43 -0700 |
| commit | 2bd7f73c2175c1f0ad56a0be4b5c39e2fc5ab97b (patch) | |
| tree | d040d21539ffd8604385e56f6e2e5a355a9c863f /compiler/rustc_parse/src/parser/expr.rs | |
| parent | 299e5d05147c3d3deefd3f85f6e994b5d05fb2f8 (diff) | |
| download | rust-2bd7f73c2175c1f0ad56a0be4b5c39e2fc5ab97b.tar.gz rust-2bd7f73c2175c1f0ad56a0be4b5c39e2fc5ab97b.zip | |
Refactor YieldKind so postfix yield must have an expression
Diffstat (limited to 'compiler/rustc_parse/src/parser/expr.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/expr.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 15a625314b4..fc9a511d56a 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -1315,8 +1315,9 @@ impl<'a> Parser<'a> { if self.eat_keyword(exp!(Yield)) { let yield_span = self.prev_token.span; self.psess.gated_spans.gate(sym::yield_expr, yield_span); - return Ok(self - .mk_expr(lo.to(yield_span), ExprKind::Yield(Some(self_arg), YieldKind::Postfix))); + return Ok( + self.mk_expr(lo.to(yield_span), ExprKind::Yield(YieldKind::Postfix(self_arg))) + ); } let fn_span_lo = self.token.span; @@ -1893,7 +1894,7 @@ impl<'a> Parser<'a> { /// Parse `"yield" expr?`. fn parse_expr_yield(&mut self) -> PResult<'a, P<Expr>> { let lo = self.prev_token.span; - let kind = ExprKind::Yield(self.parse_expr_opt()?, YieldKind::Prefix); + let kind = ExprKind::Yield(YieldKind::Prefix(self.parse_expr_opt()?)); let span = lo.to(self.prev_token.span); self.psess.gated_spans.gate(sym::yield_expr, span); let expr = self.mk_expr(span, kind); @@ -4047,7 +4048,7 @@ impl MutVisitor for CondChecker<'_> { | ExprKind::MacCall(_) | ExprKind::Struct(_) | ExprKind::Repeat(_, _) - | ExprKind::Yield(_, _) + | ExprKind::Yield(_) | ExprKind::Yeet(_) | ExprKind::Become(_) | ExprKind::IncludedBytes(_) |
