Binders::wrap_empty -> wrap_empty_binders

This commit is contained in:
Florian Diebold 2021-04-05 21:25:40 +02:00
parent 2f5a77658b
commit 738174671a
3 changed files with 12 additions and 16 deletions

View File

@ -92,13 +92,11 @@ pub fn param_idx(db: &dyn HirDatabase, id: TypeParamId) -> Option<usize> {
generics(db.upcast(), id.parent).param_idx(id)
}
impl<T> Binders<T> {
pub fn wrap_empty(value: T) -> Self
where
T: TypeWalk,
{
Binders::empty(&Interner, value.shifted_in_from(DebruijnIndex::ONE))
}
pub fn wrap_empty_binders<T>(value: T) -> Binders<T>
where
T: TypeWalk,
{
Binders::empty(&Interner, value.shifted_in_from(DebruijnIndex::ONE))
}
impl<T: TypeWalk> Binders<T> {

View File

@ -384,7 +384,9 @@ impl<'a> TyLoweringContext<'a> {
1,
QuantifiedWhereClauses::from_iter(
&Interner,
Some(Binders::wrap_empty(WhereClause::Implemented(trait_ref))),
Some(crate::wrap_empty_binders(WhereClause::Implemented(
trait_ref,
))),
),
),
};
@ -720,7 +722,7 @@ impl<'a> TyLoweringContext<'a> {
let trait_ref = match bound {
TypeBound::Path(path) => {
bindings = self.lower_trait_ref_from_path(path, Some(self_ty));
bindings.clone().map(WhereClause::Implemented).map(|b| Binders::wrap_empty(b))
bindings.clone().map(WhereClause::Implemented).map(|b| crate::wrap_empty_binders(b))
}
TypeBound::Lifetime(_) => None,
TypeBound::Error => None,
@ -767,7 +769,7 @@ impl<'a> TyLoweringContext<'a> {
let ty = self.lower_ty(type_ref);
let alias_eq =
AliasEq { alias: AliasTy::Projection(projection_ty.clone()), ty };
preds.push(Binders::wrap_empty(WhereClause::AliasEq(alias_eq)));
preds.push(crate::wrap_empty_binders(WhereClause::AliasEq(alias_eq)));
}
for bound in &binding.bounds {
preds.extend(self.lower_type_bound(

View File

@ -246,8 +246,8 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
let bound = OpaqueTyDatumBound {
bounds: make_binders(
vec![
wrap_in_empty_binders(impl_bound).to_chalk(self.db),
wrap_in_empty_binders(proj_bound).to_chalk(self.db),
crate::wrap_empty_binders(impl_bound).to_chalk(self.db),
crate::wrap_empty_binders(proj_bound).to_chalk(self.db),
],
1,
),
@ -723,7 +723,3 @@ impl From<crate::db::InternedClosureId> for chalk_ir::ClosureId<Interner> {
chalk_ir::ClosureId(id.as_intern_id())
}
}
fn wrap_in_empty_binders<T: crate::TypeWalk>(value: T) -> crate::Binders<T> {
crate::Binders::wrap_empty(value)
}