@@ -989,12 +989,9 @@ impl<'tcx> InferCtxt<'tcx> {
989989 self . inner . borrow_mut ( ) . type_variables ( ) . num_vars ( )
990990 }
991991
992- pub fn next_ty_var_id ( & self , origin : TypeVariableOrigin ) -> TyVid {
993- self . inner . borrow_mut ( ) . type_variables ( ) . new_var ( self . universe ( ) , origin)
994- }
995-
996992 pub fn next_ty_var ( & self , origin : TypeVariableOrigin ) -> Ty < ' tcx > {
997- Ty :: new_var ( self . tcx , self . next_ty_var_id ( origin) )
993+ let vid = self . inner . borrow_mut ( ) . type_variables ( ) . new_var ( self . universe ( ) , origin) ;
994+ Ty :: new_var ( self . tcx , vid)
998995 }
999996
1000997 pub fn next_ty_var_id_in_universe (
@@ -1015,7 +1012,13 @@ impl<'tcx> InferCtxt<'tcx> {
10151012 }
10161013
10171014 pub fn next_const_var ( & self , ty : Ty < ' tcx > , origin : ConstVariableOrigin ) -> ty:: Const < ' tcx > {
1018- ty:: Const :: new_var ( self . tcx , self . next_const_var_id ( origin) , ty)
1015+ let vid = self
1016+ . inner
1017+ . borrow_mut ( )
1018+ . const_unification_table ( )
1019+ . new_key ( ConstVariableValue :: Unknown { origin, universe : self . universe ( ) } )
1020+ . vid ;
1021+ ty:: Const :: new_var ( self . tcx , vid, ty)
10191022 }
10201023
10211024 pub fn next_const_var_in_universe (
@@ -1033,28 +1036,14 @@ impl<'tcx> InferCtxt<'tcx> {
10331036 ty:: Const :: new_var ( self . tcx , vid, ty)
10341037 }
10351038
1036- pub fn next_const_var_id ( & self , origin : ConstVariableOrigin ) -> ConstVid {
1037- self . inner
1038- . borrow_mut ( )
1039- . const_unification_table ( )
1040- . new_key ( ConstVariableValue :: Unknown { origin, universe : self . universe ( ) } )
1041- . vid
1042- }
1043-
1044- fn next_int_var_id ( & self ) -> IntVid {
1045- self . inner . borrow_mut ( ) . int_unification_table ( ) . new_key ( None )
1046- }
1047-
10481039 pub fn next_int_var ( & self ) -> Ty < ' tcx > {
1049- Ty :: new_int_var ( self . tcx , self . next_int_var_id ( ) )
1050- }
1051-
1052- fn next_float_var_id ( & self ) -> FloatVid {
1053- self . inner . borrow_mut ( ) . float_unification_table ( ) . new_key ( None )
1040+ let vid = self . inner . borrow_mut ( ) . int_unification_table ( ) . new_key ( None ) ;
1041+ Ty :: new_int_var ( self . tcx , vid)
10541042 }
10551043
10561044 pub fn next_float_var ( & self ) -> Ty < ' tcx > {
1057- Ty :: new_float_var ( self . tcx , self . next_float_var_id ( ) )
1045+ let vid = self . inner . borrow_mut ( ) . float_unification_table ( ) . new_key ( None ) ;
1046+ Ty :: new_float_var ( self . tcx , vid)
10581047 }
10591048
10601049 /// Creates a fresh region variable with the next available index.
0 commit comments