diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-03-18 16:27:10 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-18 16:27:10 +0100 |
| commit | 72e2c7c45a76acc8d803783db66016877d857d81 (patch) | |
| tree | 3e5ded0b14d88d39ebdefd9a75972cf96784fe4b | |
| parent | 1ac0239bd23e06330d7d8ba7fc40584bb13a460d (diff) | |
| parent | f3e9dfaed6c4d44fc0a5182221c31e5b0ff038fd (diff) | |
| download | rust-72e2c7c45a76acc8d803783db66016877d857d81.tar.gz rust-72e2c7c45a76acc8d803783db66016877d857d81.zip | |
Rollup merge of #122680 - lqd:nested-await-args, r=compiler-errors
Do not eat nested expressions' results in `MayContainYieldPoint` format args visitor #121563 unintentionally changed the `MayContainYieldPoint` format args visitor behavior, now missing yield points in nested expressions, as seen in #122674. The walk can find a yield point in an expression but it was ignored. r? ``@petrochenkov`` as the reviewer of #121563 cc ``@Jarcho`` as the author Fixes #122674. We're in the 1.77 release week. #121563 will land on 1.78 but beta is still 1.77.9: this PR will likely need to be backported soon after beta is cut.
| -rw-r--r-- | compiler/rustc_ast_lowering/src/format.rs | 3 | ||||
| -rw-r--r-- | tests/ui/fmt/nested-awaits-issue-122674.rs | 22 |
2 files changed, 23 insertions, 2 deletions
diff --git a/compiler/rustc_ast_lowering/src/format.rs b/compiler/rustc_ast_lowering/src/format.rs index 3f84e6b100d..d2c3b8b2d56 100644 --- a/compiler/rustc_ast_lowering/src/format.rs +++ b/compiler/rustc_ast_lowering/src/format.rs @@ -604,8 +604,7 @@ fn may_contain_yield_point(e: &ast::Expr) -> bool { if let ast::ExprKind::Await(_, _) | ast::ExprKind::Yield(_) = e.kind { ControlFlow::Break(()) } else { - visit::walk_expr(self, e); - ControlFlow::Continue(()) + visit::walk_expr(self, e) } } diff --git a/tests/ui/fmt/nested-awaits-issue-122674.rs b/tests/ui/fmt/nested-awaits-issue-122674.rs new file mode 100644 index 00000000000..f250933dadb --- /dev/null +++ b/tests/ui/fmt/nested-awaits-issue-122674.rs @@ -0,0 +1,22 @@ +// Non-regression test for issue #122674: a change in the format args visitor missed nested awaits. + +//@ edition: 2021 +//@ check-pass + +pub fn f1() -> impl std::future::Future<Output = Result<(), String>> + Send { + async { + should_work().await?; + Ok(()) + } +} + +async fn should_work() -> Result<String, String> { + let x = 1; + Err(format!("test: {}: {}", x, inner().await?)) +} + +async fn inner() -> Result<String, String> { + Ok("test".to_string()) +} + +fn main() {} |
