Add another test

This commit is contained in:
Florian Diebold 2021-08-05 20:32:07 +02:00
parent 6f41053ede
commit 5cff355059

View file

@ -1094,3 +1094,23 @@ fn parse_arule() {
"#, "#,
) )
} }
#[test]
fn call_expected_type_closure() {
check_types(
r#"
//- minicore: fn, option
fn map<T, U>(o: Option<T>, f: impl FnOnce(T) -> U) -> Option<U> { loop {} }
struct S {
field: u32
}
fn test() {
let o = Some(S { field: 2 });
let _: Option<()> = map(o, |s| { s.field; });
// ^^^^^^^ u32
}
"#,
);
}