Change:
<ins> // We used to bind the closure return type `&'a ()` with the late-bound vars of // the owner (here `main` & `env` resp.) instead of the ones of the enclosing // function-like / closure inside diagnostic code which was incorrect. #![feature(closure_lifetime_binder)] // issue: rust-lang/rust#130391 fn main() { let _ = for<'a> |x: &'a u8| -> &'a () { x }; //~ ERROR mismatched types } // issue: rust-lang/rust#130663 fn env<'r>() { let _ = for<'a> |x: &'a u8| -> &'a () { x }; //~ ERROR mismatched types } </ins>

Discussion:
<!-- Thank you for finding an Internal Compiler Error! If possible, try to provide a minimal verifiable example. You can read "Rust Bug Minimization Patterns" for how to create smaller examples. --This is a pretty minor ICE that I can only reproduce in code that shouldn't compile anyway. If I specify the wrong return type for a closure used in a static item, I get an ICE instead of a normal build error. Possibly related to Add this to any : <!-- If you're using the stable version of the compiler, you should also check if the bug also exists in the beta or nightly versions. --: I can also reproduce this on latest nightly ( I believe, ran it with ). <!-- Include a backtrace in the code block by setting in your environment. E.g. . --<details<summary<strongBacktrace</strong</summary<p</p</details
Reduced:

<!-- ICE: Rustc '-Zincremental-verify-ich=yes -Cincremental=<dir-Cdebuginfo=2 -Clink-dead-code=true -Zvalidate-mir --edition=2021' 'assertion failed ' left: BrNamed(DefId(0:5 ~ a[221d]::hello::{closure}::'a), 'a)' ' right: BrNamed(DefId(0:11 ~ a[221d]::hello::'), ')'', 'assertion failed ' left: BrNamed(DefId(0:5 ~ a[221d]::hello::{closure}::'a), 'a)' ' right: BrNamed(DefId(0:11 ~ a[221d]::hello::'), ')'' File: /home/gh- --auto-reduced (treereduce-rust): original: Version information ` <!-- query stack: note: compiler flags: -Z incremental-verify-ich=yes -C incremental=[REDACTED] -C debuginfo=2 -C link-dead-code=true -Z validate-mir [typeck] type-checking [analysis] running analysis passes on this crate --
Command: <!-- Include a backtrace in the code block by setting in your environment. E.g. . --<details<summary<strongProgram output</strong</summary<p</p</details
This has nothing to do with async closures?
I'm sensing a notable lack of the keyword anywhere in this example... label: -F-async_closure

<!-- ICE: Rustc '' 'thread 'rustc' panicked at /home/gh- 'Not enough bound vars: '^0.Named(DefId(0:23 ~ ice[faee]::main::{closure}::'a), "'a") not found in []'', 'thread 'rustc' panicked at /home/gh- 'Not enough bound vars: '^0.Named(DefId(0:23 ~ ice[faee]::main::{closure}::'a), "'a") not found in []'' File: /home/gh- --auto-reduced (treereduce-rust): &lt;details&lt;summary&lt;strongoriginal code&lt;/strong&lt;/summary&lt;poriginal: </p</detailsVersion information ` <!-- query stack: [typeck] type-checking [analysis] running analysis passes on this crate -- label +F-closurelifetimebinder
Command: <!-- Include a backtrace in the code block by setting in your environment. E.g. . --<details<summary<strongProgram output</strong</summary<p</p</details

<!-- Thank you for finding an Internal Compiler Error! If possible, try to provide a minimal verifiable example. You can read "Rust Bug Minimization Patterns" for how to create smaller examples. --<!-- If you're using the stable version of the compiler, you should also check if the bug also exists in the beta or nightly versions. --: <!-- Include a backtrace in the code block by setting in your environment. E.g. . --<details<summary<strongBacktrace</strong</summary<p</p</details