diff --git a/compiler/rustc_ast_lowering/src/format.rs b/compiler/rustc_ast_lowering/src/format.rs index 3f84e6b100d11..d2c3b8b2d5652 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 0000000000000..f250933dadb48 --- /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> + Send { + async { + should_work().await?; + Ok(()) + } +} + +async fn should_work() -> Result { + let x = 1; + Err(format!("test: {}: {}", x, inner().await?)) +} + +async fn inner() -> Result { + Ok("test".to_string()) +} + +fn main() {}