@@ -33,7 +33,7 @@ use super::unify_key::{ConstVarValue, ConstVariableValue, ConstVariableOrigin};
3333use crate :: hir:: def_id:: DefId ;
3434use crate :: mir:: interpret:: ConstValue ;
3535use crate :: ty:: { IntType , UintType } ;
36- use crate :: ty:: { self , Ty , TyCtxt , InferConst , LazyConst } ;
36+ use crate :: ty:: { self , Ty , TyCtxt , InferConst } ;
3737use crate :: ty:: error:: TypeError ;
3838use crate :: ty:: relate:: { self , Relate , RelateResult , TypeRelation } ;
3939use crate :: ty:: subst:: SubstsRef ;
@@ -118,41 +118,39 @@ impl<'infcx, 'gcx, 'tcx> InferCtxt<'infcx, 'gcx, 'tcx> {
118118 pub fn super_combine_consts < R > (
119119 & self ,
120120 relation : & mut R ,
121- a : & ' tcx LazyConst < ' tcx > ,
122- b : & ' tcx LazyConst < ' tcx > ,
123- ) -> RelateResult < ' tcx , & ' tcx LazyConst < ' tcx > >
121+ a : & ' tcx ty :: Const < ' tcx > ,
122+ b : & ' tcx ty :: Const < ' tcx > ,
123+ ) -> RelateResult < ' tcx , & ' tcx ty :: Const < ' tcx > >
124124 where
125125 R : TypeRelation < ' infcx , ' gcx , ' tcx > ,
126126 {
127127 let a_is_expected = relation. a_is_expected ( ) ;
128128
129- if let ( & ty:: LazyConst :: Evaluated ( a_eval) , & ty:: LazyConst :: Evaluated ( b_eval) ) = ( a, b) {
130- match ( a_eval. val , b_eval. val ) {
131- ( ConstValue :: Infer ( InferConst :: Var ( a_vid) ) ,
132- ConstValue :: Infer ( InferConst :: Var ( b_vid) ) ) => {
133- self . const_unification_table
134- . borrow_mut ( )
135- . unify_var_var ( a_vid, b_vid)
136- . map_err ( |e| const_unification_error ( a_is_expected, e) ) ?;
137- return Ok ( a) ;
138- }
139-
140- // All other cases of inference with other variables are errors.
141- ( ConstValue :: Infer ( InferConst :: Var ( _) ) , ConstValue :: Infer ( _) ) |
142- ( ConstValue :: Infer ( _) , ConstValue :: Infer ( InferConst :: Var ( _) ) ) => {
143- bug ! ( "tried to combine ConstValue::Infer/ConstValue::Infer(InferConst::Var)" )
144- }
129+ match ( a. val , b. val ) {
130+ ( ConstValue :: Infer ( InferConst :: Var ( a_vid) ) ,
131+ ConstValue :: Infer ( InferConst :: Var ( b_vid) ) ) => {
132+ self . const_unification_table
133+ . borrow_mut ( )
134+ . unify_var_var ( a_vid, b_vid)
135+ . map_err ( |e| const_unification_error ( a_is_expected, e) ) ?;
136+ return Ok ( a) ;
137+ }
145138
146- ( ConstValue :: Infer ( InferConst :: Var ( vid) ) , _) => {
147- return self . unify_const_variable ( a_is_expected, vid, b) ;
148- }
139+ // All other cases of inference with other variables are errors.
140+ ( ConstValue :: Infer ( InferConst :: Var ( _) ) , ConstValue :: Infer ( _) ) |
141+ ( ConstValue :: Infer ( _) , ConstValue :: Infer ( InferConst :: Var ( _) ) ) => {
142+ bug ! ( "tried to combine ConstValue::Infer/ConstValue::Infer(InferConst::Var)" )
143+ }
149144
150- ( _ , ConstValue :: Infer ( InferConst :: Var ( vid) ) ) => {
151- return self . unify_const_variable ( ! a_is_expected, vid, a ) ;
152- }
145+ ( ConstValue :: Infer ( InferConst :: Var ( vid) ) , _ ) => {
146+ return self . unify_const_variable ( a_is_expected, vid, b ) ;
147+ }
153148
154- _ => { }
149+ ( _, ConstValue :: Infer ( InferConst :: Var ( vid) ) ) => {
150+ return self . unify_const_variable ( !a_is_expected, vid, a) ;
155151 }
152+
153+ _ => { }
156154 }
157155
158156 ty:: relate:: super_relate_consts ( relation, a, b)
@@ -162,8 +160,8 @@ impl<'infcx, 'gcx, 'tcx> InferCtxt<'infcx, 'gcx, 'tcx> {
162160 & self ,
163161 vid_is_expected : bool ,
164162 vid : ty:: ConstVid < ' tcx > ,
165- value : & ' tcx LazyConst < ' tcx > ,
166- ) -> RelateResult < ' tcx , & ' tcx LazyConst < ' tcx > > {
163+ value : & ' tcx ty :: Const < ' tcx > ,
164+ ) -> RelateResult < ' tcx , & ' tcx ty :: Const < ' tcx > > {
167165 self . const_unification_table
168166 . borrow_mut ( )
169167 . unify_var_value ( vid, ConstVarValue {
@@ -582,16 +580,13 @@ impl<'cx, 'gcx, 'tcx> TypeRelation<'cx, 'gcx, 'tcx> for Generalizer<'cx, 'gcx, '
582580
583581 fn consts (
584582 & mut self ,
585- c : & ' tcx ty:: LazyConst < ' tcx > ,
586- c2 : & ' tcx ty:: LazyConst < ' tcx >
587- ) -> RelateResult < ' tcx , & ' tcx ty:: LazyConst < ' tcx > > {
583+ c : & ' tcx ty:: Const < ' tcx > ,
584+ c2 : & ' tcx ty:: Const < ' tcx >
585+ ) -> RelateResult < ' tcx , & ' tcx ty:: Const < ' tcx > > {
588586 assert_eq ! ( c, c2) ; // we are abusing TypeRelation here; both LHS and RHS ought to be ==
589587
590588 match c {
591- LazyConst :: Evaluated ( ty:: Const {
592- val : ConstValue :: Infer ( InferConst :: Var ( vid) ) ,
593- ..
594- } ) => {
589+ ty:: Const { val : ConstValue :: Infer ( InferConst :: Var ( vid) ) , .. } => {
595590 let mut variable_table = self . infcx . const_unification_table . borrow_mut ( ) ;
596591 match variable_table. probe_value ( * vid) . val . known ( ) {
597592 Some ( u) => {
@@ -628,7 +623,7 @@ impl<'tcx, T:Clone + PartialEq> RelateResultCompare<'tcx, T> for RelateResult<'t
628623
629624pub fn const_unification_error < ' tcx > (
630625 a_is_expected : bool ,
631- ( a, b) : ( & ' tcx LazyConst < ' tcx > , & ' tcx LazyConst < ' tcx > ) ,
626+ ( a, b) : ( & ' tcx ty :: Const < ' tcx > , & ' tcx ty :: Const < ' tcx > ) ,
632627) -> TypeError < ' tcx > {
633628 TypeError :: ConstMismatch ( ty:: relate:: expected_found_bool ( a_is_expected, & a, & b) )
634629}
0 commit comments