Commit 0cc1ef4
committed
Don't ICE in has_self_borrows when coroutine captures-by-ref ty is still inferred
`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.
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.
Closes #155999.1 parent ba1a955 commit 0cc1ef4
3 files changed
Lines changed: 22 additions & 1 deletion
File tree
- compiler/rustc_type_ir/src/ty_kind
- tests/ui/async-await/async-closures
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
322 | 322 | | |
323 | 323 | | |
324 | 324 | | |
325 | | - | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
326 | 328 | | |
327 | 329 | | |
328 | 330 | | |
| |||
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
0 commit comments