about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_hir/src/db.rs6
-rw-r--r--crates/ra_hir_def/src/lib.rs8
-rw-r--r--crates/ra_hir_ty/src/db.rs4
-rw-r--r--crates/ra_hir_ty/src/lib.rs8
-rw-r--r--crates/ra_hir_ty/src/traits/chalk.rs12
-rw-r--r--crates/ra_hir_ty/src/traits/chalk/interner.rs14
-rw-r--r--crates/ra_hir_ty/src/traits/chalk/mapping.rs13
-rw-r--r--crates/ra_ide_db/src/change.rs1
8 files changed, 28 insertions, 38 deletions
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs
index 3a9973abffa..1ad92a1f81d 100644
--- a/crates/ra_hir/src/db.rs
+++ b/crates/ra_hir/src/db.rs
@@ -17,9 +17,9 @@ pub use hir_ty::db::{
     AssociatedTyDataQuery, AssociatedTyValueQuery, CallableItemSignatureQuery, FieldTypesQuery,
     GenericDefaultsQuery, GenericPredicatesForParamQuery, GenericPredicatesQuery, HirDatabase,
     HirDatabaseStorage, ImplDatumQuery, ImplSelfTyQuery, ImplTraitQuery, InferQueryQuery,
-    InherentImplsInCrateQuery, InternTypeCtorQuery, InternTypeParamIdQuery,
-    ReturnTypeImplTraitsQuery, StructDatumQuery, TraitDatumQuery, TraitImplsInCrateQuery,
-    TraitImplsInDepsQuery, TraitSolveQuery, TyQuery, ValueTyQuery,
+    InherentImplsInCrateQuery, InternTypeParamIdQuery, ReturnTypeImplTraitsQuery, StructDatumQuery,
+    TraitDatumQuery, TraitImplsInCrateQuery, TraitImplsInDepsQuery, TraitSolveQuery, TyQuery,
+    ValueTyQuery,
 };
 
 #[test]
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs
index b71d626c331..87000fe9876 100644
--- a/crates/ra_hir_def/src/lib.rs
+++ b/crates/ra_hir_def/src/lib.rs
@@ -159,17 +159,17 @@ pub struct FunctionId(salsa::InternId);
 type FunctionLoc = AssocItemLoc<Function>;
 impl_intern!(FunctionId, FunctionLoc, intern_function, lookup_intern_function);
 
-#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
 pub struct StructId(salsa::InternId);
 type StructLoc = ItemLoc<Struct>;
 impl_intern!(StructId, StructLoc, intern_struct, lookup_intern_struct);
 
-#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
 pub struct UnionId(salsa::InternId);
 pub type UnionLoc = ItemLoc<Union>;
 impl_intern!(UnionId, UnionLoc, intern_union, lookup_intern_union);
 
-#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
 pub struct EnumId(salsa::InternId);
 pub type EnumLoc = ItemLoc<Enum>;
 impl_intern!(EnumId, EnumLoc, intern_enum, lookup_intern_enum);
