@@ -275,6 +275,11 @@ type vals_and_bindings<V:copy, T:copy> = {
275
275
mut bindings : [ ( V , var_value < V , T > ) ]
276
276
} ;
277
277
278
+ enum node < V : copy , T : copy > = {
279
+ root: V ,
280
+ possible_types: T ,
281
+ } ;
282
+
278
283
enum infer_ctxt = @{
279
284
tcx: ty:: ctxt,
280
285
@@ -639,7 +644,7 @@ impl unify_methods for infer_ctxt {
639
644
640
645
fn get < V : copy vid, T : copy > (
641
646
vb : vals_and_bindings < V , T > , vid : V )
642
- -> { root : V , possible_types : T } {
647
+ -> node < V , T > {
643
648
644
649
alt vb. vals . find ( vid. to_uint ( ) ) {
645
650
none {
@@ -649,15 +654,15 @@ impl unify_methods for infer_ctxt {
649
654
some ( var_val) {
650
655
alt var_val {
651
656
redirect( vid) {
652
- let { root : rt , possible_types : pt } = self . get ( vb, vid) ;
653
- if rt != vid {
657
+ let nde = self . get ( vb, vid) ;
658
+ if nde . root != vid {
654
659
// Path compression
655
- vb. vals . insert ( vid. to_uint ( ) , redirect ( rt ) ) ;
660
+ vb. vals . insert ( vid. to_uint ( ) , redirect ( nde . root ) ) ;
656
661
}
657
- { root : rt , possible_types : pt }
662
+ nde
658
663
}
659
664
root ( pt) {
660
- { root: vid, possible_types: pt}
665
+ node ( { root: vid, possible_types: pt} )
661
666
}
662
667
}
663
668
}
@@ -771,8 +776,12 @@ impl unify_methods for infer_ctxt {
771
776
a_id: V , b_id: V ) -> ures {
772
777
773
778
// Need to make sub_id a subtype of sup_id.
774
- let { root: a_id, possible_types: a_bounds} = self . get( vb, a_id) ;
775
- let { root: b_id, possible_types: b_bounds} = self . get( vb, b_id) ;
779
+ let nde_a = self . get( vb, a_id) ;
780
+ let nde_b = self . get( vb, b_id) ;
781
+ let a_id = nde_a. root;
782
+ let b_id = nde_b. root;
783
+ let a_bounds = nde_a. possible_types;
784
+ let b_bounds = nde_b. possible_types;
776
785
777
786
#debug[ "vars( %s=%s <: %s=%s) ",
778
787
a_id. to_str( ) , a_bounds. to_str( self ) ,
@@ -809,8 +818,12 @@ impl unify_methods for infer_ctxt {
809
818
vb : vals_and_bindings < V , int_ty_set > ,
810
819
a_id : V , b_id : V ) -> ures {
811
820
812
- let { root: a_id , possible_types : a_pt } = self . get ( vb, a_id) ;
813
- let { root: b_id , possible_types : b_pt } = self . get ( vb, b_id) ;
821
+ let nde_a = self . get ( vb, a_id) ;
822
+ let nde_b = self . get ( vb, b_id) ;
823
+ let a_id = nde_a. root ;
824
+ let b_id = nde_b. root ;
825
+ let a_pt = nde_a. possible_types ;
826
+ let b_pt = nde_b. possible_types ;
814
827
815
828
// If we're already dealing with the same two variables,
816
829
// there's nothing to do.
@@ -831,7 +844,10 @@ impl unify_methods for infer_ctxt {
831
844
vb : vals_and_bindings < V , bounds < T > > ,
832
845
a_id : V , b : T ) -> ures {
833
846
834
- let { root: a_id , possible_types : a_bounds } = self . get ( vb, a_id) ;
847
+ let nde_a = self . get ( vb, a_id) ;
848
+ let a_id = nde_a. root ;
849
+ let a_bounds = nde_a. possible_types ;
850
+
835
851
#debug[ "vart(%s=%s <: %s)" ,
836
852
a_id. to_str ( ) , a_bounds. to_str ( self ) ,
837
853
b. to_str ( self ) ] ;
@@ -845,7 +861,9 @@ impl unify_methods for infer_ctxt {
845
861
846
862
assert ty:: type_is_integral ( b) ;
847
863
848
- let { root: a_id , possible_types : a_pt } = self . get ( vb, a_id) ;
864
+ let nde_a = self . get ( vb, a_id) ;
865
+ let a_id = nde_a. root ;
866
+ let a_pt = nde_a. possible_types ;
849
867
850
868
let intersection =
851
869
intersection ( a_pt, convert_integral_ty_to_int_ty_set (
@@ -862,7 +880,10 @@ impl unify_methods for infer_ctxt {
862
880
a : T , b_id : V ) -> ures {
863
881
864
882
let a_bounds = { lb: some ( a) , ub: none} ;
865
- let { root: b_id , possible_types : b_bounds } = self . get ( vb, b_id) ;
883
+ let nde_b = self . get ( vb, b_id) ;
884
+ let b_id = nde_b. root ;
885
+ let b_bounds = nde_b. possible_types ;
886
+
866
887
#debug[ "tvar(%s <: %s=%s)" ,
867
888
a. to_str ( self ) ,
868
889
b_id. to_str ( ) , b_bounds. to_str ( self ) ] ;
@@ -875,7 +896,9 @@ impl unify_methods for infer_ctxt {
875
896
876
897
assert ty:: type_is_integral ( a) ;
877
898
878
- let { root: b_id , possible_types : b_pt } = self . get ( vb, b_id) ;
899
+ let nde_b = self . get ( vb, b_id) ;
900
+ let b_id = nde_b. root ;
901
+ let b_pt = nde_b. possible_types ;
879
902
880
903
let intersection =
881
904
intersection ( b_pt, convert_integral_ty_to_int_ty_set (
@@ -1101,8 +1124,9 @@ impl methods for resolve_state {
1101
1124
ret ty:: re_var( rid) ;
1102
1125
} else {
1103
1126
vec:: push( self . r_seen, rid) ;
1104
- let { root: _, possible_types: bounds} =
1105
- self . infcx. get( self . infcx. rb, rid) ;
1127
+ let nde = self . infcx. get( self . infcx. rb, rid) ;
1128
+ let bounds = nde. possible_types;
1129
+
1106
1130
let r1 = alt bounds {
1107
1131
{ ub : _, lb : some( t) } { self . resolve_region( t) }
1108
1132
{ ub: some( t) , lb: _ } { self . resolve_region( t) }
@@ -1135,8 +1159,9 @@ impl methods for resolve_state {
1135
1159
// tend to carry more restrictions or higher
1136
1160
// perf. penalties, so it pays to know more.
1137
1161
1138
- let { root: _, possible_types: bounds} =
1139
- self . infcx. get( self . infcx. tvb, vid) ;
1162
+ let nde = self . infcx. get( self . infcx. tvb, vid) ;
1163
+ let bounds = nde. possible_types;
1164
+
1140
1165
let t1 = alt bounds {
1141
1166
{ ub : _, lb : some( t) } if !type_is_bot( t) { self . resolve1( t) }
1142
1167
{ ub: some( t) , lb: _ } { self . resolve1( t) }
@@ -1157,8 +1182,9 @@ impl methods for resolve_state {
1157
1182
}
1158
1183
1159
1184
fn resolve_ty_var_integral( vid: tvi_vid) -> ty:: t {
1160
- let { root : _, possible_types : pt} =
1161
- self . infcx. get( self . infcx. tvib, vid) ;
1185
+ let nde = self . infcx. get( self . infcx. tvib, vid) ;
1186
+ let pt = nde. possible_types;
1187
+
1162
1188
// If there's only one type in the set of possible types, then
1163
1189
// that's the answer.
1164
1190
alt single_type_contained_in( self . infcx. tcx, pt) {
@@ -1258,21 +1284,28 @@ impl assignment for infer_ctxt {
1258
1284
}
1259
1285
1260
1286
( ty:: ty_var( a_id) , ty:: ty_var( b_id) ) {
1261
- let { root: _, possible_types: a_bounds} = self . get( self . tvb, a_id) ;
1262
- let { root: _, possible_types: b_bounds} = self . get( self . tvb, b_id) ;
1287
+ let nde_a = self . get( self . tvb, a_id) ;
1288
+ let nde_b = self . get( self . tvb, b_id) ;
1289
+ let a_bounds = nde_a. possible_types;
1290
+ let b_bounds = nde_b. possible_types;
1291
+
1263
1292
let a_bnd = select( a_bounds. ub, a_bounds. lb) ;
1264
1293
let b_bnd = select( b_bounds. lb, b_bounds. ub) ;
1265
1294
self . assign_tys_or_sub( anmnt, a, b, a_bnd, b_bnd)
1266
1295
}
1267
1296
1268
1297
( ty:: ty_var( a_id) , _) {
1269
- let { root: _, possible_types: a_bounds} = self . get( self . tvb, a_id) ;
1298
+ let nde_a = self . get( self . tvb, a_id) ;
1299
+ let a_bounds = nde_a. possible_types;
1300
+
1270
1301
let a_bnd = select( a_bounds. ub, a_bounds. lb) ;
1271
1302
self . assign_tys_or_sub( anmnt, a, b, a_bnd, some( b) )
1272
1303
}
1273
1304
1274
1305
( _, ty:: ty_var( b_id) ) {
1275
- let { root: _, possible_types: b_bounds} = self . get( self . tvb, b_id) ;
1306
+ let nde_b = self . get( self . tvb, b_id) ;
1307
+ let b_bounds = nde_b. possible_types;
1308
+
1276
1309
let b_bnd = select( b_bounds. lb, b_bounds. ub) ;
1277
1310
self . assign_tys_or_sub( anmnt, a, b, some( a) , b_bnd)
1278
1311
}
@@ -2466,8 +2499,12 @@ fn lattice_vars<V:copy vid, T:copy to_str st, L:lattice_ops combine>(
2466
2499
// upper/lower/sub/super/etc.
2467
2500
2468
2501
// Need to find a type that is a supertype of both a and b:
2469
- let { root: a_vid, possible_types: a_bounds} = self . infcx( ) . get( vb, a_vid) ;
2470
- let { root: b_vid, possible_types: b_bounds} = self . infcx( ) . get( vb, b_vid) ;
2502
+ let nde_a = self . infcx( ) . get( vb, a_vid) ;
2503
+ let nde_b = self . infcx( ) . get( vb, b_vid) ;
2504
+ let a_vid = nde_a. root;
2505
+ let b_vid = nde_b. root;
2506
+ let a_bounds = nde_a. possible_types;
2507
+ let b_bounds = nde_b. possible_types;
2471
2508
2472
2509
#debug[ "%s.lattice_vars(%s=%s <: %s=%s)" ,
2473
2510
self . tag( ) ,
@@ -2503,7 +2540,9 @@ fn lattice_var_t<V:copy vid, T:copy to_str st, L:lattice_ops combine>(
2503
2540
a_id: V , b: T ,
2504
2541
c_ts: fn ( T , T ) -> cres < T > ) -> cres < T > {
2505
2542
2506
- let { root: a_id, possible_types: a_bounds} = self . infcx( ) . get( vb, a_id) ;
2543
+ let nde_a = self . infcx( ) . get( vb, a_id) ;
2544
+ let a_id = nde_a. root;
2545
+ let a_bounds = nde_a. possible_types;
2507
2546
2508
2547
// The comments in this function are written for LUB, but they
2509
2548
// apply equally well to GLB if you inverse upper/lower/sub/super/etc.
0 commit comments