Commit ec00000
authored
Rollup merge of #156266 - swjng:fix/async-closure-coroutine-captures-infer-ice, r=lcnr
Don't ICE in has_self_borrows when coroutine captures-by-ref ty is still inferred
Closes rust-lang/rust#155999.
`coroutine_captures_by_ref_ty` is a fresh `next_ty_var` until upvar
inference unifies it to an `FnPtr`. If `has_self_borrows` is reached
before that — e.g. when the body contains an unresolved `as _` cast —
the `_ => panic!()` arm fires:
```rust
//@ edition:2021
fn needs_fn_mut<T>(x: impl FnMut() -> T) {
needs_fn_mut(async || x as _)
}
```
Treat the `Infer` case like `Error`: report self-borrows defensively
so the closure falls back to `FnOnce`-only and the caller surfaces a
normal type-inference error instead of an ICE.0 file changed
0 commit comments