@@ -1512,6 +1512,10 @@ fn check_expr_fn_with_unifier(fcx: @fn_ctxt,
1512
1512
let fty = ty_of_fn_decl ( tcx, m_check_tyvar ( fcx) , decl,
1513
1513
proto, [ ] , none) . ty ;
1514
1514
1515
+ log #fmt( "check_expr_fn_with_unifier %s fty=%s" ,
1516
+ expr_to_str ( expr) ,
1517
+ ty_to_str ( tcx, fty) ) ;
1518
+
1515
1519
write:: ty_only_fixup ( fcx, expr. id , fty) ;
1516
1520
1517
1521
// Unify the type of the function with the expected type before we
@@ -1521,9 +1525,6 @@ fn check_expr_fn_with_unifier(fcx: @fn_ctxt,
1521
1525
unify ( fcx, expr. span , expected, fty) ;
1522
1526
1523
1527
check_fn1 ( fcx. ccx , decl, proto, body, expr. id , some ( fcx) ) ;
1524
- if proto == ast:: proto_block {
1525
- write:: ty_only_fixup ( fcx, expr. id , expected) ;
1526
- }
1527
1528
}
1528
1529
1529
1530
fn check_expr_with_unifier ( fcx : @fn_ctxt , expr : @ast:: expr , unify : unifier ,
@@ -1979,11 +1980,20 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
1979
1980
// Take the prototype from the expected type, but default to block:
1980
1981
let proto = alt ty:: struct ( tcx, expected) {
1981
1982
ty:: ty_fn ( proto, _, _, _, _) { proto }
1982
- _ { ast : : proto_block }
1983
+ _ {
1984
+ fcx. ccx . tcx . sess . span_warn (
1985
+ expr. span ,
1986
+ "unable to infer kind of closure, defaulting to block" ) ;
1987
+ ast:: proto_block
1988
+ }
1983
1989
} ;
1990
+ log #fmt( "checking expr_fn_block %s expected=%s" ,
1991
+ expr_to_str ( expr) ,
1992
+ ty_to_str ( tcx, expected) ) ;
1984
1993
check_expr_fn_with_unifier ( fcx, expr, decl,
1985
1994
proto, body,
1986
1995
unify, expected) ;
1996
+ write:: ty_only_fixup ( fcx, id, expected) ;
1987
1997
}
1988
1998
ast:: expr_block ( b) {
1989
1999
// If this is an unchecked block, turn off purity-checking
0 commit comments