@@ -22,7 +22,9 @@ use rustc_middle::bug;
2222use rustc_middle:: infer:: unify_key:: EffectVarValue ;
2323use rustc_middle:: traits:: solve:: Goal ;
2424use rustc_middle:: ty:: error:: { ExpectedFound , TypeError } ;
25- use rustc_middle:: ty:: { self , InferConst , IntType , Ty , TyCtxt , TypeVisitableExt , UintType , Upcast } ;
25+ use rustc_middle:: ty:: {
26+ self , ConstKind , InferConst , IntType , Ty , TyCtxt , TypeVisitableExt , UintType , Upcast ,
27+ } ;
2628pub use rustc_next_trait_solver:: relate:: combine:: * ;
2729use tracing:: debug;
2830
@@ -177,6 +179,8 @@ impl<'tcx> InferCtxt<'tcx> {
177179 where
178180 R : PredicateEmittingRelation < InferCtxt < ' tcx > > ,
179181 {
182+ use InferConst :: * ;
183+
180184 debug ! ( "super_combine_consts::<{}>({:?}, {:?})" , std:: any:: type_name:: <R >( ) , a, b) ;
181185 debug_assert ! ( !a. has_escaping_bound_vars( ) ) ;
182186 debug_assert ! ( !b. has_escaping_bound_vars( ) ) ;
@@ -189,55 +193,37 @@ impl<'tcx> InferCtxt<'tcx> {
189193 let b = self . shallow_resolve_const ( b) ;
190194
191195 match ( a. kind ( ) , b. kind ( ) ) {
192- (
193- ty:: ConstKind :: Infer ( InferConst :: Var ( a_vid) ) ,
194- ty:: ConstKind :: Infer ( InferConst :: Var ( b_vid) ) ,
195- ) => {
196+ ( ConstKind :: Infer ( Var ( a_vid) ) , ConstKind :: Infer ( Var ( b_vid) ) ) => {
196197 self . inner . borrow_mut ( ) . const_unification_table ( ) . union ( a_vid, b_vid) ;
197198 Ok ( a)
198199 }
199200
200- (
201- ty:: ConstKind :: Infer ( InferConst :: EffectVar ( a_vid) ) ,
202- ty:: ConstKind :: Infer ( InferConst :: EffectVar ( b_vid) ) ,
203- ) => {
201+ ( ConstKind :: Infer ( EffectVar ( a_vid) ) , ConstKind :: Infer ( EffectVar ( b_vid) ) ) => {
204202 self . inner . borrow_mut ( ) . effect_unification_table ( ) . union ( a_vid, b_vid) ;
205203 Ok ( a)
206204 }
207205
208206 // All other cases of inference with other variables are errors.
209- (
210- ty:: ConstKind :: Infer ( InferConst :: Var ( _) | InferConst :: EffectVar ( _) ) ,
211- ty:: ConstKind :: Infer ( _) ,
212- )
213- | (
214- ty:: ConstKind :: Infer ( _) ,
215- ty:: ConstKind :: Infer ( InferConst :: Var ( _) | InferConst :: EffectVar ( _) ) ,
216- ) => {
217- bug ! (
218- "tried to combine ConstKind::Infer/ConstKind::Infer(InferConst::Var): {a:?} and {b:?}"
219- )
207+ ( ConstKind :: Infer ( Var ( _) | EffectVar ( _) ) , ConstKind :: Infer ( _) )
208+ | ( ConstKind :: Infer ( _) , ConstKind :: Infer ( Var ( _) | EffectVar ( _) ) ) => {
209+ bug ! ( "tried to combine ConstKind::Infer/ConstKind::Infer(Var): {a:?} and {b:?}" )
220210 }
221211
222- ( ty :: ConstKind :: Infer ( InferConst :: Var ( vid) ) , _) => {
212+ ( ConstKind :: Infer ( Var ( vid) ) , _) => {
223213 self . instantiate_const_var ( relation, true , vid, b) ?;
224214 Ok ( b)
225215 }
226216
227- ( _, ty :: ConstKind :: Infer ( InferConst :: Var ( vid) ) ) => {
217+ ( _, ConstKind :: Infer ( Var ( vid) ) ) => {
228218 self . instantiate_const_var ( relation, false , vid, a) ?;
229219 Ok ( a)
230220 }
231221
232- ( ty:: ConstKind :: Infer ( InferConst :: EffectVar ( vid) ) , _) => {
233- Ok ( self . unify_effect_variable ( vid, b) )
234- }
222+ ( ConstKind :: Infer ( EffectVar ( vid) ) , _) => Ok ( self . unify_effect_variable ( vid, b) ) ,
235223
236- ( _, ty:: ConstKind :: Infer ( InferConst :: EffectVar ( vid) ) ) => {
237- Ok ( self . unify_effect_variable ( vid, a) )
238- }
224+ ( _, ConstKind :: Infer ( EffectVar ( vid) ) ) => Ok ( self . unify_effect_variable ( vid, a) ) ,
239225
240- ( ty :: ConstKind :: Unevaluated ( ..) , _) | ( _, ty :: ConstKind :: Unevaluated ( ..) )
226+ ( ConstKind :: Unevaluated ( ..) , _) | ( _, ConstKind :: Unevaluated ( ..) )
241227 if self . tcx . features ( ) . generic_const_exprs || self . next_trait_solver ( ) =>
242228 {
243229 match relation. structurally_relate_aliases ( ) {
0 commit comments