From 429bbbd39a7bcb8650b522a9d683d20d76269770 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 3 Apr 2021 17:41:14 +0200 Subject: Make ToChalk implementations identity --- crates/hir_ty/src/traits/chalk/mapping.rs | 299 ++++-------------------------- 1 file changed, 41 insertions(+), 258 deletions(-) (limited to 'crates/hir_ty/src/traits/chalk') diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs index 701359e6f..c2e289660 100644 --- a/crates/hir_ty/src/traits/chalk/mapping.rs +++ b/crates/hir_ty/src/traits/chalk/mapping.rs @@ -21,159 +21,10 @@ use super::*; impl ToChalk for Ty { type Chalk = chalk_ir::Ty; fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Ty { - match self.into_inner() { - TyKind::Ref(m, lt, ty) => { - chalk_ir::TyKind::Ref(m, lt, ty.to_chalk(db)).intern(&Interner) - } - TyKind::Array(ty, size) => { - chalk_ir::TyKind::Array(ty.to_chalk(db), size).intern(&Interner) - } - TyKind::Function(FnPointer { sig, substitution: substs, num_binders }) => { - let substitution = chalk_ir::FnSubst(substs.0.to_chalk(db)); - chalk_ir::TyKind::Function(chalk_ir::FnPointer { num_binders, sig, substitution }) - .intern(&Interner) - } - TyKind::AssociatedType(assoc_type_id, substs) => { - let substitution = substs.to_chalk(db); - chalk_ir::TyKind::AssociatedType(assoc_type_id, substitution).intern(&Interner) - } - - TyKind::OpaqueType(id, substs) => { - let substitution = substs.to_chalk(db); - chalk_ir::TyKind::OpaqueType(id, substitution).intern(&Interner) - } - - TyKind::Foreign(id) => chalk_ir::TyKind::Foreign(id).intern(&Interner), - - TyKind::Scalar(scalar) => chalk_ir::TyKind::Scalar(scalar).intern(&Interner), - - TyKind::Tuple(cardinality, substs) => { - let substitution = substs.to_chalk(db); - chalk_ir::TyKind::Tuple(cardinality, substitution).intern(&Interner) - } - TyKind::Raw(mutability, ty) => { - let ty = ty.to_chalk(db); - chalk_ir::TyKind::Raw(mutability, ty).intern(&Interner) - } - TyKind::Slice(ty) => chalk_ir::TyKind::Slice(ty.to_chalk(db)).intern(&Interner), - TyKind::Str => chalk_ir::TyKind::Str.intern(&Interner), - TyKind::FnDef(id, substs) => { - let substitution = substs.to_chalk(db); - chalk_ir::TyKind::FnDef(id, substitution).intern(&Interner) - } - TyKind::Never => chalk_ir::TyKind::Never.intern(&Interner), - - TyKind::Closure(closure_id, substs) => { - let substitution = substs.to_chalk(db); - chalk_ir::TyKind::Closure(closure_id, substitution).intern(&Interner) - } - - TyKind::Adt(adt_id, substs) => { - let substitution = substs.to_chalk(db); - chalk_ir::TyKind::Adt(adt_id, substitution).intern(&Interner) - } - TyKind::Alias(AliasTy::Projection(proj_ty)) => { - chalk_ir::AliasTy::Projection(proj_ty.to_chalk(db)) - .cast(&Interner) - .intern(&Interner) - } - TyKind::Alias(AliasTy::Opaque(opaque_ty)) => { - chalk_ir::AliasTy::Opaque(opaque_ty.to_chalk(db)).cast(&Interner).intern(&Interner) - } - TyKind::Placeholder(idx) => idx.to_ty::(&Interner), - TyKind::BoundVar(idx) => chalk_ir::TyKind::BoundVar(idx).intern(&Interner), - TyKind::InferenceVar(..) => panic!("uncanonicalized infer ty"), - TyKind::Dyn(dyn_ty) => { - let (bounds, binders) = dyn_ty.bounds.into_value_and_skipped_binders(); - let where_clauses = chalk_ir::QuantifiedWhereClauses::from_iter( - &Interner, - bounds.interned().iter().cloned().map(|p| p.to_chalk(db)), - ); - let bounded_ty = chalk_ir::DynTy { - bounds: chalk_ir::Binders::new(binders, where_clauses), - lifetime: dyn_ty.lifetime, - }; - chalk_ir::TyKind::Dyn(bounded_ty).intern(&Interner) - } - TyKind::Error => chalk_ir::TyKind::Error.intern(&Interner), - } + self } fn from_chalk(db: &dyn HirDatabase, chalk: chalk_ir::Ty) -> Self { - match chalk.data(&Interner).kind.clone() { - chalk_ir::TyKind::Error => TyKind::Error, - chalk_ir::TyKind::Array(ty, size) => TyKind::Array(from_chalk(db, ty), size), - chalk_ir::TyKind::Placeholder(idx) => TyKind::Placeholder(idx), - chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Projection(proj)) => { - TyKind::Alias(AliasTy::Projection(from_chalk(db, proj))) - } - chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Opaque(opaque_ty)) => { - TyKind::Alias(AliasTy::Opaque(from_chalk(db, opaque_ty))) - } - chalk_ir::TyKind::Function(chalk_ir::FnPointer { - num_binders, - sig, - substitution, - .. - }) => { - assert_eq!(num_binders, 0); - let substs = crate::FnSubst(from_chalk(db, substitution.0)); - TyKind::Function(FnPointer { num_binders, sig, substitution: substs }) - } - chalk_ir::TyKind::BoundVar(idx) => TyKind::BoundVar(idx), - chalk_ir::TyKind::InferenceVar(_iv, _kind) => TyKind::Error, - chalk_ir::TyKind::Dyn(dyn_ty) => { - assert_eq!(dyn_ty.bounds.binders.len(&Interner), 1); - let (bounds, binders) = dyn_ty.bounds.into_value_and_skipped_binders(); - let where_clauses = crate::QuantifiedWhereClauses::from_iter( - &Interner, - bounds.interned().iter().cloned().map(|p| from_chalk(db, p)), - ); - TyKind::Dyn(crate::DynTy { - bounds: crate::Binders::new(binders, where_clauses), - // HACK: we sometimes get lifetime variables back in solutions - // from Chalk, and don't have the infrastructure to substitute - // them yet. So for now we just turn them into 'static right - // when we get them - lifetime: static_lifetime(), - }) - } - - chalk_ir::TyKind::Adt(adt_id, subst) => TyKind::Adt(adt_id, from_chalk(db, subst)), - chalk_ir::TyKind::AssociatedType(type_id, subst) => { - TyKind::AssociatedType(type_id, from_chalk(db, subst)) - } - - chalk_ir::TyKind::OpaqueType(opaque_type_id, subst) => { - TyKind::OpaqueType(opaque_type_id, from_chalk(db, subst)) - } - - chalk_ir::TyKind::Scalar(scalar) => TyKind::Scalar(scalar), - chalk_ir::TyKind::Tuple(cardinality, subst) => { - TyKind::Tuple(cardinality, from_chalk(db, subst)) - } - chalk_ir::TyKind::Raw(mutability, ty) => TyKind::Raw(mutability, from_chalk(db, ty)), - chalk_ir::TyKind::Slice(ty) => TyKind::Slice(from_chalk(db, ty)), - chalk_ir::TyKind::Ref(mutability, _lifetime, ty) => { - // HACK: we sometimes get lifetime variables back in solutions - // from Chalk, and don't have the infrastructure to substitute - // them yet. So for now we just turn them into 'static right - // when we get them - TyKind::Ref(mutability, static_lifetime(), from_chalk(db, ty)) - } - chalk_ir::TyKind::Str => TyKind::Str, - chalk_ir::TyKind::Never => TyKind::Never, - - chalk_ir::TyKind::FnDef(fn_def_id, subst) => { - TyKind::FnDef(fn_def_id, from_chalk(db, subst)) - } - - chalk_ir::TyKind::Closure(id, subst) => TyKind::Closure(id, from_chalk(db, subst)), - - chalk_ir::TyKind::Foreign(foreign_def_id) => TyKind::Foreign(foreign_def_id), - chalk_ir::TyKind::Generator(_, _) => unimplemented!(), // FIXME - chalk_ir::TyKind::GeneratorWitness(_, _) => unimplemented!(), // FIXME - } - .intern(&Interner) + chalk } } @@ -181,17 +32,11 @@ impl ToChalk for GenericArg { type Chalk = chalk_ir::GenericArg; fn to_chalk(self, db: &dyn HirDatabase) -> Self::Chalk { - match self.interned() { - crate::GenericArgData::Ty(ty) => ty.clone().to_chalk(db).cast(&Interner), - } + self } fn from_chalk(db: &dyn HirDatabase, chalk: Self::Chalk) -> Self { - match chalk.interned() { - chalk_ir::GenericArgData::Ty(ty) => Ty::from_chalk(db, ty.clone()).cast(&Interner), - chalk_ir::GenericArgData::Lifetime(_) => unimplemented!(), - chalk_ir::GenericArgData::Const(_) => unimplemented!(), - } + chalk } } @@ -199,18 +44,14 @@ impl ToChalk for Substitution { type Chalk = chalk_ir::Substitution; fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Substitution { - chalk_ir::Substitution::from_iter( - &Interner, - self.iter(&Interner).map(|ty| ty.clone().to_chalk(db)), - ) + self } fn from_chalk( db: &dyn HirDatabase, parameters: chalk_ir::Substitution, ) -> Substitution { - let tys = parameters.iter(&Interner).map(|p| from_chalk(db, p.clone())).collect(); - Substitution::intern(tys) + parameters } } @@ -218,15 +59,11 @@ impl ToChalk for TraitRef { type Chalk = chalk_ir::TraitRef; fn to_chalk(self: TraitRef, db: &dyn HirDatabase) -> chalk_ir::TraitRef { - let trait_id = self.trait_id; - let substitution = self.substitution.to_chalk(db); - chalk_ir::TraitRef { trait_id, substitution } + self } fn from_chalk(db: &dyn HirDatabase, trait_ref: chalk_ir::TraitRef) -> Self { - let trait_id = trait_ref.trait_id; - let substs = from_chalk(db, trait_ref.substitution); - TraitRef { trait_id, substitution: substs } + trait_ref } } @@ -287,34 +124,14 @@ impl ToChalk for WhereClause { type Chalk = chalk_ir::WhereClause; fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::WhereClause { - match self { - WhereClause::Implemented(trait_ref) => { - chalk_ir::WhereClause::Implemented(trait_ref.to_chalk(db)) - } - WhereClause::AliasEq(alias_eq) => chalk_ir::WhereClause::AliasEq(alias_eq.to_chalk(db)), - } + self } fn from_chalk( db: &dyn HirDatabase, where_clause: chalk_ir::WhereClause, ) -> WhereClause { - match where_clause { - chalk_ir::WhereClause::Implemented(tr) => WhereClause::Implemented(from_chalk(db, tr)), - chalk_ir::WhereClause::AliasEq(alias_eq) => { - WhereClause::AliasEq(from_chalk(db, alias_eq)) - } - - chalk_ir::WhereClause::LifetimeOutlives(_) => { - // we shouldn't get these from Chalk - panic!("encountered LifetimeOutlives from Chalk") - } - - chalk_ir::WhereClause::TypeOutlives(_) => { - // we shouldn't get these from Chalk - panic!("encountered TypeOutlives from Chalk") - } - } + where_clause } } @@ -322,37 +139,25 @@ impl ToChalk for ProjectionTy { type Chalk = chalk_ir::ProjectionTy; fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::ProjectionTy { - chalk_ir::ProjectionTy { - associated_ty_id: self.associated_ty_id, - substitution: self.substitution.to_chalk(db), - } + self } fn from_chalk( db: &dyn HirDatabase, projection_ty: chalk_ir::ProjectionTy, ) -> ProjectionTy { - ProjectionTy { - associated_ty_id: projection_ty.associated_ty_id, - substitution: from_chalk(db, projection_ty.substitution), - } + projection_ty } } impl ToChalk for OpaqueTy { type Chalk = chalk_ir::OpaqueTy; fn to_chalk(self, db: &dyn HirDatabase) -> Self::Chalk { - chalk_ir::OpaqueTy { - opaque_ty_id: self.opaque_ty_id, - substitution: self.substitution.to_chalk(db), - } + self } fn from_chalk(db: &dyn HirDatabase, chalk: Self::Chalk) -> Self { - OpaqueTy { - opaque_ty_id: chalk.opaque_ty_id, - substitution: from_chalk(db, chalk.substitution), - } + chalk } } @@ -360,21 +165,11 @@ impl ToChalk for AliasTy { type Chalk = chalk_ir::AliasTy; fn to_chalk(self, db: &dyn HirDatabase) -> Self::Chalk { - match self { - AliasTy::Projection(projection_ty) => { - chalk_ir::AliasTy::Projection(projection_ty.to_chalk(db)) - } - AliasTy::Opaque(opaque_ty) => chalk_ir::AliasTy::Opaque(opaque_ty.to_chalk(db)), - } + self } fn from_chalk(db: &dyn HirDatabase, chalk: Self::Chalk) -> Self { - match chalk { - chalk_ir::AliasTy::Projection(projection_ty) => { - AliasTy::Projection(from_chalk(db, projection_ty)) - } - chalk_ir::AliasTy::Opaque(opaque_ty) => AliasTy::Opaque(from_chalk(db, opaque_ty)), - } + chalk } } @@ -382,11 +177,11 @@ impl ToChalk for AliasEq { type Chalk = chalk_ir::AliasEq; fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::AliasEq { - chalk_ir::AliasEq { alias: self.alias.to_chalk(db), ty: self.ty.to_chalk(db) } + self } fn from_chalk(db: &dyn HirDatabase, alias_eq: chalk_ir::AliasEq) -> Self { - AliasEq { alias: from_chalk(db, alias_eq.alias), ty: from_chalk(db, alias_eq.ty) } + alias_eq } } @@ -394,68 +189,56 @@ impl ToChalk for DomainGoal { type Chalk = chalk_ir::DomainGoal; fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::DomainGoal { - match self { - DomainGoal::Holds(WhereClause::Implemented(tr)) => tr.to_chalk(db).cast(&Interner), - DomainGoal::Holds(WhereClause::AliasEq(alias_eq)) => { - alias_eq.to_chalk(db).cast(&Interner) - } - } + self } - fn from_chalk(_db: &dyn HirDatabase, _goal: chalk_ir::DomainGoal) -> Self { - unimplemented!() + fn from_chalk(_db: &dyn HirDatabase, goal: chalk_ir::DomainGoal) -> Self { + goal } } impl ToChalk for Canonical where - T: ToChalk, - T::Chalk: HasInterner, + T: HasInterner, { - type Chalk = chalk_ir::Canonical; + type Chalk = chalk_ir::Canonical; - fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Canonical { - let value = self.value.to_chalk(db); - chalk_ir::Canonical { value, binders: self.binders } + fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Canonical { + self } - fn from_chalk(db: &dyn HirDatabase, canonical: chalk_ir::Canonical) -> Canonical { - Canonical { binders: canonical.binders, value: from_chalk(db, canonical.value) } + fn from_chalk(db: &dyn HirDatabase, canonical: chalk_ir::Canonical) -> Canonical { + canonical } } impl ToChalk for InEnvironment where - T::Chalk: chalk_ir::interner::HasInterner, + T: HasInterner, { - type Chalk = chalk_ir::InEnvironment; + type Chalk = chalk_ir::InEnvironment; - fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::InEnvironment { - chalk_ir::InEnvironment { environment: self.environment, goal: self.goal.to_chalk(db) } + fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::InEnvironment { + self } - fn from_chalk( - _db: &dyn HirDatabase, - _in_env: chalk_ir::InEnvironment, - ) -> InEnvironment { - unimplemented!() + fn from_chalk(_db: &dyn HirDatabase, in_env: chalk_ir::InEnvironment) -> InEnvironment { + in_env } } impl ToChalk for crate::Binders where - T::Chalk: chalk_ir::interner::HasInterner, + T: HasInterner, { - type Chalk = chalk_ir::Binders; + type Chalk = chalk_ir::Binders; - fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Binders { - let (value, binders) = self.into_value_and_skipped_binders(); - chalk_ir::Binders::new(binders, value.to_chalk(db)) + fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Binders { + self } - fn from_chalk(db: &dyn HirDatabase, binders: chalk_ir::Binders) -> crate::Binders { - let (v, b) = binders.into_value_and_skipped_binders(); - crate::Binders::new(b, from_chalk(db, v)) + fn from_chalk(db: &dyn HirDatabase, binders: chalk_ir::Binders) -> crate::Binders { + binders } } @@ -463,11 +246,11 @@ impl ToChalk for crate::ConstrainedSubst { type Chalk = chalk_ir::ConstrainedSubst; fn to_chalk(self, _db: &dyn HirDatabase) -> Self::Chalk { - unimplemented!() + self } fn from_chalk(db: &dyn HirDatabase, chalk: Self::Chalk) -> Self { - ConstrainedSubst { subst: from_chalk(db, chalk.subst) } + chalk } } -- cgit v1.2.3 From b25b147e8604f62a5620a5833112e358ebeeb287 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Wed, 7 Apr 2021 21:26:24 +0200 Subject: Fix shifted_{in,out} calls --- crates/hir_ty/src/traits/chalk/mapping.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/hir_ty/src/traits/chalk') diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs index c2e289660..62cf0fecf 100644 --- a/crates/hir_ty/src/traits/chalk/mapping.rs +++ b/crates/hir_ty/src/traits/chalk/mapping.rs @@ -288,7 +288,7 @@ pub(super) fn generic_predicate_to_inline_bound( ) -> Option>> { // An InlineBound is like a GenericPredicate, except the self type is left out. // We don't have a special type for this, but Chalk does. - let self_ty_shifted_in = self_ty.clone().shifted_in_from(DebruijnIndex::ONE); + let self_ty_shifted_in = self_ty.clone().shifted_in_from(&Interner, DebruijnIndex::ONE); let (pred, binders) = pred.as_ref().into_value_and_skipped_binders(); match pred { WhereClause::Implemented(trait_ref) => { -- cgit v1.2.3 From 8ce6fea325c001deeed2857da560fa5cfbc6eea3 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Thu, 8 Apr 2021 14:16:05 +0200 Subject: Remove identity impls for ToChalk --- crates/hir_ty/src/traits/chalk/mapping.rs | 191 +----------------------------- 1 file changed, 4 insertions(+), 187 deletions(-) (limited to 'crates/hir_ty/src/traits/chalk') diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs index 62cf0fecf..54783b58c 100644 --- a/crates/hir_ty/src/traits/chalk/mapping.rs +++ b/crates/hir_ty/src/traits/chalk/mapping.rs @@ -18,55 +18,6 @@ use crate::{ use super::interner::*; use super::*; -impl ToChalk for Ty { - type Chalk = chalk_ir::Ty; - fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Ty { - self - } - fn from_chalk(db: &dyn HirDatabase, chalk: chalk_ir::Ty) -> Self { - chalk - } -} - -impl ToChalk for GenericArg { - type Chalk = chalk_ir::GenericArg; - - fn to_chalk(self, db: &dyn HirDatabase) -> Self::Chalk { - self - } - - fn from_chalk(db: &dyn HirDatabase, chalk: Self::Chalk) -> Self { - chalk - } -} - -impl ToChalk for Substitution { - type Chalk = chalk_ir::Substitution; - - fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Substitution { - self - } - - fn from_chalk( - db: &dyn HirDatabase, - parameters: chalk_ir::Substitution, - ) -> Substitution { - parameters - } -} - -impl ToChalk for TraitRef { - type Chalk = chalk_ir::TraitRef; - - fn to_chalk(self: TraitRef, db: &dyn HirDatabase) -> chalk_ir::TraitRef { - self - } - - fn from_chalk(db: &dyn HirDatabase, trait_ref: chalk_ir::TraitRef) -> Self { - trait_ref - } -} - impl ToChalk for hir_def::TraitId { type Chalk = TraitId; @@ -120,140 +71,6 @@ impl ToChalk for TypeAliasAsValue { } } -impl ToChalk for WhereClause { - type Chalk = chalk_ir::WhereClause; - - fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::WhereClause { - self - } - - fn from_chalk( - db: &dyn HirDatabase, - where_clause: chalk_ir::WhereClause, - ) -> WhereClause { - where_clause - } -} - -impl ToChalk for ProjectionTy { - type Chalk = chalk_ir::ProjectionTy; - - fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::ProjectionTy { - self - } - - fn from_chalk( - db: &dyn HirDatabase, - projection_ty: chalk_ir::ProjectionTy, - ) -> ProjectionTy { - projection_ty - } -} -impl ToChalk for OpaqueTy { - type Chalk = chalk_ir::OpaqueTy; - - fn to_chalk(self, db: &dyn HirDatabase) -> Self::Chalk { - self - } - - fn from_chalk(db: &dyn HirDatabase, chalk: Self::Chalk) -> Self { - chalk - } -} - -impl ToChalk for AliasTy { - type Chalk = chalk_ir::AliasTy; - - fn to_chalk(self, db: &dyn HirDatabase) -> Self::Chalk { - self - } - - fn from_chalk(db: &dyn HirDatabase, chalk: Self::Chalk) -> Self { - chalk - } -} - -impl ToChalk for AliasEq { - type Chalk = chalk_ir::AliasEq; - - fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::AliasEq { - self - } - - fn from_chalk(db: &dyn HirDatabase, alias_eq: chalk_ir::AliasEq) -> Self { - alias_eq - } -} - -impl ToChalk for DomainGoal { - type Chalk = chalk_ir::DomainGoal; - - fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::DomainGoal { - self - } - - fn from_chalk(_db: &dyn HirDatabase, goal: chalk_ir::DomainGoal) -> Self { - goal - } -} - -impl ToChalk for Canonical -where - T: HasInterner, -{ - type Chalk = chalk_ir::Canonical; - - fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Canonical { - self - } - - fn from_chalk(db: &dyn HirDatabase, canonical: chalk_ir::Canonical) -> Canonical { - canonical - } -} - -impl ToChalk for InEnvironment -where - T: HasInterner, -{ - type Chalk = chalk_ir::InEnvironment; - - fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::InEnvironment { - self - } - - fn from_chalk(_db: &dyn HirDatabase, in_env: chalk_ir::InEnvironment) -> InEnvironment { - in_env - } -} - -impl ToChalk for crate::Binders -where - T: HasInterner, -{ - type Chalk = chalk_ir::Binders; - - fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Binders { - self - } - - fn from_chalk(db: &dyn HirDatabase, binders: chalk_ir::Binders) -> crate::Binders { - binders - } -} - -impl ToChalk for crate::ConstrainedSubst { - type Chalk = chalk_ir::ConstrainedSubst; - - fn to_chalk(self, _db: &dyn HirDatabase) -> Self::Chalk { - self - } - - fn from_chalk(db: &dyn HirDatabase, chalk: Self::Chalk) -> Self { - chalk - } -} - pub(super) fn make_binders(value: T, num_vars: usize) -> chalk_ir::Binders where T: HasInterner, @@ -276,7 +93,7 @@ pub(super) fn convert_where_clauses( let generic_predicates = db.generic_predicates(def); let mut result = Vec::with_capacity(generic_predicates.len()); for pred in generic_predicates.iter() { - result.push(pred.clone().substitute(&Interner, substs).to_chalk(db)); + result.push(pred.clone().substitute(&Interner, substs)); } result } @@ -299,7 +116,7 @@ pub(super) fn generic_predicate_to_inline_bound( } let args_no_self = trait_ref.substitution.interned()[1..] .iter() - .map(|ty| ty.clone().to_chalk(db).cast(&Interner)) + .map(|ty| ty.clone().cast(&Interner)) .collect(); let trait_bound = rust_ir::TraitBound { trait_id: trait_ref.trait_id, args_no_self }; Some(chalk_ir::Binders::new(binders, rust_ir::InlineBound::TraitBound(trait_bound))) @@ -311,10 +128,10 @@ pub(super) fn generic_predicate_to_inline_bound( let trait_ = projection_ty.trait_(db); let args_no_self = projection_ty.substitution.interned()[1..] .iter() - .map(|ty| ty.clone().to_chalk(db).cast(&Interner)) + .map(|ty| ty.clone().cast(&Interner)) .collect(); let alias_eq_bound = rust_ir::AliasEqBound { - value: ty.clone().to_chalk(db), + value: ty.clone(), trait_bound: rust_ir::TraitBound { trait_id: trait_.to_chalk(db), args_no_self }, associated_ty_id: projection_ty.associated_ty_id, parameters: Vec::new(), // FIXME we don't support generic associated types yet -- cgit v1.2.3 From 8040f4a5e3792f95b3194e21b3f6d375fb7499c5 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Thu, 8 Apr 2021 14:21:22 +0200 Subject: Replace `make_binders` by the now equivalent `make_only_type_binders` --- crates/hir_ty/src/traits/chalk/mapping.rs | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'crates/hir_ty/src/traits/chalk') diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs index 54783b58c..4abc0fbf2 100644 --- a/crates/hir_ty/src/traits/chalk/mapping.rs +++ b/crates/hir_ty/src/traits/chalk/mapping.rs @@ -71,20 +71,6 @@ impl ToChalk for TypeAliasAsValue { } } -pub(super) fn make_binders(value: T, num_vars: usize) -> chalk_ir::Binders -where - T: HasInterner, -{ - chalk_ir::Binders::new( - chalk_ir::VariableKinds::from_iter( - &Interner, - std::iter::repeat(chalk_ir::VariableKind::Ty(chalk_ir::TyVariableKind::General)) - .take(num_vars), - ), - value, - ) -} - pub(super) fn convert_where_clauses( db: &dyn HirDatabase, def: GenericDefId, -- cgit v1.2.3 From d992736e796501b2a5ae232644924a3dfefede92 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Thu, 8 Apr 2021 14:35:15 +0200 Subject: Remove unused --- crates/hir_ty/src/traits/chalk/mapping.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'crates/hir_ty/src/traits/chalk') diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs index 4abc0fbf2..7818f6387 100644 --- a/crates/hir_ty/src/traits/chalk/mapping.rs +++ b/crates/hir_ty/src/traits/chalk/mapping.rs @@ -3,16 +3,15 @@ //! Chalk (in both directions); plus some helper functions for more specialized //! conversions. -use chalk_ir::{cast::Cast, interner::HasInterner}; +use chalk_ir::cast::Cast; use chalk_solve::rust_ir; use base_db::salsa::InternKey; use hir_def::{GenericDefId, TypeAliasId}; use crate::{ - db::HirDatabase, static_lifetime, AliasTy, CallableDefId, Canonical, ConstrainedSubst, - DomainGoal, FnPointer, GenericArg, InEnvironment, OpaqueTy, ProjectionTy, ProjectionTyExt, - QuantifiedWhereClause, Substitution, TraitRef, Ty, TypeWalk, WhereClause, + db::HirDatabase, AliasTy, CallableDefId, ProjectionTyExt, QuantifiedWhereClause, Substitution, + Ty, WhereClause, }; use super::interner::*; -- cgit v1.2.3