@@ -2141,6 +2141,11 @@ fn check_expr_fn_with_unifier(fcx: @fn_ctxt,
2141
2141
check_fn ( fcx. ccx , proto, decl, body, expr. id , some ( fcx) ) ;
2142
2142
}
2143
2143
2144
+ type check_call_or_bind_result = {
2145
+ bot : bool ,
2146
+ rb : @ty:: unify:: region_bindings
2147
+ } ;
2148
+
2144
2149
fn check_expr_with_unifier ( fcx : @fn_ctxt , expr : @ast:: expr , unify : unifier ,
2145
2150
expected : ty:: t ) -> bool {
2146
2151
@@ -2150,7 +2155,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
2150
2155
// A generic function to factor out common logic from call and bind
2151
2156
// expressions.
2152
2157
fn check_call_or_bind ( fcx : @fn_ctxt , sp : span , id : ast:: node_id ,
2153
- fty : ty:: t , args : [ option < @ast:: expr > ] ) -> bool {
2158
+ fty : ty:: t , args : [ option < @ast:: expr > ] )
2159
+ -> check_call_or_bind_result {
2154
2160
// Replaces "caller" regions in the arguments with the local region.
2155
2161
fn instantiate_caller_regions ( fcx : @fn_ctxt , id : ast:: node_id ,
2156
2162
args : [ ty:: arg ] ) -> [ ty:: arg ] {
@@ -2185,6 +2191,9 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
2185
2191
} ;
2186
2192
}
2187
2193
2194
+ let rb = ty:: unify:: mk_region_bindings ( ) ;
2195
+ let unifier = bind demand:: with_region_bindings ( _, _, rb, _, _) ;
2196
+
2188
2197
let sty = structure_of ( fcx, sp, fty) ;
2189
2198
// Grab the argument types
2190
2199
let arg_tys = alt sty {
@@ -2222,6 +2231,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
2222
2231
arg_tys = vec:: from_elem ( supplied_arg_count, dummy) ;
2223
2232
}
2224
2233
2234
+ // FIXME: This should instantiate re_params instead.
2225
2235
arg_tys = instantiate_caller_regions ( fcx, id, arg_tys) ;
2226
2236
2227
2237
// Check the arguments.
@@ -2241,8 +2251,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
2241
2251
_ { false }
2242
2252
} ;
2243
2253
if is_block == check_blocks {
2244
- bot |= check_expr_with_unifier (
2245
- fcx, a, demand :: simple , arg_tys [ i ] . ty ) ;
2254
+ let t = arg_tys [ i ] . ty ;
2255
+ bot |= check_expr_with_unifier ( fcx, a, unifier , t ) ;
2246
2256
}
2247
2257
}
2248
2258
none { }
@@ -2251,7 +2261,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
2251
2261
}
2252
2262
ret bot;
2253
2263
} ;
2254
- check_args ( false ) | check_args ( true )
2264
+ let bot = check_args ( false ) | check_args ( true ) ;
2265
+ ret { bot : bot, rb : rb } ;
2255
2266
}
2256
2267
2257
2268
// A generic function for checking assignment expressions
@@ -2272,10 +2283,15 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
2272
2283
args_opt_0 += [ some :: < @ast:: expr > ( arg) ] ;
2273
2284
}
2274
2285
2275
- let bot = check_expr ( fcx, f) ;
2286
+ let mut bot = check_expr ( fcx, f) ;
2276
2287
// Call the generic checker.
2277
- bot | check_call_or_bind ( fcx, sp, id, expr_ty ( fcx. ccx . tcx , f) ,
2278
- args_opt_0)
2288
+ let ccobr = check_call_or_bind ( fcx, sp, id, expr_ty ( fcx. ccx . tcx , f) ,
2289
+ args_opt_0) ;
2290
+ bot |= ccobr. bot ;
2291
+
2292
+ // TODO: Munge return type.
2293
+
2294
+ ret bot;
2279
2295
}
2280
2296
2281
2297
// A generic function for doing all of the checking for call expressions
@@ -2690,8 +2706,11 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
2690
2706
ast:: expr_bind ( f, args) {
2691
2707
// Call the generic checker.
2692
2708
bot = check_expr ( fcx, f) ;
2693
- bot |= check_call_or_bind ( fcx, expr. span , expr. id , expr_ty ( tcx, f) ,
2694
- args) ;
2709
+ let ccobr = check_call_or_bind ( fcx, expr. span , expr. id ,
2710
+ expr_ty ( tcx, f) , args) ;
2711
+ bot |= ccobr. bot ;
2712
+
2713
+ // TODO: Perform substitutions on the return type.
2695
2714
2696
2715
// Pull the argument and return types out.
2697
2716
let proto, arg_tys, rt, cf, constrs;
0 commit comments