@@ -1790,9 +1790,9 @@ fn region_env() -> @region_env {
1790
1790
// Replaces all region parameters in the given type with region variables.
1791
1791
// This is used when typechecking function calls, bind expressions, and method
1792
1792
// calls.
1793
- fn universally_quantify_regions ( fcx : @fn_ctxt , renv : @region_env , ty : ty:: t )
1794
- -> ty:: t {
1793
+ fn universally_quantify_regions ( fcx : @fn_ctxt , ty : ty:: t ) -> ty:: t {
1795
1794
if ty:: type_has_rptrs ( ty) {
1795
+ let renv = region_env ( ) ;
1796
1796
ty:: fold_ty ( fcx. ccx . tcx , ty:: fm_rptr ( { |r, _under_rptr|
1797
1797
alt r {
1798
1798
ty : : re_param ( param_id) {
@@ -2301,12 +2301,10 @@ fn lookup_method_inner(fcx: @fn_ctxt, expr: @ast::expr,
2301
2301
self_ty = instantiate_self_regions ( fcx. ccx . tcx ,
2302
2302
ty:: re_param ( next_rid) ,
2303
2303
self_ty) ;
2304
- self_ty = universally_quantify_regions ( fcx, region_env ( ) ,
2305
- self_ty) ;
2304
+ self_ty = universally_quantify_regions ( fcx, self_ty) ;
2306
2305
2307
2306
// ... and "ty" refers to the caller side.
2308
- let ty = universally_quantify_regions ( fcx, region_env ( ) ,
2309
- ty) ;
2307
+ let ty = universally_quantify_regions ( fcx, ty) ;
2310
2308
2311
2309
alt unify:: unify ( fcx, self_ty, ty) {
2312
2310
result:: ok ( _) {
@@ -2440,9 +2438,11 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
2440
2438
2441
2439
// A generic function to factor out common logic from call and bind
2442
2440
// expressions.
2443
- fn check_call_or_bind ( fcx : @fn_ctxt , sp : span , fty : ty:: t ,
2444
- args : [ option < @ast:: expr > ] ) -> bool {
2441
+ fn check_call_or_bind (
2442
+ fcx : @fn_ctxt , sp : span , fty : ty:: t ,
2443
+ args : [ option < @ast:: expr > ] ) -> { fty : ty:: t , bot : bool } {
2445
2444
2445
+ let fty = universally_quantify_regions ( fcx, fty) ;
2446
2446
let sty = structure_of ( fcx, sp, fty) ;
2447
2447
// Grab the argument types
2448
2448
let mut arg_tys = alt sty {
@@ -2510,7 +2510,10 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
2510
2510
}
2511
2511
ret bot;
2512
2512
} ;
2513
- ret check_args( false ) | check_args ( true ) ;
2513
+
2514
+ let bot = check_args ( false ) | check_args ( true ) ;
2515
+
2516
+ { fty: fty, bot: bot}
2514
2517
}
2515
2518
2516
2519
// A generic function for checking assignment expressions
@@ -2532,11 +2535,11 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
2532
2535
2533
2536
let bot = check_expr ( fcx, f) ;
2534
2537
2535
- let mut fn_ty = fcx. expr_ty ( f) ;
2536
- fn_ty = universally_quantify_regions ( fcx, region_env ( ) , fn_ty) ;
2537
-
2538
2538
// Call the generic checker.
2539
- ret check_call_or_bind ( fcx, sp, fn_ty, args_opt_0) | bot;
2539
+ ret {
2540
+ let fn_ty = fcx. expr_ty ( f) ;
2541
+ check_call_or_bind ( fcx, sp, fn_ty, args_opt_0) . bot | bot
2542
+ } ;
2540
2543
}
2541
2544
2542
2545
// A generic function for doing all of the checking for call expressions
@@ -2612,10 +2615,10 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
2612
2615
let callee_id = ast_util:: op_expr_callee_id ( op_ex) ;
2613
2616
alt lookup_method ( fcx, op_ex, callee_id, opname, self_t, [ ] , false ) {
2614
2617
some ( origin) {
2615
- let method_ty = fcx . node_ty ( callee_id ) ;
2616
- let method_ty = universally_quantify_regions ( fcx, region_env ( ) ,
2617
- method_ty) ;
2618
- let bot = check_call_or_bind ( fcx , op_ex . span , method_ty , args ) ;
2618
+ let { fty : method_ty , bot : bot } = {
2619
+ let method_ty = fcx. node_ty ( callee_id ) ;
2620
+ check_call_or_bind ( fcx , op_ex . span , method_ty, args )
2621
+ } ;
2619
2622
fcx. ccx . method_map . insert ( op_ex. id , origin) ;
2620
2623
some ( ( ty:: ty_fn_ret ( method_ty) , bot) )
2621
2624
}
@@ -2834,18 +2837,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
2834
2837
let defn = lookup_def ( fcx, pth. span , id) ;
2835
2838
2836
2839
let tpt = ty_param_bounds_and_ty_for_def ( fcx, expr. span , defn) ;
2837
- if ty:: def_has_ty_params ( defn) {
2838
- instantiate_path ( fcx, pth, tpt, expr. span , expr. id ) ;
2839
- } else {
2840
- // The definition doesn't take type parameters. If the programmer
2841
- // supplied some, that's an error
2842
- if vec:: len :: < @ast:: ty > ( pth. node . types ) > 0 u {
2843
- tcx. sess . span_fatal ( expr. span ,
2844
- "this kind of value does not \
2845
- take type parameters") ;
2846
- }
2847
- fcx. write_ty ( id, tpt. ty ) ;
2848
- }
2840
+ instantiate_path ( fcx, pth, tpt, expr. span , expr. id ) ;
2849
2841
}
2850
2842
ast:: expr_mac ( _) { tcx. sess . bug ( "unexpanded macro" ) ; }
2851
2843
ast:: expr_fail ( expr_opt) {
@@ -3045,10 +3037,10 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
3045
3037
// Call the generic checker.
3046
3038
bot = check_expr ( fcx, f) ;
3047
3039
3048
- let mut fn_ty = fcx . expr_ty ( f ) ;
3049
- fn_ty = universally_quantify_regions ( fcx, region_env ( ) , fn_ty ) ;
3050
-
3051
- let ccob_bot = check_call_or_bind ( fcx , expr . span , fn_ty , args ) ;
3040
+ let ccob_bot = {
3041
+ let fn_ty = fcx. expr_ty ( f ) ;
3042
+ check_call_or_bind ( fcx , expr . span , fn_ty , args ) . bot
3043
+ } ;
3052
3044
bot |= ccob_bot;
3053
3045
3054
3046
// TODO: Perform substitutions on the return type.
0 commit comments