Change:
<!-- 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

Discussion:
let ty = self.lowerer().lower_ty(hir_ty); debug!(?ty, "return type (lowered)"); debug!(?expected, "expected type"); <del> let bound_vars = self.tcx.late_bound_vars(hir_ty.hir_id.owner.into()); </del> <ins> let bound_vars = self.tcx.late_bound_vars(self.tcx.local_def_id_to_hir_id(fn_id)); </ins> let ty = Binder::bind_with_vars(ty, bound_vars); let ty = self.normalize(hir_ty.span, ty); let ty = self.tcx.instantiate_bound_regions_with_erased(ty);

<del> //@ known-bug: rust-lang/rust#125655 fn main() { static foo: dyn Fn() -> u32 = || -> u32 { ... 0 }; } </del>

<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>

<ins> error[E0308]: mismatched types --> $DIR/closure-return-type-mismatch.rs:9:45 | LL |     let _ = for<'a> |x: &'a u8| -> &'a () { x }; |                                    ------   ^ expected `&()`, found `&u8` |                                    | |                                    expected `&'a ()` because of return type | = note: expected reference `&'a ()` found reference `&'a u8` error[E0308]: mismatched types --> $DIR/closure-return-type-mismatch.rs:14:45 | LL |     let _ = for<'a> |x: &'a u8| -> &'a () { x }; |                                    ------   ^ expected `&()`, found `&u8` |                                    | |                                    expected `&'a ()` because of return type | = note: expected reference `&'a ()` found reference `&'a u8` error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0308`. </ins>

b }; } <ins> // issue: rust-lang/rust#130858 rust-lang/rust#125655 static FOO: fn() -> bool = || -> bool { 1 }; //~^ ERROR mismatched types </ins>

error[E0308]: mismatched types <ins> --> $DIR/closure-return-type-mismatch.rs:20:41 | LL | static FOO: fn() -> bool = || -> bool { 1 }; |                                  ----   ^ expected `bool`, found integer |                                  | |                                  expected `bool` because of return type error[E0308]: mismatched types </ins> --> $DIR/closure-return-type-mismatch.rs:7:9 | LL |         a

LL |             return "hello" |                    ^^^^^^^ expected `bool`, found `&str` <del> error: aborting due to 2 previous errors </del> <ins> error: aborting due to 3 previous errors </ins> For more information about this error, try `rustc --explain E0308`.