@@ -574,8 +574,8 @@ pub fn super_relate_tys<'tcx, R: TypeRelation<'tcx>>(
574
574
/// it.
575
575
pub fn super_relate_consts < ' tcx , R : TypeRelation < ' tcx > > (
576
576
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 > ,
579
579
) -> RelateResult < ' tcx , ty:: Const < ' tcx > > {
580
580
debug ! ( "{}.super_relate_consts(a = {:?}, b = {:?})" , relation. tag( ) , a, b) ;
581
581
let tcx = relation. tcx ( ) ;
@@ -596,6 +596,17 @@ pub fn super_relate_consts<'tcx, R: TypeRelation<'tcx>>(
596
596
) ;
597
597
}
598
598
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
+
599
610
// Currently, the values that can be unified are primitive types,
600
611
// and those that derive both `PartialEq` and `Eq`, corresponding
601
612
// to structural-match types.
0 commit comments