@@ -609,9 +609,27 @@ where
609
609
/// Tries to unify two abstract constants using structural equality.
610
610
pub ( super ) fn try_unify < ' tcx > (
611
611
tcx : TyCtxt < ' tcx > ,
612
- a : AbstractConst < ' tcx > ,
613
- b : AbstractConst < ' tcx > ,
612
+ mut a : AbstractConst < ' tcx > ,
613
+ mut b : AbstractConst < ' tcx > ,
614
614
) -> bool {
615
+ while let Node :: Leaf ( a_ct) = a. root ( ) {
616
+ let a_ct = a_ct. subst ( tcx, a. substs ) ;
617
+ match AbstractConst :: from_const ( tcx, a_ct) {
618
+ Ok ( Some ( a_act) ) => a = a_act,
619
+ Ok ( None ) => break ,
620
+ Err ( _) => return true ,
621
+ }
622
+ }
623
+
624
+ while let Node :: Leaf ( b_ct) = b. root ( ) {
625
+ let b_ct = b_ct. subst ( tcx, b. substs ) ;
626
+ match AbstractConst :: from_const ( tcx, b_ct) {
627
+ Ok ( Some ( b_act) ) => b = b_act,
628
+ Ok ( None ) => break ,
629
+ Err ( _) => return true ,
630
+ }
631
+ }
632
+
615
633
match ( a. root ( ) , b. root ( ) ) {
616
634
( Node :: Leaf ( a_ct) , Node :: Leaf ( b_ct) ) => {
617
635
let a_ct = a_ct. subst ( tcx, a. substs ) ;
@@ -632,8 +650,6 @@ pub(super) fn try_unify<'tcx>(
632
650
// we do not want to use `assert_eq!(a(), b())` to infer that `N` and `M` have to be `1`. This
633
651
// means that we only allow inference variables if they are equal.
634
652
( ty:: ConstKind :: Infer ( a_val) , ty:: ConstKind :: Infer ( b_val) ) => a_val == b_val,
635
- // We may want to instead recurse into unevaluated constants here. That may require some
636
- // care to prevent infinite recursion, so let's just ignore this for now.
637
653
(
638
654
ty:: ConstKind :: Unevaluated ( a_def, a_substs, None ) ,
639
655
ty:: ConstKind :: Unevaluated ( b_def, b_substs, None ) ,
0 commit comments