Skip to content

Commit 5cff355

Browse files
committed
Add another test
1 parent 6f41053 commit 5cff355

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

crates/hir_ty/src/tests/regression.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,3 +1094,23 @@ fn parse_arule() {
10941094
"#,
10951095
)
10961096
}
1097+
1098+
#[test]
1099+
fn call_expected_type_closure() {
1100+
check_types(
1101+
r#"
1102+
//- minicore: fn, option
1103+
1104+
fn map<T, U>(o: Option<T>, f: impl FnOnce(T) -> U) -> Option<U> { loop {} }
1105+
struct S {
1106+
field: u32
1107+
}
1108+
1109+
fn test() {
1110+
let o = Some(S { field: 2 });
1111+
let _: Option<()> = map(o, |s| { s.field; });
1112+
// ^^^^^^^ u32
1113+
}
1114+
"#,
1115+
);
1116+
}

0 commit comments

Comments
 (0)