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_ast/src/util | |
| 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_ast/src/util')
| -rw-r--r-- | compiler/rustc_ast/src/util/classify.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/compiler/rustc_ast/src/util/classify.rs b/compiler/rustc_ast/src/util/classify.rs index 116847af9f4..989ebe14bf8 100644 --- a/compiler/rustc_ast/src/util/classify.rs +++ b/compiler/rustc_ast/src/util/classify.rs @@ -182,11 +182,14 @@ pub fn expr_trailing_brace(mut expr: &ast::Expr) -> Option<TrailingBrace<'_>> { | Range(_, Some(e), _) | Ret(Some(e)) | Unary(_, e) - | Yield(Some(e), _) | Yeet(Some(e)) | Become(e) => { expr = e; } + Yield(kind) => match kind.expr() { + Some(e) => expr = e, + None => break None, + }, Closure(closure) => { expr = &closure.body; } @@ -217,7 +220,6 @@ pub fn expr_trailing_brace(mut expr: &ast::Expr) -> Option<TrailingBrace<'_>> { Break(_, None) | Range(_, None, _) | Ret(None) - | Yield(None, _) | Array(_) | Call(_, _) | MethodCall(_) @@ -237,7 +239,9 @@ pub fn expr_trailing_brace(mut expr: &ast::Expr) -> Option<TrailingBrace<'_>> { | Yeet(None) | UnsafeBinderCast(..) | Err(_) - | Dummy => break None, + | Dummy => { + break None; + } } } } |
