@@ -29,7 +29,7 @@ use ty::error::{ExpectedFound, TypeError, UnconstrainedNumeric};
29
29
use ty:: fold:: { TypeFoldable , TypeFolder , TypeVisitor } ;
30
30
use ty:: relate:: RelateResult ;
31
31
use traits:: { self , ObligationCause , PredicateObligations , Reveal } ;
32
- use rustc_data_structures:: unify:: { self , UnificationTable } ;
32
+ use rustc_data_structures:: unify as ut ;
33
33
use std:: cell:: { Cell , RefCell , Ref , RefMut } ;
34
34
use std:: collections:: BTreeMap ;
35
35
use std:: fmt;
@@ -99,10 +99,10 @@ pub struct InferCtxt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
99
99
pub type_variables : RefCell < type_variable:: TypeVariableTable < ' tcx > > ,
100
100
101
101
// Map from integral variable to the kind of integer it represents
102
- int_unification_table : RefCell < UnificationTable < ty:: IntVid > > ,
102
+ int_unification_table : RefCell < ut :: UnificationTable < ut :: InPlace < ty:: IntVid > > > ,
103
103
104
104
// Map from floating variable to the kind of float it represents
105
- float_unification_table : RefCell < UnificationTable < ty:: FloatVid > > ,
105
+ float_unification_table : RefCell < ut :: UnificationTable < ut :: InPlace < ty:: FloatVid > > > ,
106
106
107
107
// Tracks the set of region variables and the constraints between
108
108
// them. This is initially `Some(_)` but when
@@ -441,8 +441,8 @@ impl<'a, 'gcx, 'tcx> InferCtxtBuilder<'a, 'gcx, 'tcx> {
441
441
in_progress_tables,
442
442
projection_cache : RefCell :: new ( traits:: ProjectionCache :: new ( ) ) ,
443
443
type_variables : RefCell :: new ( type_variable:: TypeVariableTable :: new ( ) ) ,
444
- int_unification_table : RefCell :: new ( UnificationTable :: new ( ) ) ,
445
- float_unification_table : RefCell :: new ( UnificationTable :: new ( ) ) ,
444
+ int_unification_table : RefCell :: new ( ut :: UnificationTable :: new ( ) ) ,
445
+ float_unification_table : RefCell :: new ( ut :: UnificationTable :: new ( ) ) ,
446
446
region_constraints : RefCell :: new ( Some ( RegionConstraintCollector :: new ( ) ) ) ,
447
447
lexical_region_resolutions : RefCell :: new ( None ) ,
448
448
selection_cache : traits:: SelectionCache :: new ( ) ,
@@ -476,8 +476,8 @@ impl<'tcx, T> InferOk<'tcx, T> {
476
476
pub struct CombinedSnapshot < ' a , ' tcx : ' a > {
477
477
projection_cache_snapshot : traits:: ProjectionCacheSnapshot ,
478
478
type_snapshot : type_variable:: Snapshot ,
479
- int_snapshot : unify :: Snapshot < ty:: IntVid > ,
480
- float_snapshot : unify :: Snapshot < ty:: FloatVid > ,
479
+ int_snapshot : ut :: Snapshot < ut :: InPlace < ty:: IntVid > > ,
480
+ float_snapshot : ut :: Snapshot < ut :: InPlace < ty:: FloatVid > > ,
481
481
region_constraints_snapshot : RegionSnapshot ,
482
482
region_obligations_snapshot : usize ,
483
483
was_in_snapshot : bool ,
@@ -678,14 +678,14 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
678
678
use ty:: error:: UnconstrainedNumeric :: { UnconstrainedInt , UnconstrainedFloat } ;
679
679
match ty. sty {
680
680
ty:: TyInfer ( ty:: IntVar ( vid) ) => {
681
- if self . int_unification_table . borrow_mut ( ) . has_value ( vid) {
681
+ if self . int_unification_table . borrow_mut ( ) . probe_value ( vid) . is_some ( ) {
682
682
Neither
683
683
} else {
684
684
UnconstrainedInt
685
685
}
686
686
} ,
687
687
ty:: TyInfer ( ty:: FloatVar ( vid) ) => {
688
- if self . float_unification_table . borrow_mut ( ) . has_value ( vid) {
688
+ if self . float_unification_table . borrow_mut ( ) . probe_value ( vid) . is_some ( ) {
689
689
Neither
690
690
} else {
691
691
UnconstrainedFloat
@@ -698,27 +698,32 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
698
698
pub fn unsolved_variables ( & self ) -> Vec < Ty < ' tcx > > {
699
699
let mut variables = Vec :: new ( ) ;
700
700
701
- let unbound_ty_vars = self . type_variables
702
- . borrow_mut ( )
703
- . unsolved_variables ( )
704
- . into_iter ( )
705
- . map ( |t| self . tcx . mk_var ( t) ) ;
706
-
707
- let unbound_int_vars = self . int_unification_table
708
- . borrow_mut ( )
709
- . unsolved_variables ( )
710
- . into_iter ( )
711
- . map ( |v| self . tcx . mk_int_var ( v) ) ;
701
+ {
702
+ let mut type_variables = self . type_variables . borrow_mut ( ) ;
703
+ variables. extend (
704
+ type_variables
705
+ . unsolved_variables ( )
706
+ . into_iter ( )
707
+ . map ( |t| self . tcx . mk_var ( t) ) ) ;
708
+ }
712
709
713
- let unbound_float_vars = self . float_unification_table
714
- . borrow_mut ( )
715
- . unsolved_variables ( )
716
- . into_iter ( )
717
- . map ( |v| self . tcx . mk_float_var ( v) ) ;
710
+ {
711
+ let mut int_unification_table = self . int_unification_table . borrow_mut ( ) ;
712
+ variables. extend (
713
+ ( 0 ..int_unification_table. len ( ) )
714
+ . map ( |i| ty:: IntVid { index : i as u32 } )
715
+ . filter ( |& vid| int_unification_table. probe_value ( vid) . is_none ( ) )
716
+ . map ( |v| self . tcx . mk_int_var ( v) ) ) ;
717
+ }
718
718
719
- variables. extend ( unbound_ty_vars) ;
720
- variables. extend ( unbound_int_vars) ;
721
- variables. extend ( unbound_float_vars) ;
719
+ {
720
+ let mut float_unification_table = self . float_unification_table . borrow_mut ( ) ;
721
+ variables. extend (
722
+ ( 0 ..float_unification_table. len ( ) )
723
+ . map ( |i| ty:: FloatVid { index : i as u32 } )
724
+ . filter ( |& vid| float_unification_table. probe_value ( vid) . is_none ( ) )
725
+ . map ( |v| self . tcx . mk_float_var ( v) ) ) ;
726
+ }
722
727
723
728
return variables;
724
729
}
@@ -1262,15 +1267,15 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
1262
1267
ty:: TyInfer ( ty:: IntVar ( v) ) => {
1263
1268
self . int_unification_table
1264
1269
. borrow_mut ( )
1265
- . probe ( v)
1270
+ . probe_value ( v)
1266
1271
. map ( |v| v. to_type ( self . tcx ) )
1267
1272
. unwrap_or ( typ)
1268
1273
}
1269
1274
1270
1275
ty:: TyInfer ( ty:: FloatVar ( v) ) => {
1271
1276
self . float_unification_table
1272
1277
. borrow_mut ( )
1273
- . probe ( v)
1278
+ . probe_value ( v)
1274
1279
. map ( |v| v. to_type ( self . tcx ) )
1275
1280
. unwrap_or ( typ)
1276
1281
}
0 commit comments