From 5cff35505974ac91efb13d17866d3a80c498b972 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Thu, 5 Aug 2021 20:32:07 +0200 Subject: [PATCH] Add another test --- crates/hir_ty/src/tests/regression.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/crates/hir_ty/src/tests/regression.rs b/crates/hir_ty/src/tests/regression.rs index 2574dfca320..1919b1fc700 100644 --- a/crates/hir_ty/src/tests/regression.rs +++ b/crates/hir_ty/src/tests/regression.rs @@ -1094,3 +1094,23 @@ fn parse_arule() { "#, ) } + +#[test] +fn call_expected_type_closure() { + check_types( + r#" +//- minicore: fn, option + +fn map(o: Option, f: impl FnOnce(T) -> U) -> Option { loop {} } +struct S { + field: u32 +} + +fn test() { + let o = Some(S { field: 2 }); + let _: Option<()> = map(o, |s| { s.field; }); + // ^^^^^^^ u32 +} + "#, + ); +}