@@ -709,8 +709,9 @@ pub(crate) fn inherent_impl_substs(
709
709
) -> Option < Substitution > {
710
710
// we create a var for each type parameter of the impl; we need to keep in
711
711
// mind here that `self_ty` might have vars of its own
712
+ let self_ty_vars = self_ty. binders . len ( & Interner ) ;
712
713
let vars = TyBuilder :: subst_for_def ( db, impl_id)
713
- . fill_with_bound_vars ( DebruijnIndex :: INNERMOST , self_ty . binders . len ( & Interner ) )
714
+ . fill_with_bound_vars ( DebruijnIndex :: INNERMOST , self_ty_vars )
714
715
. build ( ) ;
715
716
let self_ty_with_vars = db. impl_self_ty ( impl_id) . substitute ( & Interner , & vars) ;
716
717
let mut kinds = self_ty. binders . interned ( ) . to_vec ( ) ;
@@ -725,14 +726,15 @@ pub(crate) fn inherent_impl_substs(
725
726
binders : CanonicalVarKinds :: from_iter ( & Interner , kinds) ,
726
727
value : ( self_ty_with_vars, self_ty. value . clone ( ) ) ,
727
728
} ;
728
- let substs = super :: infer:: unify ( & tys) ;
729
+ let substs = super :: infer:: unify ( & tys) ? ;
729
730
// We only want the substs for the vars we added, not the ones from self_ty.
730
731
// Also, if any of the vars we added are still in there, we replace them by
731
732
// Unknown. I think this can only really happen if self_ty contained
732
733
// Unknown, and in that case we want the result to contain Unknown in those
733
734
// places again.
734
- substs
735
- . map ( |s| fallback_bound_vars ( s. suffix ( vars. len ( & Interner ) ) , self_ty. binders . len ( & Interner ) ) )
735
+ let suffix =
736
+ Substitution :: from_iter ( & Interner , substs. iter ( & Interner ) . cloned ( ) . skip ( self_ty_vars) ) ;
737
+ Some ( fallback_bound_vars ( suffix, self_ty_vars) )
736
738
}
737
739
738
740
/// This replaces any 'free' Bound vars in `s` (i.e. those with indices past
0 commit comments