aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/traits
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2020-07-15 20:47:45 +0100
committerFlorian Diebold <[email protected]>2020-07-15 21:07:13 +0100
commit20770044631fd0c21caa12f9bc87489ea6c848ee (patch)
tree27ba12638469c763874fa094744ffe3f628a7164 /crates/ra_hir_ty/src/traits
parenta48843a16a2306399f2f6a78c69d9192a6480c88 (diff)
Remove TypeCtor interning
Our TypeCtor and Chalk's TypeName match now!
Diffstat (limited to 'crates/ra_hir_ty/src/traits')
-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
3 files changed, 19 insertions, 20 deletions
diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/ra_hir_ty/src/traits/chalk.rs
index 7f8ba2f12..1ef5baa05 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(
552 Arc::new(datum) 552 Arc::new(datum)
553} 553}
554 554
555impl From<AdtId> for crate::TypeCtorId {
556 fn from(struct_id: AdtId) -> Self {
557 struct_id.0
558 }
559}
560
561impl From<crate::TypeCtorId> for AdtId {
562 fn from(type_ctor_id: crate::TypeCtorId) -> Self {
563 chalk_ir::AdtId(type_ctor_id)
564 }
565}
566
567impl From<FnDefId> for crate::CallableDefId { 555impl From<FnDefId> for crate::CallableDefId {
568 fn from(fn_def_id: FnDefId) -> Self { 556 fn from(fn_def_id: FnDefId) -> Self {
569 InternKey::from_intern_id(fn_def_id.0) 557 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 156b691b4..8d4c51a8f 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 {
41 type InternedCanonicalVarKinds = Vec<chalk_ir::CanonicalVarKind<Self>>; 41 type InternedCanonicalVarKinds = Vec<chalk_ir::CanonicalVarKind<Self>>;
42 type InternedConstraints = Vec<chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>>; 42 type InternedConstraints = Vec<chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>>;
43 type DefId = InternId; 43 type DefId = InternId;
44 type InternedAdtId = crate::TypeCtorId; 44 type InternedAdtId = hir_def::AdtId;
45 type Identifier = TypeAliasId; 45 type Identifier = TypeAliasId;
46 type FnAbi = (); 46 type FnAbi = ();
47 47
@@ -364,6 +364,18 @@ impl chalk_ir::interner::Interner for Interner {
364 ) -> &'a [chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>] { 364 ) -> &'a [chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>] {
365 constraints 365 constraints
366 } 366 }
367 fn debug_closure_id(
368 _fn_def_id: chalk_ir::ClosureId<Self>,
369 _fmt: &mut fmt::Formatter<'_>,
370 ) -> Option<fmt::Result> {
371 None
372 }
373 fn debug_constraints(
374 _clauses: &chalk_ir::Constraints<Self>,
375 _fmt: &mut fmt::Formatter<'_>,
376 ) -> Option<fmt::Result> {
377 None
378 }
367} 379}
368 380
369impl chalk_ir::interner::HasInterner for Interner { 381impl 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 796947e69..a852ce2ac 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 {
316 TypeName::Closure(closure_id.into()) 316 TypeName::Closure(closure_id.into())
317 } 317 }
318 318
319 TypeCtor::FnPtr { .. } => panic!("Trying to convert FnPtr to TypeName"), 319 TypeCtor::Adt(adt_id) => TypeName::Adt(chalk_ir::AdtId(adt_id)),
320 320
321 TypeCtor::Adt(_) => { 321 TypeCtor::FnPtr { .. } => {
322 // FIXME no interning needed anymore 322 // This should not be reached, since Chalk doesn't represent
323 // other TypeCtors get interned and turned into a chalk StructId 323 // function pointers with TypeName
324 let struct_id = db.intern_type_ctor(self).into(); 324 unreachable!()
325 TypeName::Adt(struct_id)
326 } 325 }
327 } 326 }
328 } 327 }
329 328
330 fn from_chalk(db: &dyn HirDatabase, type_name: TypeName<Interner>) -> TypeCtor { 329 fn from_chalk(db: &dyn HirDatabase, type_name: TypeName<Interner>) -> TypeCtor {
331 match type_name { 330 match type_name {
332 TypeName::Adt(struct_id) => db.lookup_intern_type_ctor(struct_id.into()), 331 TypeName::Adt(struct_id) => TypeCtor::Adt(struct_id.0),
333 TypeName::AssociatedType(type_id) => TypeCtor::AssociatedType(from_chalk(db, type_id)), 332 TypeName::AssociatedType(type_id) => TypeCtor::AssociatedType(from_chalk(db, type_id)),
334 TypeName::OpaqueType(opaque_type_id) => { 333 TypeName::OpaqueType(opaque_type_id) => {
335 TypeCtor::OpaqueType(from_chalk(db, opaque_type_id)) 334 TypeCtor::OpaqueType(from_chalk(db, opaque_type_id))