@@ -925,10 +925,7 @@ where
925925 // show up in the bounds, but just ones that come from substituting
926926 // `Self` with the dyn type.
927927 let proj = proj. with_self_ty ( cx, trait_ref. self_ty ( ) ) ;
928- replace_projection_with
929- . entry ( proj. def_id ( ) . into ( ) )
930- . or_default ( )
931- . push ( bound. rebind ( proj) ) ;
928+ replace_projection_with. entry ( proj. def_id ( ) ) . or_default ( ) . push ( bound. rebind ( proj) ) ;
932929 }
933930 }
934931
@@ -952,7 +949,7 @@ struct ReplaceProjectionWith<'a, 'b, I: Interner, D: SolverDelegate<Interner = I
952949 ecx : & ' a mut EvalCtxt < ' b , D > ,
953950 param_env : I :: ParamEnv ,
954951 self_ty : I :: Ty ,
955- mapping : & ' a HashMap < I :: DefId , Vec < ty:: Binder < I , ty:: ProjectionPredicate < I > > > > ,
952+ mapping : & ' a HashMap < I :: TraitAssocTermId , Vec < ty:: Binder < I , ty:: ProjectionPredicate < I > > > > ,
956953 nested : Vec < Goal < I , I :: Predicate > > ,
957954}
958955
@@ -965,8 +962,9 @@ where
965962 & mut self ,
966963 source_projection : ty:: Binder < I , ty:: ProjectionPredicate < I > > ,
967964 target_projection : ty:: AliasTerm < I > ,
965+ target_projection_def_id : I :: TraitAssocTermId ,
968966 ) -> bool {
969- source_projection. item_def_id ( ) == target_projection . def_id ( )
967+ source_projection. item_def_id ( ) == target_projection_def_id
970968 && self
971969 . ecx
972970 . probe ( |_| ProbeKind :: ProjectionCompatibility )
@@ -985,21 +983,22 @@ where
985983 fn try_eagerly_replace_alias (
986984 & mut self ,
987985 alias_term : ty:: AliasTerm < I > ,
986+ alias_term_def_id : I :: TraitAssocTermId ,
988987 ) -> Result < Option < I :: Term > , Ambiguous > {
989988 if alias_term. self_ty ( ) != self . self_ty {
990989 return Ok ( None ) ;
991990 }
992991
993- let Some ( replacements) = self . mapping . get ( & alias_term . def_id ( ) ) else {
992+ let Some ( replacements) = self . mapping . get ( & alias_term_def_id ) else {
994993 return Ok ( None ) ;
995994 } ;
996995
997996 // This is quite similar to the `projection_may_match` we use in unsizing,
998997 // but here we want to unify a projection predicate against an alias term
999998 // so we can replace it with the projection predicate's term.
1000- let mut matching_projections = replacements
1001- . iter ( )
1002- . filter ( |source_projection| self . projection_may_match ( * * source_projection , alias_term ) ) ;
999+ let mut matching_projections = replacements. iter ( ) . filter ( |source_projection| {
1000+ self . projection_may_match ( * * source_projection , alias_term , alias_term_def_id )
1001+ } ) ;
10031002 let Some ( replacement) = matching_projections. next ( ) else {
10041003 // This shouldn't happen.
10051004 panic ! ( "could not replace {alias_term:?} with term from from {:?}" , self . self_ty) ;
@@ -1038,8 +1037,8 @@ where
10381037 }
10391038
10401039 fn try_fold_ty ( & mut self , ty : I :: Ty ) -> Result < I :: Ty , Ambiguous > {
1041- if let ty:: Alias ( alias_ty @ ty:: AliasTy { kind : ty:: Projection { .. } , .. } ) = ty. kind ( )
1042- && let Some ( term) = self . try_eagerly_replace_alias ( alias_ty. into ( ) ) ?
1040+ if let ty:: Alias ( alias_ty @ ty:: AliasTy { kind : ty:: Projection { def_id } , .. } ) = ty. kind ( )
1041+ && let Some ( term) = self . try_eagerly_replace_alias ( alias_ty. into ( ) , def_id . into ( ) ) ?
10431042 {
10441043 Ok ( term. expect_ty ( ) )
10451044 } else {
0 commit comments