Move fallback_bound_vars to the only place it's used now
This commit is contained in:
parent
9ea2e0bd5b
commit
60aeb8fa1a
@ -9,6 +9,8 @@
|
||||
use std::{iter, sync::Arc};
|
||||
|
||||
use base_db::CrateId;
|
||||
use chalk_ir::fold::Fold;
|
||||
use chalk_ir::interner::HasInterner;
|
||||
use chalk_ir::{cast::Cast, fold::Shift, Mutability, Safety};
|
||||
use hir_def::generics::TypeOrConstParamData;
|
||||
use hir_def::intern::Interned;
|
||||
@ -36,7 +38,6 @@
|
||||
use syntax::{ast, SmolStr};
|
||||
|
||||
use crate::consteval::{path_to_const, unknown_const_as_generic, unknown_const_usize, usize_const};
|
||||
use crate::method_resolution::fallback_bound_vars;
|
||||
use crate::utils::Generics;
|
||||
use crate::{all_super_traits, make_binders, Const, GenericArgData, ParamKind};
|
||||
use crate::{
|
||||
@ -1701,3 +1702,28 @@ pub(crate) fn const_or_path_to_chalk(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 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<T: Fold<Interner> + HasInterner<Interner = Interner>>(
|
||||
s: T,
|
||||
num_vars_to_keep: usize,
|
||||
) -> T::Result {
|
||||
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)
|
||||
}
|
||||
},
|
||||
|ty, bound, binders| {
|
||||
if bound.index >= num_vars_to_keep && bound.debruijn == DebruijnIndex::INNERMOST {
|
||||
consteval::unknown_const(ty.clone())
|
||||
} else {
|
||||
bound.shifted_in_from(binders).to_const(Interner, ty)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
use arrayvec::ArrayVec;
|
||||
use base_db::{CrateId, Edition};
|
||||
use chalk_ir::{cast::Cast, fold::Fold, interner::HasInterner, Mutability, UniverseIndex};
|
||||
use chalk_ir::{cast::Cast, Mutability, UniverseIndex};
|
||||
use hir_def::{
|
||||
item_scope::ItemScope, lang_item::LangItemTarget, nameres::DefMap, AssocItemId, BlockId,
|
||||
ConstId, FunctionId, GenericDefId, HasModule, ImplId, ItemContainerId, Lookup, ModuleDefId,
|
||||
@ -18,7 +18,6 @@
|
||||
|
||||
use crate::{
|
||||
autoderef::{self, AutoderefKind},
|
||||
consteval,
|
||||
db::HirDatabase,
|
||||
from_foreign_def_id,
|
||||
infer::{unify::InferenceTable, Adjust, Adjustment, AutoBorrow, OverloadedDeref, PointerCast},
|
||||
@ -1061,31 +1060,6 @@ fn is_valid_candidate(
|
||||
}
|
||||
}
|
||||
|
||||
/// This replaces any 'free' Bound vars in `s` (i.e. those with indices past
|
||||
/// num_vars_to_keep) by `TyKind::Unknown`.
|
||||
pub(crate) fn fallback_bound_vars<T: Fold<Interner> + HasInterner<Interner = Interner>>(
|
||||
s: T,
|
||||
num_vars_to_keep: usize,
|
||||
) -> T::Result {
|
||||
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)
|
||||
}
|
||||
},
|
||||
|ty, bound, binders| {
|
||||
if bound.index >= num_vars_to_keep && bound.debruijn == DebruijnIndex::INNERMOST {
|
||||
consteval::usize_const(None)
|
||||
} else {
|
||||
bound.shifted_in_from(binders).to_const(Interner, ty)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
pub fn implements_trait(
|
||||
ty: &Canonical<Ty>,
|
||||
db: &dyn HirDatabase,
|
||||
|
Loading…
Reference in New Issue
Block a user