@@ -574,8 +574,8 @@ pub fn super_relate_tys<'tcx, R: TypeRelation<'tcx>>(
574574/// it.
575575pub fn super_relate_consts < ' tcx , R : TypeRelation < ' tcx > > (
576576 relation : & mut R ,
577- a : ty:: Const < ' tcx > ,
578- b : ty:: Const < ' tcx > ,
577+ mut a : ty:: Const < ' tcx > ,
578+ mut b : ty:: Const < ' tcx > ,
579579) -> RelateResult < ' tcx , ty:: Const < ' tcx > > {
580580 debug ! ( "{}.super_relate_consts(a = {:?}, b = {:?})" , relation. tag( ) , a, b) ;
581581 let tcx = relation. tcx ( ) ;
@@ -596,6 +596,17 @@ pub fn super_relate_consts<'tcx, R: TypeRelation<'tcx>>(
596596 ) ;
597597 }
598598
599+ // HACK(const_generics): We still need to eagerly evaluate consts when
600+ // relating them because during `normalize_param_env_or_error`,
601+ // we may relate an evaluated constant in a obligation against
602+ // an unnormalized (i.e. unevaluated) const in the param-env.
603+ // FIXME(generic_const_exprs): Once we always lazily unify unevaluated constants
604+ // these `eval` calls can be removed.
605+ if !relation. tcx ( ) . features ( ) . generic_const_exprs {
606+ a = a. eval ( tcx, relation. param_env ( ) ) ;
607+ b = b. eval ( tcx, relation. param_env ( ) ) ;
608+ }
609+
599610 // Currently, the values that can be unified are primitive types,
600611 // and those that derive both `PartialEq` and `Eq`, corresponding
601612 // to structural-match types.
0 commit comments