add regression test for closure return ICE

This commit is contained in:
Takayuki Maeda
2026-05-07 23:33:00 +09:00
parent 4ddb0b7f8e
commit ddddb4d109
2 changed files with 23 additions and 0 deletions
@@ -0,0 +1,8 @@
// Regression test for https://github.com/rust-lang/rust/issues/155893.
fn func(_f: impl Fn()) {
func(|| return 2)
//~^ ERROR mismatched types
}
fn main() {}
@@ -0,0 +1,15 @@
error[E0308]: mismatched types
--> $DIR/return-in-closure-with-fn-bound.rs:4:20
|
LL | func(|| return 2)
| ^ expected `()`, found integer
|
note: return type inferred to be `()` here
--> $DIR/return-in-closure-with-fn-bound.rs:4:20
|
LL | func(|| return 2)
| ^
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0308`.