diff options
Diffstat (limited to 'crates/ra_hir/src/ty/traits/chalk.rs')
-rw-r--r-- | crates/ra_hir/src/ty/traits/chalk.rs | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/crates/ra_hir/src/ty/traits/chalk.rs b/crates/ra_hir/src/ty/traits/chalk.rs index e669f835b..6df7094c5 100644 --- a/crates/ra_hir/src/ty/traits/chalk.rs +++ b/crates/ra_hir/src/ty/traits/chalk.rs | |||
@@ -45,8 +45,17 @@ impl ToChalk for Ty { | |||
45 | fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::Ty { | 45 | fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::Ty { |
46 | match self { | 46 | match self { |
47 | Ty::Apply(apply_ty) => { | 47 | Ty::Apply(apply_ty) => { |
48 | let struct_id = apply_ty.ctor.to_chalk(db); | 48 | let name = match apply_ty.ctor { |
49 | let name = TypeName::TypeKindId(struct_id.into()); | 49 | TypeCtor::AssociatedType(type_alias) => { |
50 | let type_id = type_alias.to_chalk(db); | ||
51 | TypeName::AssociatedType(type_id) | ||
52 | } | ||
53 | _ => { | ||
54 | // other TypeCtors get interned and turned into a chalk StructId | ||
55 | let struct_id = apply_ty.ctor.to_chalk(db); | ||
56 | TypeName::TypeKindId(struct_id.into()) | ||
57 | } | ||
58 | }; | ||
50 | let parameters = apply_ty.parameters.to_chalk(db); | 59 | let parameters = apply_ty.parameters.to_chalk(db); |
51 | chalk_ir::ApplicationTy { name, parameters }.cast() | 60 | chalk_ir::ApplicationTy { name, parameters }.cast() |
52 | } | 61 | } |
@@ -79,15 +88,21 @@ impl ToChalk for Ty { | |||
79 | fn from_chalk(db: &impl HirDatabase, chalk: chalk_ir::Ty) -> Self { | 88 | fn from_chalk(db: &impl HirDatabase, chalk: chalk_ir::Ty) -> Self { |
80 | match chalk { | 89 | match chalk { |
81 | chalk_ir::Ty::Apply(apply_ty) => { | 90 | chalk_ir::Ty::Apply(apply_ty) => { |
91 | // FIXME this is kind of hacky due to the fact that | ||
92 | // TypeName::Placeholder is a Ty::Param on our side | ||
82 | match apply_ty.name { | 93 | match apply_ty.name { |
83 | TypeName::TypeKindId(TypeKindId::StructId(struct_id)) => { | 94 | TypeName::TypeKindId(TypeKindId::StructId(struct_id)) => { |
84 | let ctor = from_chalk(db, struct_id); | 95 | let ctor = from_chalk(db, struct_id); |
85 | let parameters = from_chalk(db, apply_ty.parameters); | 96 | let parameters = from_chalk(db, apply_ty.parameters); |
86 | Ty::Apply(ApplicationTy { ctor, parameters }) | 97 | Ty::Apply(ApplicationTy { ctor, parameters }) |
87 | } | 98 | } |
99 | TypeName::AssociatedType(type_id) => { | ||
100 | let ctor = TypeCtor::AssociatedType(from_chalk(db, type_id)); | ||
101 | let parameters = from_chalk(db, apply_ty.parameters); | ||
102 | Ty::Apply(ApplicationTy { ctor, parameters }) | ||
103 | } | ||
88 | // FIXME handle TypeKindId::Trait/Type here | 104 | // FIXME handle TypeKindId::Trait/Type here |
89 | TypeName::TypeKindId(_) => unimplemented!(), | 105 | TypeName::TypeKindId(_) => unimplemented!(), |
90 | TypeName::AssociatedType(_) => unimplemented!(), | ||
91 | TypeName::Placeholder(idx) => { | 106 | TypeName::Placeholder(idx) => { |
92 | assert_eq!(idx.ui, UniverseIndex::ROOT); | 107 | assert_eq!(idx.ui, UniverseIndex::ROOT); |
93 | Ty::Param { idx: idx.idx as u32, name: crate::Name::missing() } | 108 | Ty::Param { idx: idx.idx as u32, name: crate::Name::missing() } |