@@ -498,12 +498,15 @@ pub fn super_relate_consts<R: TypeRelation<'tcx>>(
498498 debug ! ( "{}.super_relate_consts(a = {:?}, b = {:?})" , relation. tag( ) , a, b) ;
499499 let tcx = relation. tcx ( ) ;
500500
501- let eagerly_eval = |x : & ' tcx ty:: Const < ' tcx > | x. eval ( tcx, relation. param_env ( ) ) . val ;
501+ // FIXME(oli-obk): once const generics can have generic types, this assertion
502+ // will likely get triggered. Move to `normalize_erasing_regions` at that point.
503+ assert_eq ! (
504+ tcx. erase_regions( a. ty) ,
505+ tcx. erase_regions( b. ty) ,
506+ "cannot relate constants of different types"
507+ ) ;
502508
503- // FIXME(eddyb) doesn't look like everything below checks that `a.ty == b.ty`.
504- // We could probably always assert it early, as const generic parameters
505- // are not allowed to depend on other generic parameters, i.e. are concrete.
506- // (although there could be normalization differences)
509+ let eagerly_eval = |x : & ' tcx ty:: Const < ' tcx > | x. eval ( tcx, relation. param_env ( ) ) . val ;
507510
508511 // Currently, the values that can be unified are primitive types,
509512 // and those that derive both `PartialEq` and `Eq`, corresponding
@@ -524,7 +527,7 @@ pub fn super_relate_consts<R: TypeRelation<'tcx>>(
524527 }
525528 ( ty:: ConstKind :: Value ( a_val) , ty:: ConstKind :: Value ( b_val) ) => {
526529 let new_val = match ( a_val, b_val) {
527- ( ConstValue :: Scalar ( a_val) , ConstValue :: Scalar ( b_val) ) if a . ty == b . ty => {
530+ ( ConstValue :: Scalar ( a_val) , ConstValue :: Scalar ( b_val) ) => {
528531 if a_val == b_val {
529532 Ok ( ConstValue :: Scalar ( a_val) )
530533 } else if let ty:: FnPtr ( _) = a. ty . kind ( ) {
0 commit comments