@@ -866,6 +866,7 @@ impl TypeRelation<'tcx> for ConstInferUnifier<'_, 'tcx> {
866
866
Ok ( a. rebind ( self . relate ( a. skip_binder ( ) , b. skip_binder ( ) ) ?) )
867
867
}
868
868
869
+ #[ tracing:: instrument( level = "debug" , skip( self ) ) ]
869
870
fn tys ( & mut self , t : Ty < ' tcx > , _t : Ty < ' tcx > ) -> RelateResult < ' tcx , Ty < ' tcx > > {
870
871
debug_assert_eq ! ( t, _t) ;
871
872
debug ! ( "ConstInferUnifier: t={:?}" , t) ;
@@ -941,6 +942,7 @@ impl TypeRelation<'tcx> for ConstInferUnifier<'_, 'tcx> {
941
942
}
942
943
}
943
944
945
+ #[ tracing:: instrument( level = "debug" , skip( self ) ) ]
944
946
fn consts (
945
947
& mut self ,
946
948
c : & ' tcx ty:: Const < ' tcx > ,
@@ -951,29 +953,38 @@ impl TypeRelation<'tcx> for ConstInferUnifier<'_, 'tcx> {
951
953
952
954
match c. val {
953
955
ty:: ConstKind :: Infer ( InferConst :: Var ( vid) ) => {
954
- let mut inner = self . infcx . inner . borrow_mut ( ) ;
955
- let variable_table = & mut inner. const_unification_table ( ) ;
956
-
957
956
// Check if the current unification would end up
958
957
// unifying `target_vid` with a const which contains
959
958
// an inference variable which is unioned with `target_vid`.
960
959
//
961
960
// Not doing so can easily result in stack overflows.
962
- if variable_table. unioned ( self . target_vid , vid) {
961
+ if self
962
+ . infcx
963
+ . inner
964
+ . borrow_mut ( )
965
+ . const_unification_table ( )
966
+ . unioned ( self . target_vid , vid)
967
+ {
963
968
return Err ( TypeError :: CyclicConst ( c) ) ;
964
969
}
965
970
966
- let var_value = variable_table. probe_value ( vid) ;
971
+ let var_value =
972
+ self . infcx . inner . borrow_mut ( ) . const_unification_table ( ) . probe_value ( vid) ;
967
973
match var_value. val {
968
974
ConstVariableValue :: Known { value : u } => self . consts ( u, u) ,
969
975
ConstVariableValue :: Unknown { universe } => {
970
976
if self . for_universe . can_name ( universe) {
971
977
Ok ( c)
972
978
} else {
973
- let new_var_id = variable_table. new_key ( ConstVarValue {
974
- origin : var_value. origin ,
975
- val : ConstVariableValue :: Unknown { universe : self . for_universe } ,
976
- } ) ;
979
+ let new_var_id =
980
+ self . infcx . inner . borrow_mut ( ) . const_unification_table ( ) . new_key (
981
+ ConstVarValue {
982
+ origin : var_value. origin ,
983
+ val : ConstVariableValue :: Unknown {
984
+ universe : self . for_universe ,
985
+ } ,
986
+ } ,
987
+ ) ;
977
988
Ok ( self . tcx ( ) . mk_const_var ( new_var_id, c. ty ) )
978
989
}
979
990
}
0 commit comments