mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 15:01:51 +00:00
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.
This commit is contained in:
commit
72e2c7c45a
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
22
tests/ui/fmt/nested-awaits-issue-122674.rs
Normal file
22
tests/ui/fmt/nested-awaits-issue-122674.rs
Normal file
@ -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() {}
|
Loading…
Reference in New Issue
Block a user