mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
Replace some fold
calls
This commit is contained in:
parent
b25b147e86
commit
caee3b6c2d
4 changed files with 53 additions and 47 deletions
|
@ -6,7 +6,11 @@ use std::{iter, sync::Arc};
|
|||
|
||||
use arrayvec::ArrayVec;
|
||||
use base_db::CrateId;
|
||||
use chalk_ir::{cast::Cast, Mutability, UniverseIndex};
|
||||
use chalk_ir::{
|
||||
cast::Cast,
|
||||
fold::{Fold, Folder},
|
||||
Fallible, Mutability, UniverseIndex,
|
||||
};
|
||||
use hir_def::{
|
||||
lang_item::LangItemTarget, nameres::DefMap, AssocContainerId, AssocItemId, FunctionId,
|
||||
GenericDefId, HasModule, ImplId, Lookup, ModuleId, TraitId,
|
||||
|
@ -21,7 +25,7 @@ use crate::{
|
|||
primitive::{self, FloatTy, IntTy, UintTy},
|
||||
static_lifetime,
|
||||
utils::all_super_traits,
|
||||
AdtId, Canonical, CanonicalVarKinds, DebruijnIndex, FnPointer, FnSig, ForeignDefId,
|
||||
AdtId, BoundVar, Canonical, CanonicalVarKinds, DebruijnIndex, FnPointer, FnSig, ForeignDefId,
|
||||
InEnvironment, Interner, Scalar, Substitution, TraitEnvironment, TraitRefExt, Ty, TyBuilder,
|
||||
TyExt, TyKind, TypeWalk,
|
||||
};
|
||||
|
@ -757,20 +761,13 @@ pub(crate) fn inherent_impl_substs(
|
|||
/// This replaces any 'free' Bound vars in `s` (i.e. those with indices past
|
||||
/// num_vars_to_keep) by `TyKind::Unknown`.
|
||||
fn fallback_bound_vars(s: Substitution, num_vars_to_keep: usize) -> Substitution {
|
||||
s.fold_binders(
|
||||
&mut |ty, binders| {
|
||||
if let TyKind::BoundVar(bound) = ty.kind(&Interner) {
|
||||
if bound.index >= num_vars_to_keep && bound.debruijn >= binders {
|
||||
TyKind::Error.intern(&Interner)
|
||||
} else {
|
||||
ty
|
||||
}
|
||||
} else {
|
||||
ty
|
||||
}
|
||||
},
|
||||
DebruijnIndex::INNERMOST,
|
||||
)
|
||||
crate::fold_free_vars(s, |bound, binders| {
|
||||
if bound.index >= num_vars_to_keep && bound.debruijn == DebruijnIndex::INNERMOST {
|
||||
TyKind::Error.intern(&Interner)
|
||||
} else {
|
||||
bound.shifted_in_from(binders).to_ty(&Interner)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn transform_receiver_ty(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue