@@ -631,6 +631,15 @@ pub fn super_relate_consts<'tcx, R: TypeRelation<'tcx>>(
631631 b = b. eval ( tcx, relation. param_env ( ) ) ;
632632 }
633633
634+ if tcx. features ( ) . generic_const_exprs {
635+ if let Ok ( Some ( a2) ) = tcx. expand_abstract_consts ( a) {
636+ a = a2;
637+ }
638+ if let Ok ( Some ( b2) ) = tcx. expand_abstract_consts ( b) {
639+ b = b2
640+ }
641+ }
642+
634643 // Currently, the values that can be unified are primitive types,
635644 // and those that derive both `PartialEq` and `Eq`, corresponding
636645 // to structural-match types.
@@ -647,22 +656,6 @@ pub fn super_relate_consts<'tcx, R: TypeRelation<'tcx>>(
647656 ( ty:: ConstKind :: Placeholder ( p1) , ty:: ConstKind :: Placeholder ( p2) ) => p1 == p2,
648657 ( ty:: ConstKind :: Value ( a_val) , ty:: ConstKind :: Value ( b_val) ) => a_val == b_val,
649658
650- ( ty:: ConstKind :: Unevaluated ( _) , ty:: ConstKind :: Unevaluated ( _) )
651- if tcx. features ( ) . generic_const_exprs =>
652- {
653- // FIXME(generic_const_exprs): this spurriously fails when relating two assoc consts
654- // i.e. `<T as Trait>::ASSOC eq <T as Trait>::ASSOC` would return `false`. Wheras if
655- // both were behind an anon const that gets normalized away here it would succeed.
656- if let ( Ok ( Some ( a) ) , Ok ( Some ( b) ) ) = (
657- tcx. expand_abstract_consts ( a) ,
658- tcx. expand_abstract_consts ( b) ,
659- ) && a. ty ( ) == b. ty ( ) {
660- return relation. consts ( a, b) ;
661- } else {
662- false
663- }
664- }
665-
666659 // While this is slightly incorrect, it shouldn't matter for `min_const_generics`
667660 // and is the better alternative to waiting until `generic_const_exprs` can
668661 // be stabilized.
0 commit comments