Skip to content

Commit 72e2c7c

Browse files
authored
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.
2 parents 1ac0239 + f3e9dfa commit 72e2c7c

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

Diff for: compiler/rustc_ast_lowering/src/format.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -604,8 +604,7 @@ fn may_contain_yield_point(e: &ast::Expr) -> bool {
604604
if let ast::ExprKind::Await(_, _) | ast::ExprKind::Yield(_) = e.kind {
605605
ControlFlow::Break(())
606606
} else {
607-
visit::walk_expr(self, e);
608-
ControlFlow::Continue(())
607+
visit::walk_expr(self, e)
609608
}
610609
}
611610

Diff for: tests/ui/fmt/nested-awaits-issue-122674.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Non-regression test for issue #122674: a change in the format args visitor missed nested awaits.
2+
3+
//@ edition: 2021
4+
//@ check-pass
5+
6+
pub fn f1() -> impl std::future::Future<Output = Result<(), String>> + Send {
7+
async {
8+
should_work().await?;
9+
Ok(())
10+
}
11+
}
12+
13+
async fn should_work() -> Result<String, String> {
14+
let x = 1;
15+
Err(format!("test: {}: {}", x, inner().await?))
16+
}
17+
18+
async fn inner() -> Result<String, String> {
19+
Ok("test".to_string())
20+
}
21+
22+
fn main() {}

0 commit comments

Comments
 (0)