fix inference in nested closure
This commit is contained in:
parent
fa3db447d7
commit
85f9235de8
@ -462,7 +462,7 @@ fn walk_expr_without_adjust(&mut self, tgt_expr: ExprId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn expr_ty(&mut self, expr: ExprId) -> Ty {
|
fn expr_ty(&mut self, expr: ExprId) -> Ty {
|
||||||
self.infer_expr_no_expect(expr)
|
self.result[expr].clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_upvar(&self, place: &HirPlace) -> bool {
|
fn is_upvar(&self, place: &HirPlace) -> bool {
|
||||||
|
@ -1067,6 +1067,23 @@ fn parse_arule() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn nested_closure() {
|
||||||
|
check_types(
|
||||||
|
r#"
|
||||||
|
//- minicore: fn, option
|
||||||
|
|
||||||
|
fn map<T, U>(o: Option<T>, f: impl FnOnce(T) -> U) -> Option<U> { loop {} }
|
||||||
|
|
||||||
|
fn test() {
|
||||||
|
let o = Some(Some(2));
|
||||||
|
map(o, |s| map(s, |x| x));
|
||||||
|
// ^ i32
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn call_expected_type_closure() {
|
fn call_expected_type_closure() {
|
||||||
check_types(
|
check_types(
|
||||||
|
Loading…
Reference in New Issue
Block a user