@@ -29,7 +29,7 @@ use ty::error::{ExpectedFound, TypeError, UnconstrainedNumeric};
2929use ty:: fold:: { TypeFoldable , TypeFolder , TypeVisitor } ;
3030use ty:: relate:: RelateResult ;
3131use traits:: { self , ObligationCause , PredicateObligations , Reveal } ;
32- use rustc_data_structures:: unify:: { self , UnificationTable } ;
32+ use rustc_data_structures:: unify as ut ;
3333use std:: cell:: { Cell , RefCell , Ref , RefMut } ;
3434use std:: collections:: BTreeMap ;
3535use std:: fmt;
@@ -99,10 +99,10 @@ pub struct InferCtxt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
9999 pub type_variables : RefCell < type_variable:: TypeVariableTable < ' tcx > > ,
100100
101101 // 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 > > > ,
103103
104104 // 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 > > > ,
106106
107107 // Tracks the set of region variables and the constraints between
108108 // them. This is initially `Some(_)` but when
@@ -441,8 +441,8 @@ impl<'a, 'gcx, 'tcx> InferCtxtBuilder<'a, 'gcx, 'tcx> {
441441 in_progress_tables,
442442 projection_cache : RefCell :: new ( traits:: ProjectionCache :: new ( ) ) ,
443443 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 ( ) ) ,
446446 region_constraints : RefCell :: new ( Some ( RegionConstraintCollector :: new ( ) ) ) ,
447447 lexical_region_resolutions : RefCell :: new ( None ) ,
448448 selection_cache : traits:: SelectionCache :: new ( ) ,
@@ -476,8 +476,8 @@ impl<'tcx, T> InferOk<'tcx, T> {
476476pub struct CombinedSnapshot < ' a , ' tcx : ' a > {
477477 projection_cache_snapshot : traits:: ProjectionCacheSnapshot ,
478478 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 > > ,
481481 region_constraints_snapshot : RegionSnapshot ,
482482 region_obligations_snapshot : usize ,
483483 was_in_snapshot : bool ,
@@ -678,14 +678,14 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
678678 use ty:: error:: UnconstrainedNumeric :: { UnconstrainedInt , UnconstrainedFloat } ;
679679 match ty. sty {
680680 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 ( ) {
682682 Neither
683683 } else {
684684 UnconstrainedInt
685685 }
686686 } ,
687687 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 ( ) {
689689 Neither
690690 } else {
691691 UnconstrainedFloat
@@ -698,27 +698,32 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
698698 pub fn unsolved_variables ( & self ) -> Vec < Ty < ' tcx > > {
699699 let mut variables = Vec :: new ( ) ;
700700
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+ }
712709
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+ }
718718
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+ }
722727
723728 return variables;
724729 }
@@ -1262,15 +1267,15 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
12621267 ty:: TyInfer ( ty:: IntVar ( v) ) => {
12631268 self . int_unification_table
12641269 . borrow_mut ( )
1265- . probe ( v)
1270+ . probe_value ( v)
12661271 . map ( |v| v. to_type ( self . tcx ) )
12671272 . unwrap_or ( typ)
12681273 }
12691274
12701275 ty:: TyInfer ( ty:: FloatVar ( v) ) => {
12711276 self . float_unification_table
12721277 . borrow_mut ( )
1273- . probe ( v)
1278+ . probe_value ( v)
12741279 . map ( |v| v. to_type ( self . tcx ) )
12751280 . unwrap_or ( typ)
12761281 }
0 commit comments