@@ -239,7 +239,7 @@ pub enum AssocContainerId {
 impl_from!(ContainerId for AssocContainerId);
 
 /// A Data Type
-#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
+#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
 pub enum AdtId {
     StructId(StructId),
     UnionId(UnionId),
diff --git a/crates/ra_hir_ty/src/db.rs b/crates/ra_hir_ty/src/db.rs
index d8a79877150..608bab1b182 100644
--- a/crates/ra_hir_ty/src/db.rs
+++ b/crates/ra_hir_ty/src/db.rs
@@ -14,7 +14,7 @@ use crate::{
     method_resolution::{InherentImpls, TraitImpls},
     traits::chalk,
     Binders, CallableDef, GenericPredicate, InferenceResult, OpaqueTyId, PolyFnSig,
-    ReturnTypeImplTraits, TraitRef, Ty, TyDefId, TypeCtor, ValueTyDefId,
+    ReturnTypeImplTraits, TraitRef, Ty, TyDefId, ValueTyDefId,
 };
 use hir_expand::name::Name;
 
@@ -77,8 +77,6 @@ pub trait HirDatabase: DefDatabase + Upcast<dyn DefDatabase> {
 
     // Interned IDs for Chalk integration
     #[salsa::interned]
-    fn intern_type_ctor(&self, type_ctor: TypeCtor) -> crate::TypeCtorId;
-    #[salsa::interned]
     fn intern_callable_def(&self, callable_def: CallableDef) -> crate::CallableDefId;
     #[salsa::interned]
     fn intern_type_param_id(&self, param_id: TypeParamId) -> GlobalTypeParamId;
diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs
index c4c24a83b0c..9f034eca514 100644
--- a/crates/ra_hir_ty/src/lib.rs
+++ b/crates/ra_hir_ty/src/lib.rs
@@ -112,6 +112,7 @@ pub enum TypeCtor {
     /// fn foo() -> i32 { 1 }
     /// let bar: fn() -> i32 = foo;
     /// ```
+    // FIXME make this a Ty variant like in Chalk
     FnPtr { num_args: u16, is_varargs: bool },
 
     /// The never type `!`.
@@ -139,13 +140,6 @@ pub enum TypeCtor {
     Closure { def: DefWithBodyId, expr: ExprId },
 }
 
-/// This exists just for Chalk, because Chalk just has a single `StructId` where
-/// we have different kinds of ADTs, primitive types and special type
-/// constructors like tuples and function pointers.
-#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd)]
-pub struct TypeCtorId(salsa::InternId);
-impl_intern_key!(TypeCtorId);
-
 /// This exists just for Chalk, because Chalk just has a single `FnDefId` where
 /// we have different IDs for struct and enum variant constructors.
 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd)]
diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/ra_hir_ty/src/traits/chalk.rs
index 7f8ba2f121d..1ef5baa0591 100644
--- a/crates/ra_hir_ty/src/traits/chalk.rs
+++ b/crates/ra_hir_ty/src/traits/chalk.rs
@@ -552,18 +552,6 @@ pub(crate) fn fn_def_datum_query(
     Arc::new(datum)
 }
 
-impl From<AdtId> for crate::TypeCtorId {
-    fn from(struct_id: AdtId) -> Self {
-        struct_id.0
-    }
-}
-
-impl From<crate::TypeCtorId> for AdtId {
-    fn from(type_ctor_id: crate::TypeCtorId) -> Self {
-        chalk_ir::AdtId(type_ctor_id)
-    }
-}
-
 impl From<FnDefId> for crate::CallableDefId {
     fn from(fn_def_id: FnDefId) -> Self {
         InternKey::from_intern_id(fn_def_id.0)
diff --git a/crates/ra_hir_ty/src/traits/chalk/interner.rs b/crates/ra_hir_ty/src/traits/chalk/interner.rs
index 156b691b45c..8d4c51a8ffd 100644
--- a/crates/ra_hir_ty/src/traits/chalk/interner.rs
+++ b/crates/ra_hir_ty/src/traits/chalk/interner.rs
@@ -41,7 +41,7 @@ impl chalk_ir::interner::Interner for Interner {
     type InternedCanonicalVarKinds = Vec<chalk_ir::CanonicalVarKind<Self>>;
     type InternedConstraints = Vec<chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>>;
     type DefId = InternId;
-    type InternedAdtId = crate::TypeCtorId;
+    type InternedAdtId = hir_def::AdtId;
     type Identifier = TypeAliasId;
     type FnAbi = ();
 
@@ -364,6 +364,18 @@ impl chalk_ir::interner::Interner for Interner {
     ) -> &'a [chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>] {
         constraints
     }
+    fn debug_closure_id(
+        _fn_def_id: chalk_ir::ClosureId<Self>,
+        _fmt: &mut fmt::Formatter<'_>,
+    ) -> Option<fmt::Result> {
+        None
+    }
+    fn debug_constraints(
+        _clauses: &chalk_ir::Constraints<Self>,
+        _fmt: &mut fmt::Formatter<'_>,
+    ) -> Option<fmt::Result> {
+        None
+    }
 }
 
 impl chalk_ir::interner::HasInterner for Interner {
diff --git a/crates/ra_hir_ty/src/traits/chalk/mapping.rs b/crates/ra_hir_ty/src/traits/chalk/mapping.rs
index 796947e690b..a852ce2ac1f 100644
--- a/crates/ra_hir_ty/src/traits/chalk/mapping.rs
+++ b/crates/ra_hir_ty/src/traits/chalk/mapping.rs
@@ -316,20 +316,19 @@ impl ToChalk for TypeCtor {
                 TypeName::Closure(closure_id.into())
             }
 
-            TypeCtor::FnPtr { .. } => panic!("Trying to convert FnPtr to TypeName"),
+            TypeCtor::Adt(adt_id) => TypeName::Adt(chalk_ir::AdtId(adt_id)),
 
-            TypeCtor::Adt(_) => {
-                // FIXME no interning needed anymore
-                // other TypeCtors get interned and turned into a chalk StructId
-                let struct_id = db.intern_type_ctor(self).into();
-                TypeName::Adt(struct_id)
+            TypeCtor::FnPtr { .. } => {
+                // This should not be reached, since Chalk doesn't represent
+                // function pointers with TypeName
+                unreachable!()
             }
         }
     }
 
     fn from_chalk(db: &dyn HirDatabase, type_name: TypeName<Interner>) -> TypeCtor {
         match type_name {
-            TypeName::Adt(struct_id) => db.lookup_intern_type_ctor(struct_id.into()),
+            TypeName::Adt(struct_id) => TypeCtor::Adt(struct_id.0),
             TypeName::AssociatedType(type_id) => TypeCtor::AssociatedType(from_chalk(db, type_id)),
             TypeName::OpaqueType(opaque_type_id) => {
                 TypeCtor::OpaqueType(from_chalk(db, opaque_type_id))
diff --git a/crates/ra_ide_db/src/change.rs b/crates/ra_ide_db/src/change.rs
index d40cfeb02dd..a1bb3043b6b 100644
--- a/crates/ra_ide_db/src/change.rs
+++ b/crates/ra_ide_db/src/change.rs
@@ -279,7 +279,6 @@ impl RootDatabase {
             hir::db::InternImplQuery
 
             // HirDatabase
-            hir::db::InternTypeCtorQuery
             hir::db::InternTypeParamIdQuery
         ];