@@ -4,7 +4,6 @@ pub use lexical_region_resolve::RegionResolutionError;
4
4
pub use relate:: combine:: CombineFields ;
5
5
pub use relate:: combine:: ObligationEmittingRelation ;
6
6
pub use relate:: StructurallyRelateAliases ;
7
- pub use rustc_middle:: ty:: IntVarValue ;
8
7
pub use BoundRegionConversionTime :: * ;
9
8
pub use RegionVariableOrigin :: * ;
10
9
pub use SubregionOrigin :: * ;
@@ -30,7 +29,7 @@ use rustc_hir::def_id::{DefId, LocalDefId};
30
29
use rustc_middle:: infer:: canonical:: { Canonical , CanonicalVarValues } ;
31
30
use rustc_middle:: infer:: unify_key:: ConstVariableValue ;
32
31
use 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 } ;
34
33
use rustc_middle:: infer:: unify_key:: { ConstVidKey , EffectVidKey } ;
35
34
use rustc_middle:: mir:: interpret:: { ErrorHandled , EvalToValTreeResult } ;
36
35
use rustc_middle:: mir:: ConstraintCategory ;
@@ -797,13 +796,13 @@ impl<'tcx> InferCtxt<'tcx> {
797
796
vars. extend (
798
797
( 0 ..inner. int_unification_table ( ) . len ( ) )
799
798
. 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 ( ) )
801
800
. map ( |v| Ty :: new_int_var ( self . tcx , v) ) ,
802
801
) ;
803
802
vars. extend (
804
803
( 0 ..inner. float_unification_table ( ) . len ( ) )
805
804
. 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 ( ) )
807
806
. map ( |v| Ty :: new_float_var ( self . tcx , v) ) ,
808
807
) ;
809
808
vars
@@ -1026,15 +1025,15 @@ impl<'tcx> InferCtxt<'tcx> {
1026
1025
}
1027
1026
1028
1027
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 )
1030
1029
}
1031
1030
1032
1031
pub fn next_int_var ( & self ) -> Ty < ' tcx > {
1033
1032
Ty :: new_int_var ( self . tcx , self . next_int_var_id ( ) )
1034
1033
}
1035
1034
1036
1035
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 )
1038
1037
}
1039
1038
1040
1039
pub fn next_float_var ( & self ) -> Ty < ' tcx > {
@@ -1276,21 +1275,26 @@ impl<'tcx> InferCtxt<'tcx> {
1276
1275
/// or else the root int var in the unification table.
1277
1276
pub fn opportunistic_resolve_int_var ( & self , vid : ty:: IntVid ) -> Ty < ' tcx > {
1278
1277
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
+ }
1283
1285
}
1284
1286
}
1285
1287
1286
1288
/// Resolves a float var to a rigid int type, if it was constrained to one,
1287
1289
/// or else the root float var in the unification table.
1288
1290
pub fn opportunistic_resolve_float_var ( & self , vid : ty:: FloatVid ) -> Ty < ' tcx > {
1289
1291
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
+ }
1294
1298
}
1295
1299
}
1296
1300
@@ -1607,15 +1611,15 @@ impl<'tcx> InferCtxt<'tcx> {
1607
1611
// If `inlined_probe_value` returns a value it's always a
1608
1612
// `ty::Int(_)` or `ty::UInt(_)`, which never matches a
1609
1613
// `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 ( )
1611
1615
}
1612
1616
1613
1617
TyOrConstInferVar :: TyFloat ( v) => {
1614
1618
// If `probe_value` returns a value it's always a
1615
1619
// `ty::Float(_)`, which never matches a `ty::Infer(_)`.
1616
1620
//
1617
1621
// 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 ( )
1619
1623
}
1620
1624
1621
1625
TyOrConstInferVar :: Const ( v) => {
@@ -1836,21 +1840,20 @@ impl<'a, 'tcx> ShallowResolver<'a, 'tcx> {
1836
1840
known. map ( |t| self . fold_ty ( t) )
1837
1841
}
1838
1842
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
+ }
1846
1850
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
+ }
1854
1857
1855
1858
ty:: FreshTy ( _) | ty:: FreshIntTy ( _) | ty:: FreshFloatTy ( _) => None ,
1856
1859
}
0 commit comments