From b58a7f41f14f56375c602911be768d40cf46de04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Sun, 5 Apr 2020 18:18:40 +0300 Subject: Fix inference of function pointer return types --- crates/ra_hir_ty/src/tests/simple.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'crates/ra_hir_ty') diff --git a/crates/ra_hir_ty/src/tests/simple.rs b/crates/ra_hir_ty/src/tests/simple.rs index a600b947d..141f0245a 100644 --- a/crates/ra_hir_ty/src/tests/simple.rs +++ b/crates/ra_hir_ty/src/tests/simple.rs @@ -1729,3 +1729,29 @@ fn foo() -> u32 { "### ); } + +#[test] +fn fn_pointer_return() { + assert_snapshot!( + infer(r#" +struct Vtable { + method: fn(), +} + +fn main() { + let vtable = Vtable { method: || {} }; + let m = vtable.method; +} +"#), + @r###" + [48; 121) '{ ...hod; }': () + [58; 64) 'vtable': Vtable + [67; 91) 'Vtable...| {} }': Vtable + [84; 89) '|| {}': || -> () + [87; 89) '{}': () + [101; 102) 'm': fn() -> () + [105; 111) 'vtable': Vtable + [105; 118) 'vtable.method': fn() -> () + "### + ); +} -- cgit v1.2.3