@@ -86,8 +86,6 @@ type fn_ctxt =
86
86
proto : ast:: proto ,
87
87
infcx : infer:: infer_ctxt ,
88
88
locals : hashmap < ast:: node_id , ty_vid > ,
89
- ty_var_counter : @mut uint ,
90
- region_var_counter : @mut uint ,
91
89
92
90
mut blocks : [ ast:: node_id ] , // stack of blocks in scope, may be empty
93
91
in_scope_regions : isr_alist,
@@ -181,13 +179,11 @@ fn check_fn(ccx: @crate_ctxt,
181
179
// Create the function context. This is either derived from scratch or,
182
180
// in the case of function expressions, based on the outer context.
183
181
let fcx: @fn_ctxt = {
184
- let { infcx, locals, tvc , rvc , purity ,
185
- node_types , node_type_substs } = alt old_fcx {
182
+ let { infcx, locals, purity , node_types , node_type_substs } =
183
+ alt old_fcx {
186
184
none {
187
185
{ infcx : infer:: new_infer_ctxt ( tcx) ,
188
186
locals : int_hash ( ) ,
189
- tvc : @mut 0 u,
190
- rvc : @mut 0 u,
191
187
purity : decl. purity ,
192
188
node_types : smallintmap:: mk ( ) ,
193
189
node_type_substs : map:: int_hash ( ) }
@@ -196,8 +192,6 @@ fn check_fn(ccx: @crate_ctxt,
196
192
assert decl. purity == ast:: impure_fn;
197
193
{ infcx: fcx. infcx ,
198
194
locals: fcx. locals ,
199
- tvc: fcx. ty_var_counter ,
200
- rvc: fcx. region_var_counter ,
201
195
purity: fcx. purity ,
202
196
node_types: fcx. node_types ,
203
197
node_type_substs: fcx. node_type_substs }
@@ -219,8 +213,6 @@ fn check_fn(ccx: @crate_ctxt,
219
213
proto: proto,
220
214
infcx: infcx,
221
215
locals: locals,
222
- ty_var_counter: tvc,
223
- region_var_counter: rvc,
224
216
mut blocks: [ ] ,
225
217
in_scope_regions: isr,
226
218
node_types: node_types,
@@ -265,7 +257,7 @@ fn check_fn(ccx: @crate_ctxt,
265
257
let tcx = fcx. ccx . tcx ;
266
258
267
259
let assign = fn @( nid: ast:: node_id, ty_opt: option<ty:: t>) {
268
- let var_id = fcx. next_ty_var_id ( ) ;
260
+ let var_id = fcx. infcx . next_ty_var_id ( ) ;
269
261
fcx. locals . insert ( nid, var_id) ;
270
262
alt ty_opt {
271
263
none { /* nothing to do */ }
@@ -429,13 +421,13 @@ impl of ast_conv for @fn_ctxt {
429
421
}
430
422
431
423
fn ty_infer ( _span : span ) -> ty:: t {
432
- self . next_ty_var ( )
424
+ self . infcx . next_ty_var ( )
433
425
}
434
426
}
435
427
436
428
impl of region_scope for @fn_ctxt {
437
429
fn anon_region ( ) -> result < ty:: region , str > {
438
- result:: ok ( self . next_region_var ( ) )
430
+ result:: ok ( self . infcx . next_region_var ( ) )
439
431
}
440
432
fn named_region ( id : str ) -> result < ty:: region , str > {
441
433
empty_rscope. named_region ( id) . chain_err { |_e|
@@ -522,25 +514,6 @@ impl methods for @fn_ctxt {
522
514
fn opt_node_ty_substs ( id : ast:: node_id ) -> option < ty:: substs > {
523
515
self . node_type_substs . find ( id)
524
516
}
525
- fn next_ty_var_id ( ) -> ty_vid {
526
- let id = * self . ty_var_counter ;
527
- * self . ty_var_counter += 1 u;
528
- ret ty_vid( id) ;
529
- }
530
- fn next_ty_var ( ) -> ty:: t {
531
- ty:: mk_var ( self . ccx . tcx , self . next_ty_var_id ( ) )
532
- }
533
- fn next_ty_vars ( n : uint ) -> [ ty:: t ] {
534
- vec:: from_fn ( n) { |_i| self . next_ty_var ( ) }
535
- }
536
- fn next_region_var_id ( ) -> region_vid {
537
- let id = * self . region_var_counter ;
538
- * self . region_var_counter += 1 u;
539
- ret region_vid( id) ;
540
- }
541
- fn next_region_var ( ) -> ty:: region {
542
- ret ty:: re_var ( self . next_region_var_id ( ) ) ;
543
- }
544
517
545
518
fn report_mismatched_types ( sp : span , e : ty:: t , a : ty:: t ,
546
519
err : ty:: type_err ) {
@@ -691,7 +664,7 @@ fn impl_self_ty(fcx: @fn_ctxt, did: ast::def_id) -> ty_param_substs_and_ty {
691
664
rp: rp,
692
665
raw_ty: ty:: mk_class ( tcx, local_def ( class_id) ,
693
666
{ self_r: alt rp {
694
- ast : : rp_self { some( fcx. next_region_var ( ) ) }
667
+ ast : : rp_self { some( fcx. infcx . next_region_var ( ) ) }
695
668
ast:: rp_none { none } } ,
696
669
self_ty: none,
697
670
tps: ty:: ty_params_to_tys ( tcx, ts) } ) }
@@ -708,9 +681,9 @@ fn impl_self_ty(fcx: @fn_ctxt, did: ast::def_id) -> ty_param_substs_and_ty {
708
681
709
682
let self_r = alt rp {
710
683
ast : : rp_none { none }
711
- ast:: rp_self { some( fcx. next_region_var ( ) ) }
684
+ ast:: rp_self { some( fcx. infcx . next_region_var ( ) ) }
712
685
} ;
713
- let tps = fcx. next_ty_vars ( n_tps) ;
686
+ let tps = fcx. infcx . next_ty_vars ( n_tps) ;
714
687
715
688
let substs = { self_r: self_r, self_ty: none, tps: tps} ;
716
689
let substd_ty = ty:: subst ( tcx, substs, raw_ty) ;
@@ -772,7 +745,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
772
745
} else {
773
746
"s were"
774
747
} ] ) ;
775
- fcx. next_ty_vars ( supplied_arg_count)
748
+ fcx. infcx . next_ty_vars ( supplied_arg_count)
776
749
}
777
750
}
778
751
@@ -875,7 +848,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
875
848
let ( if_t, if_bot) =
876
849
alt elsopt {
877
850
some( els) {
878
- let if_t = fcx. next_ty_var ( ) ;
851
+ let if_t = fcx. infcx . next_ty_var ( ) ;
879
852
let thn_bot = check_block ( fcx, thn) ;
880
853
let thn_t = fcx. node_ty ( thn. node . id ) ;
881
854
demand:: suptype ( fcx, thn. span , if_t, thn_t) ;
@@ -938,7 +911,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
938
911
// result [ML T] where TL <: T and TR <: T. In other words, the
939
912
// result type is (generally) the LUB of (TL, TR) and takes the
940
913
// mutability from the LHS.
941
- let t_var = fcx. next_ty_var ( ) ;
914
+ let t_var = fcx. infcx . next_ty_var ( ) ;
942
915
let const_vec_t = ty:: mk_vec ( tcx, { ty: t_var,
943
916
mutbl: ast:: m_const} ) ;
944
917
demand:: suptype ( fcx, lhs. span , const_vec_t, lhs_t) ;
@@ -960,7 +933,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
960
933
}
961
934
962
935
( _, _) if ty:: is_binopable ( tcx, lhs_t, op) {
963
- let tvar = fcx. next_ty_var ( ) ;
936
+ let tvar = fcx. infcx . next_ty_var ( ) ;
964
937
demand:: suptype ( fcx, expr. span , tvar, lhs_t) ;
965
938
let rhs_bot = check_expr_with ( fcx, rhs, tvar) ;
966
939
let rhs_t = alt op {
@@ -1087,7 +1060,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
1087
1060
}
1088
1061
ast:: expr_vec ( args, mutbl) {
1089
1062
let tt = ast_expr_vstore_to_vstore ( fcx, ev, vec:: len ( args) , vst) ;
1090
- let t: ty:: t = fcx. next_ty_var ( ) ;
1063
+ let t: ty:: t = fcx. infcx . next_ty_var ( ) ;
1091
1064
for args. each { |e| bot |= check_expr_with( fcx, e, t) ; }
1092
1065
ty:: mk_evec ( tcx, { ty: t, mutbl: mutbl} , tt)
1093
1066
}
@@ -1117,7 +1090,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
1117
1090
ast:: expr_binary ( ast:: gt, lhs, rhs) |
1118
1091
ast:: expr_binary ( ast:: ge, lhs, rhs) {
1119
1092
let tcx = fcx. ccx . tcx ;
1120
- let tvar = fcx. next_ty_var ( ) ;
1093
+ let tvar = fcx. infcx . next_ty_var ( ) ;
1121
1094
bot |= check_expr_with ( fcx, lhs, tvar) ;
1122
1095
bot |= check_expr_with ( fcx, rhs, tvar) ;
1123
1096
fcx. write_ty ( id, ty:: mk_bool ( tcx) ) ;
@@ -1463,7 +1436,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
1463
1436
fcx. write_ty ( id, t_1) ;
1464
1437
}
1465
1438
ast:: expr_vec ( args, mutbl) {
1466
- let t: ty:: t = fcx. next_ty_var ( ) ;
1439
+ let t: ty:: t = fcx. infcx . next_ty_var ( ) ;
1467
1440
for args. each { |e| bot |= check_expr_with( fcx, e, t) ; }
1468
1441
let typ = ty:: mk_vec ( tcx, { ty: t, mutbl: mutbl} ) ;
1469
1442
fcx. write_ty ( id, typ) ;
@@ -1608,7 +1581,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
1608
1581
field, ty_to_str ( tcx, t_err) ] ;
1609
1582
tcx. sess . span_err ( expr. span , msg) ;
1610
1583
// NB: Adding a bogus type to allow typechecking to continue
1611
- fcx. write_ty ( id, fcx. next_ty_var ( ) ) ;
1584
+ fcx. write_ty ( id, fcx. infcx . next_ty_var ( ) ) ;
1612
1585
}
1613
1586
}
1614
1587
}
@@ -1836,8 +1809,6 @@ fn check_const(ccx: @crate_ctxt, _sp: span, e: @ast::expr, id: ast::node_id) {
1836
1809
proto: ast:: proto_box,
1837
1810
infcx: infer:: new_infer_ctxt ( ccx. tcx ) ,
1838
1811
locals: int_hash ( ) ,
1839
- ty_var_counter: @mut 0 u,
1840
- region_var_counter: @mut 0 u,
1841
1812
mut blocks: [ ] ,
1842
1813
in_scope_regions: @nil,
1843
1814
node_types: smallintmap:: mk ( ) ,
@@ -1878,8 +1849,6 @@ fn check_enum_variants(ccx: @crate_ctxt,
1878
1849
proto: ast:: proto_box,
1879
1850
infcx: infer:: new_infer_ctxt ( ccx. tcx ) ,
1880
1851
locals: int_hash ( ) ,
1881
- ty_var_counter: @mut 0 u,
1882
- region_var_counter: @mut 0 u,
1883
1852
mut blocks: [ ] ,
1884
1853
in_scope_regions: @nil,
1885
1854
node_types: smallintmap:: mk ( ) ,
@@ -2148,24 +2117,24 @@ fn instantiate_path(fcx: @fn_ctxt,
2148
2117
// For now, there is no way to explicitly specify the region bound.
2149
2118
// This will have to change eventually.
2150
2119
let self_r = alt tpt. rp {
2151
- ast:: rp_self { some( fcx. next_region_var ( ) ) }
2120
+ ast:: rp_self { some( fcx. infcx . next_region_var ( ) ) }
2152
2121
ast:: rp_none { none }
2153
2122
} ;
2154
2123
2155
2124
let tps = if ty_substs_len == 0 u {
2156
- fcx. next_ty_vars ( ty_param_count)
2125
+ fcx. infcx . next_ty_vars ( ty_param_count)
2157
2126
} else if ty_param_count == 0 u {
2158
2127
fcx. ccx . tcx . sess . span_err
2159
2128
( sp, "this item does not take type parameters" ) ;
2160
- fcx. next_ty_vars ( ty_param_count)
2129
+ fcx. infcx . next_ty_vars ( ty_param_count)
2161
2130
} else if ty_substs_len > ty_param_count {
2162
2131
fcx. ccx. tcx. sess. span_err
2163
2132
( sp, "too many type parameters provided for this item" ) ;
2164
- fcx. next_ty_vars( ty_param_count)
2133
+ fcx. infcx . next_ty_vars( ty_param_count)
2165
2134
} else if ty_substs_len < ty_param_count {
2166
2135
fcx. ccx . tcx . sess . span_err
2167
2136
( sp, "not enough type parameters provided for this item" ) ;
2168
- fcx. next_ty_vars ( ty_param_count)
2137
+ fcx. infcx . next_ty_vars ( ty_param_count)
2169
2138
} else {
2170
2139
pth. types . map { |aty| fcx. to_ty ( aty) }
2171
2140
} ;
0 commit comments