Skip to content

fix: Panic in async closures with HRTB - #23409

Merged
ChayimFriedman2 merged 1 commit into
rust-lang:masterfrom
Wilfred:fix/async-closure-hrtb
Sep 23, 2026
Merged

ChayimFriedman2 merged 1 commit into
rust-lang:masterfrom
Wilfred:fix/async-closure-hrtb

Conversation

@Wilfred

@Wilfred Wilfred commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Previously, generating SCIP on the dolang-org/dolang GitHub repository would panic with:

panicked at crates/hir-ty/src/next_solver/infer/region_constraints/mod.rs:448:17:
cannot relate bound region: '^1 <= ReLateParam(FunctionId("run"), 1)

When rust-analyzer has debug assertions enabled, we'd get a different panic:

ra-ap-rustc_type_ir-0.166.0/src/relate/combine.rs:57:5:
assertion failed: !a.has_escaping_bound_vars()

Ensure that we don't have escaping bound vars by using the .liberate_late_bound_regions() helper rather than just calling .skip_binder(). This matches what rustc does:

https://github.com/rust-lang/rust/blob/a92214c92df8cc0261f5ab5c08c6376c2c03a958/compiler/rustc_hir_typeck/src/closure.rs#L251

AI disclosure: Code partly written by GPT-5 Sol, commit message and review by me.

Previously, generating SCIP on the `dolang-org/dolang` GitHub
repository would panic with:

    panicked at crates/hir-ty/src/next_solver/infer/region_constraints/mod.rs:448:17:
    cannot relate bound region: '^1 <= ReLateParam(FunctionId("run"), 1)

When rust-analyzer has debug assertions enabled, we'd get a different
panic:

    ra-ap-rustc_type_ir-0.166.0/src/relate/combine.rs:57:5:
    assertion failed: !a.has_escaping_bound_vars()

Ensure that we don't have escaping bound vars by using the
.liberate_late_bound_regions() helper rather than just calling
.skip_binder(). This matches what rustc does:

https://github.com/rust-lang/rust/blob/a92214c92df8cc0261f5ab5c08c6376c2c03a958/compiler/rustc_hir_typeck/src/closure.rs#L251

AI disclosure: Code partly written by GPT-5 Sol, commit message and
review by me.
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 23, 2026

@ChayimFriedman2 ChayimFriedman2 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ChayimFriedman2
ChayimFriedman2 added this pull request to the merge queue Sep 23, 2026
Merged via the queue into rust-lang:master with commit 5ed57a8 Sep 23, 2026
20 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 23, 2026
@Wilfred
Wilfred deleted the fix/async-closure-hrtb branch September 23, 2026 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants