aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/method_resolution.rs
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2021-04-07 20:26:37 +0100
committerFlorian Diebold <[email protected]>2021-04-08 13:08:55 +0100
commitcaee3b6c2d9a7dbcf678cc06d0c1832a4bf19be4 (patch)
treedf770a02d0474c985cfb283c4386fb3711bae80f /crates/hir_ty/src/method_resolution.rs
parentb25b147e8604f62a5620a5833112e358ebeeb287 (diff)
Replace some `fold` calls
Diffstat (limited to 'crates/hir_ty/src/method_resolution.rs')
-rw-r--r--crates/hir_ty/src/method_resolution.rs29
1 files changed, 13 insertions, 16 deletions
diff --git a/crates/hir_ty/src/method_resolution.rs b/crates/hir_ty/src/method_resolution.rs
index 7e09a1539..766880b14 100644
--- a/crates/hir_ty/src/method_resolution.rs
+++ b/crates/hir_ty/src/method_resolution.rs
@@ -6,7 +6,11 @@ use std::{iter, sync::Arc};
6 6
7use arrayvec::ArrayVec; 7use arrayvec::ArrayVec;
8use base_db::CrateId; 8use base_db::CrateId;
9use chalk_ir::{cast::Cast, Mutability, UniverseIndex}; 9use chalk_ir::{
10 cast::Cast,
11 fold::{Fold, Folder},
12 Fallible, Mutability, UniverseIndex,
13};
10use hir_def::{ 14use hir_def::{
11 lang_item::LangItemTarget, nameres::DefMap, AssocContainerId, AssocItemId, FunctionId, 15 lang_item::LangItemTarget, nameres::DefMap, AssocContainerId, AssocItemId, FunctionId,
12 GenericDefId, HasModule, ImplId, Lookup, ModuleId, TraitId, 16 GenericDefId, HasModule, ImplId, Lookup, ModuleId, TraitId,
@@ -21,7 +25,7 @@ use crate::{
21 primitive::{self, FloatTy, IntTy, UintTy}, 25 primitive::{self, FloatTy, IntTy, UintTy},
22 static_lifetime, 26 static_lifetime,
23 utils::all_super_traits, 27 utils::all_super_traits,
24 AdtId, Canonical, CanonicalVarKinds, DebruijnIndex, FnPointer, FnSig, ForeignDefId, 28 AdtId, BoundVar, Canonical, CanonicalVarKinds, DebruijnIndex, FnPointer, FnSig, ForeignDefId,
25 InEnvironment, Interner, Scalar, Substitution, TraitEnvironment, TraitRefExt, Ty, TyBuilder, 29 InEnvironment, Interner, Scalar, Substitution, TraitEnvironment, TraitRefExt, Ty, TyBuilder,
26 TyExt, TyKind, TypeWalk, 30 TyExt, TyKind, TypeWalk,
27}; 31};
@@ -757,20 +761,13 @@ pub(crate) fn inherent_impl_substs(
757/// This replaces any 'free' Bound vars in `s` (i.e. those with indices past 761/// This replaces any 'free' Bound vars in `s` (i.e. those with indices past
758/// num_vars_to_keep) by `TyKind::Unknown`. 762/// num_vars_to_keep) by `TyKind::Unknown`.
759fn fallback_bound_vars(s: Substitution, num_vars_to_keep: usize) -> Substitution { 763fn fallback_bound_vars(s: Substitution, num_vars_to_keep: usize) -> Substitution {
760 s.fold_binders( 764 crate::fold_free_vars(s, |bound, binders| {
761 &mut |ty, binders| { 765 if bound.index >= num_vars_to_keep && bound.debruijn == DebruijnIndex::INNERMOST {
762 if let TyKind::BoundVar(bound) = ty.kind(&Interner) { 766 TyKind::Error.intern(&Interner)
763 if bound.index >= num_vars_to_keep && bound.debruijn >= binders { 767 } else {
764 TyKind::Error.intern(&Interner) 768 bound.shifted_in_from(binders).to_ty(&Interner)
765 } else { 769 }
766 ty 770 })
767 }
768 } else {
769 ty
770 }
771 },
772 DebruijnIndex::INNERMOST,
773 )
774} 771}
775 772
776fn transform_receiver_ty( 773fn transform_receiver_ty(