diff options
author | Florian Diebold <[email protected]> | 2021-04-07 20:26:37 +0100 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2021-04-08 13:08:55 +0100 |
commit | caee3b6c2d9a7dbcf678cc06d0c1832a4bf19be4 (patch) | |
tree | df770a02d0474c985cfb283c4386fb3711bae80f /crates/hir_ty/src/method_resolution.rs | |
parent | b25b147e8604f62a5620a5833112e358ebeeb287 (diff) |
Replace some `fold` calls
Diffstat (limited to 'crates/hir_ty/src/method_resolution.rs')
-rw-r--r-- | crates/hir_ty/src/method_resolution.rs | 29 |
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 | ||
7 | use arrayvec::ArrayVec; | 7 | use arrayvec::ArrayVec; |
8 | use base_db::CrateId; | 8 | use base_db::CrateId; |
9 | use chalk_ir::{cast::Cast, Mutability, UniverseIndex}; | 9 | use chalk_ir::{ |
10 | cast::Cast, | ||
11 | fold::{Fold, Folder}, | ||
12 | Fallible, Mutability, UniverseIndex, | ||
13 | }; | ||
10 | use hir_def::{ | 14 | use 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`. |
759 | fn fallback_bound_vars(s: Substitution, num_vars_to_keep: usize) -> Substitution { | 763 | fn 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 | ||
776 | fn transform_receiver_ty( | 773 | fn transform_receiver_ty( |