@@ -498,12 +498,15 @@ pub fn super_relate_consts<R: TypeRelation<'tcx>>(
498
498
debug ! ( "{}.super_relate_consts(a = {:?}, b = {:?})" , relation. tag( ) , a, b) ;
499
499
let tcx = relation. tcx ( ) ;
500
500
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
+ ) ;
502
508
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 ;
507
510
508
511
// Currently, the values that can be unified are primitive types,
509
512
// and those that derive both `PartialEq` and `Eq`, corresponding
@@ -524,7 +527,7 @@ pub fn super_relate_consts<R: TypeRelation<'tcx>>(
524
527
}
525
528
( ty:: ConstKind :: Value ( a_val) , ty:: ConstKind :: Value ( b_val) ) => {
526
529
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) ) => {
528
531
if a_val == b_val {
529
532
Ok ( ConstValue :: Scalar ( a_val) )
530
533
} else if let ty:: FnPtr ( _) = a. ty . kind ( ) {
0 commit comments