diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-04-05 20:59:25 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-04-05 20:59:25 +0100 |
commit | f25c1e7c6a119a1035ba226f0735a0d6667a5db8 (patch) | |
tree | 0f666c5b917de8a0f2ebf5fba185500d153036f3 /crates/hir_ty/src/method_resolution.rs | |
parent | 8c96a7d81e29061537d78b5670a3474cb136422d (diff) | |
parent | b67148daea86d85d211c4243f22635d6ac7e1983 (diff) |
Merge #8356
8356: Align more methods to Chalk r=flodiebold a=flodiebold
Related to #8313.
Move some inherent methods that don't exist in Chalk to an extension trait, remove some others.
Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/hir_ty/src/method_resolution.rs')
-rw-r--r-- | crates/hir_ty/src/method_resolution.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/crates/hir_ty/src/method_resolution.rs b/crates/hir_ty/src/method_resolution.rs index 19a1fa793..d6de844a8 100644 --- a/crates/hir_ty/src/method_resolution.rs +++ b/crates/hir_ty/src/method_resolution.rs | |||
@@ -709,8 +709,9 @@ pub(crate) fn inherent_impl_substs( | |||
709 | ) -> Option<Substitution> { | 709 | ) -> Option<Substitution> { |
710 | // we create a var for each type parameter of the impl; we need to keep in | 710 | // we create a var for each type parameter of the impl; we need to keep in |
711 | // mind here that `self_ty` might have vars of its own | 711 | // mind here that `self_ty` might have vars of its own |
712 | let self_ty_vars = self_ty.binders.len(&Interner); | ||
712 | let vars = TyBuilder::subst_for_def(db, impl_id) | 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 | .build(); | 715 | .build(); |
715 | let self_ty_with_vars = db.impl_self_ty(impl_id).substitute(&Interner, &vars); | 716 | let self_ty_with_vars = db.impl_self_ty(impl_id).substitute(&Interner, &vars); |
716 | let mut kinds = self_ty.binders.interned().to_vec(); | 717 | let mut kinds = self_ty.binders.interned().to_vec(); |
@@ -725,14 +726,15 @@ pub(crate) fn inherent_impl_substs( | |||
725 | binders: CanonicalVarKinds::from_iter(&Interner, kinds), | 726 | binders: CanonicalVarKinds::from_iter(&Interner, kinds), |
726 | value: (self_ty_with_vars, self_ty.value.clone()), | 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 | // We only want the substs for the vars we added, not the ones from self_ty. | 730 | // We only want the substs for the vars we added, not the ones from self_ty. |
730 | // Also, if any of the vars we added are still in there, we replace them by | 731 | // Also, if any of the vars we added are still in there, we replace them by |
731 | // Unknown. I think this can only really happen if self_ty contained | 732 | // Unknown. I think this can only really happen if self_ty contained |
732 | // Unknown, and in that case we want the result to contain Unknown in those | 733 | // Unknown, and in that case we want the result to contain Unknown in those |
733 | // places again. | 734 | // places again. |
734 | substs | 735 | let suffix = |
735 | .map(|s| fallback_bound_vars(s.suffix(vars.len(&Interner)), self_ty.binders.len(&Interner))) | 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 | /// This replaces any 'free' Bound vars in `s` (i.e. those with indices past | 740 | /// This replaces any 'free' Bound vars in `s` (i.e. those with indices past |