Fix type-inference regression in #112225
The type inference of argument-position closures and async blocks regressed in 1.70 as the evaluation order of async blocks changed, as they are not implicitly wrapped in an identity-function anymore. Fixes #112225 by making sure the evaluation order stays the same as it used to.
This commit is contained in:
parent
9eee230cd0
commit
75b557a2c4
4 changed files with 65 additions and 1 deletions
|
@ -362,7 +362,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
continue;
|
||||
}
|
||||
|
||||
let is_closure = matches!(arg.kind, ExprKind::Closure { .. });
|
||||
// For this check, we do *not* want to treat async generator closures (async blocks)
|
||||
// as proper closures. Doing so would regress type inference when feeding
|
||||
// the return value of an argument-position async block to an argument-position
|
||||
// closure wrapped in a block.
|
||||
// See <https://github.com/rust-lang/rust/issues/112225>.
|
||||
let is_closure = if let ExprKind::Closure(closure) = arg.kind {
|
||||
!tcx.generator_is_async(closure.def_id.to_def_id())
|
||||
} else {
|
||||
false
|
||||
};
|
||||
if is_closure != check_closures {
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue