@@ -4,7 +4,6 @@ pub use lexical_region_resolve::RegionResolutionError;
44pub use relate:: combine:: CombineFields ;
55pub use relate:: combine:: ObligationEmittingRelation ;
66pub use relate:: StructurallyRelateAliases ;
7- pub use rustc_middle:: ty:: IntVarValue ;
87pub use BoundRegionConversionTime :: * ;
98pub use RegionVariableOrigin :: * ;
109pub use SubregionOrigin :: * ;
@@ -30,7 +29,7 @@ use rustc_hir::def_id::{DefId, LocalDefId};
3029use rustc_middle:: infer:: canonical:: { Canonical , CanonicalVarValues } ;
3130use rustc_middle:: infer:: unify_key:: ConstVariableValue ;
3231use rustc_middle:: infer:: unify_key:: EffectVarValue ;
33- use rustc_middle:: infer:: unify_key:: { ConstVariableOrigin , ConstVariableOriginKind , ToType } ;
32+ use rustc_middle:: infer:: unify_key:: { ConstVariableOrigin , ConstVariableOriginKind } ;
3433use rustc_middle:: infer:: unify_key:: { ConstVidKey , EffectVidKey } ;
3534use rustc_middle:: mir:: interpret:: { ErrorHandled , EvalToValTreeResult } ;
3635use rustc_middle:: mir:: ConstraintCategory ;
@@ -797,13 +796,13 @@ impl<'tcx> InferCtxt<'tcx> {
797796 vars. extend (
798797 ( 0 ..inner. int_unification_table ( ) . len ( ) )
799798 . map ( |i| ty:: IntVid :: from_u32 ( i as u32 ) )
800- . filter ( |& vid| inner. int_unification_table ( ) . probe_value ( vid) . is_none ( ) )
799+ . filter ( |& vid| inner. int_unification_table ( ) . probe_value ( vid) . is_unknown ( ) )
801800 . map ( |v| Ty :: new_int_var ( self . tcx , v) ) ,
802801 ) ;
803802 vars. extend (
804803 ( 0 ..inner. float_unification_table ( ) . len ( ) )
805804 . map ( |i| ty:: FloatVid :: from_u32 ( i as u32 ) )
806- . filter ( |& vid| inner. float_unification_table ( ) . probe_value ( vid) . is_none ( ) )
805+ . filter ( |& vid| inner. float_unification_table ( ) . probe_value ( vid) . is_unknown ( ) )
807806 . map ( |v| Ty :: new_float_var ( self . tcx , v) ) ,
808807 ) ;
809808 vars
@@ -1026,15 +1025,15 @@ impl<'tcx> InferCtxt<'tcx> {
10261025 }
10271026
10281027 fn next_int_var_id ( & self ) -> IntVid {
1029- self . inner . borrow_mut ( ) . int_unification_table ( ) . new_key ( None )
1028+ self . inner . borrow_mut ( ) . int_unification_table ( ) . new_key ( ty :: IntVarValue :: Unknown )
10301029 }
10311030
10321031 pub fn next_int_var ( & self ) -> Ty < ' tcx > {
10331032 Ty :: new_int_var ( self . tcx , self . next_int_var_id ( ) )
10341033 }
10351034
10361035 fn next_float_var_id ( & self ) -> FloatVid {
1037- self . inner . borrow_mut ( ) . float_unification_table ( ) . new_key ( None )
1036+ self . inner . borrow_mut ( ) . float_unification_table ( ) . new_key ( ty :: FloatVarValue :: Unknown )
10381037 }
10391038
10401039 pub fn next_float_var ( & self ) -> Ty < ' tcx > {
@@ -1276,21 +1275,26 @@ impl<'tcx> InferCtxt<'tcx> {
12761275 /// or else the root int var in the unification table.
12771276 pub fn opportunistic_resolve_int_var ( & self , vid : ty:: IntVid ) -> Ty < ' tcx > {
12781277 let mut inner = self . inner . borrow_mut ( ) ;
1279- if let Some ( value) = inner. int_unification_table ( ) . probe_value ( vid) {
1280- value. to_type ( self . tcx )
1281- } else {
1282- Ty :: new_int_var ( self . tcx , inner. int_unification_table ( ) . find ( vid) )
1278+ let value = inner. int_unification_table ( ) . probe_value ( vid) ;
1279+ match value {
1280+ ty:: IntVarValue :: IntType ( ty) => Ty :: new_int ( self . tcx , ty) ,
1281+ ty:: IntVarValue :: UintType ( ty) => Ty :: new_uint ( self . tcx , ty) ,
1282+ ty:: IntVarValue :: Unknown => {
1283+ Ty :: new_int_var ( self . tcx , inner. int_unification_table ( ) . find ( vid) )
1284+ }
12831285 }
12841286 }
12851287
12861288 /// Resolves a float var to a rigid int type, if it was constrained to one,
12871289 /// or else the root float var in the unification table.
12881290 pub fn opportunistic_resolve_float_var ( & self , vid : ty:: FloatVid ) -> Ty < ' tcx > {
12891291 let mut inner = self . inner . borrow_mut ( ) ;
1290- if let Some ( value) = inner. float_unification_table ( ) . probe_value ( vid) {
1291- value. to_type ( self . tcx )
1292- } else {
1293- Ty :: new_float_var ( self . tcx , inner. float_unification_table ( ) . find ( vid) )
1292+ let value = inner. float_unification_table ( ) . probe_value ( vid) ;
1293+ match value {
1294+ ty:: FloatVarValue :: Known ( ty) => Ty :: new_float ( self . tcx , ty) ,
1295+ ty:: FloatVarValue :: Unknown => {
1296+ Ty :: new_float_var ( self . tcx , inner. float_unification_table ( ) . find ( vid) )
1297+ }
12941298 }
12951299 }
12961300
@@ -1607,15 +1611,15 @@ impl<'tcx> InferCtxt<'tcx> {
16071611 // If `inlined_probe_value` returns a value it's always a
16081612 // `ty::Int(_)` or `ty::UInt(_)`, which never matches a
16091613 // `ty::Infer(_)`.
1610- self . inner . borrow_mut ( ) . int_unification_table ( ) . inlined_probe_value ( v) . is_some ( )
1614+ ! self . inner . borrow_mut ( ) . int_unification_table ( ) . inlined_probe_value ( v) . is_unknown ( )
16111615 }
16121616
16131617 TyOrConstInferVar :: TyFloat ( v) => {
16141618 // If `probe_value` returns a value it's always a
16151619 // `ty::Float(_)`, which never matches a `ty::Infer(_)`.
16161620 //
16171621 // Not `inlined_probe_value(v)` because this call site is colder.
1618- self . inner . borrow_mut ( ) . float_unification_table ( ) . probe_value ( v) . is_some ( )
1622+ ! self . inner . borrow_mut ( ) . float_unification_table ( ) . probe_value ( v) . is_unknown ( )
16191623 }
16201624
16211625 TyOrConstInferVar :: Const ( v) => {
@@ -1836,21 +1840,20 @@ impl<'a, 'tcx> ShallowResolver<'a, 'tcx> {
18361840 known. map ( |t| self . fold_ty ( t) )
18371841 }
18381842
1839- ty:: IntVar ( v) => self
1840- . infcx
1841- . inner
1842- . borrow_mut ( )
1843- . int_unification_table ( )
1844- . probe_value ( v )
1845- . map ( |v| v . to_type ( self . infcx . tcx ) ) ,
1843+ ty:: IntVar ( v) => {
1844+ match self . infcx . inner . borrow_mut ( ) . int_unification_table ( ) . probe_value ( v ) {
1845+ ty :: IntVarValue :: Unknown => None ,
1846+ ty :: IntVarValue :: IntType ( ty ) => Some ( Ty :: new_int ( self . infcx . tcx , ty ) ) ,
1847+ ty :: IntVarValue :: UintType ( ty ) => Some ( Ty :: new_uint ( self . infcx . tcx , ty ) ) ,
1848+ }
1849+ }
18461850
1847- ty:: FloatVar ( v) => self
1848- . infcx
1849- . inner
1850- . borrow_mut ( )
1851- . float_unification_table ( )
1852- . probe_value ( v)
1853- . map ( |v| v. to_type ( self . infcx . tcx ) ) ,
1851+ ty:: FloatVar ( v) => {
1852+ match self . infcx . inner . borrow_mut ( ) . float_unification_table ( ) . probe_value ( v) {
1853+ ty:: FloatVarValue :: Unknown => None ,
1854+ ty:: FloatVarValue :: Known ( ty) => Some ( Ty :: new_float ( self . infcx . tcx , ty) ) ,
1855+ }
1856+ }
18541857
18551858 ty:: FreshTy ( _) | ty:: FreshIntTy ( _) | ty:: FreshFloatTy ( _) => None ,
18561859 }
0 commit comments