Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/tests/simple.rs')
| -rw-r--r-- | crates/hir-ty/src/tests/simple.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/crates/hir-ty/src/tests/simple.rs b/crates/hir-ty/src/tests/simple.rs index 2e107b2c59..db557b7507 100644 --- a/crates/hir-ty/src/tests/simple.rs +++ b/crates/hir-ty/src/tests/simple.rs @@ -1,5 +1,7 @@ use expect_test::expect; +use crate::tests::check_infer_with_mismatches; + use super::{check, check_infer, check_no_mismatches, check_types}; #[test] @@ -3956,3 +3958,24 @@ fn bar() { "#, ); } + +#[test] +fn cannot_coerce_capturing_closure_to_fn_ptr() { + check_infer_with_mismatches( + r#" +fn foo() { + let a = 1; + let _: fn() -> i32 = || a; +} + "#, + expect![[r#" + 9..58 '{ ...| a; }': () + 19..20 'a': i32 + 23..24 '1': i32 + 34..35 '_': fn() -> i32 + 51..55 '|| a': impl Fn() -> i32 + 54..55 'a': i32 + 51..55: expected fn() -> i32, got impl Fn() -> i32 + "#]], + ); +} |