aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-12-21 13:46:15 +0000
committerFlorian Diebold <[email protected]>2019-12-22 23:08:03 +0000
commit6b5efe5bdab160278469417734f4bb619c7bac61 (patch)
treea1b398f6ace8141cabb01c0cc569983bd1213474
parent67a2555f6d4c3914742fd42645ca043cf56f358b (diff)
Refactor Chalk integration some more
-rw-r--r--crates/ra_hir_ty/src/traits.rs14
-rw-r--r--crates/ra_hir_ty/src/traits/chalk.rs148
2 files changed, 83 insertions, 79 deletions
diff --git a/crates/ra_hir_ty/src/traits.rs b/crates/ra_hir_ty/src/traits.rs
index 46e17f0b8..fbab60925 100644
--- a/crates/ra_hir_ty/src/traits.rs
+++ b/crates/ra_hir_ty/src/traits.rs
@@ -1,7 +1,7 @@
1//! Trait solving using Chalk. 1//! Trait solving using Chalk.
2use std::sync::{Arc, Mutex}; 2use std::sync::{Arc, Mutex};
3 3
4use chalk_ir::{cast::Cast, family::ChalkIr}; 4use chalk_ir::cast::Cast;
5use hir_def::{expr::ExprId, DefWithBodyId, ImplId, TraitId, TypeAliasId}; 5use hir_def::{expr::ExprId, DefWithBodyId, ImplId, TraitId, TypeAliasId};
6use log::debug; 6use log::debug;
7use ra_db::{impl_intern_key, salsa, CrateId}; 7use ra_db::{impl_intern_key, salsa, CrateId};
@@ -12,7 +12,7 @@ use crate::db::HirDatabase;
12 12
13use super::{Canonical, GenericPredicate, HirDisplay, ProjectionTy, TraitRef, Ty, TypeWalk}; 13use super::{Canonical, GenericPredicate, HirDisplay, ProjectionTy, TraitRef, Ty, TypeWalk};
14 14
15use self::chalk::{from_chalk, ToChalk}; 15use self::chalk::{from_chalk, ToChalk, TypeFamily};
16 16
17pub(crate) mod chalk; 17pub(crate) mod chalk;
18mod builtin; 18mod builtin;
@@ -20,7 +20,7 @@ mod builtin;
20#[derive(Debug, Clone)] 20#[derive(Debug, Clone)]
21pub struct TraitSolver { 21pub struct TraitSolver {
22 krate: CrateId, 22 krate: CrateId,
23 inner: Arc<Mutex<chalk_solve::Solver<ChalkIr>>>, 23 inner: Arc<Mutex<chalk_solve::Solver<TypeFamily>>>,
24} 24}
25 25
26/// We need eq for salsa 26/// We need eq for salsa
@@ -36,8 +36,8 @@ impl TraitSolver {
36 fn solve( 36 fn solve(
37 &self, 37 &self,
38 db: &impl HirDatabase, 38 db: &impl HirDatabase,
39 goal: &chalk_ir::UCanonical<chalk_ir::InEnvironment<chalk_ir::Goal<ChalkIr>>>, 39 goal: &chalk_ir::UCanonical<chalk_ir::InEnvironment<chalk_ir::Goal<TypeFamily>>>,
40 ) -> Option<chalk_solve::Solution<ChalkIr>> { 40 ) -> Option<chalk_solve::Solution<TypeFamily>> {
41 let context = ChalkContext { db, krate: self.krate }; 41 let context = ChalkContext { db, krate: self.krate };
42 debug!("solve goal: {:?}", goal); 42 debug!("solve goal: {:?}", goal);
43 let mut solver = match self.inner.lock() { 43 let mut solver = match self.inner.lock() {
@@ -201,9 +201,9 @@ pub(crate) fn trait_solve_query(
201 201
202fn solution_from_chalk( 202fn solution_from_chalk(
203 db: &impl HirDatabase, 203 db: &impl HirDatabase,
204 solution: chalk_solve::Solution<ChalkIr>, 204 solution: chalk_solve::Solution<TypeFamily>,
205) -> Solution { 205) -> Solution {
206 let convert_subst = |subst: chalk_ir::Canonical<chalk_ir::Substitution<ChalkIr>>| { 206 let convert_subst = |subst: chalk_ir::Canonical<chalk_ir::Substitution<TypeFamily>>| {
207 let value = subst 207 let value = subst
208 .value 208 .value
209 .parameters 209 .parameters
diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/ra_hir_ty/src/traits/chalk.rs
index 3a91a374d..d53d3fdeb 100644
--- a/crates/ra_hir_ty/src/traits/chalk.rs
+++ b/crates/ra_hir_ty/src/traits/chalk.rs
@@ -3,7 +3,7 @@ use std::sync::Arc;
3 3
4use log::debug; 4use log::debug;
5 5
6use chalk_ir::{cast::Cast, family::ChalkIr, Parameter, PlaceholderIndex, TypeName, UniverseIndex}; 6use chalk_ir::{cast::Cast, Parameter, PlaceholderIndex, TypeName, UniverseIndex};
7 7
8use hir_def::{AssocContainerId, AssocItemId, GenericDefId, HasModule, Lookup, TypeAliasId}; 8use hir_def::{AssocContainerId, AssocItemId, GenericDefId, HasModule, Lookup, TypeAliasId};
9use ra_db::{ 9use ra_db::{
@@ -17,7 +17,7 @@ use crate::{
17 ProjectionTy, Substs, TraitRef, Ty, TypeCtor, TypeWalk, 17 ProjectionTy, Substs, TraitRef, Ty, TypeCtor, TypeWalk,
18}; 18};
19 19
20pub type TypeFamily = chalk_ir::family::ChalkIr; // TODO use everywhere 20pub type TypeFamily = chalk_ir::family::ChalkIr;
21pub type AssocTypeId = chalk_ir::AssocTypeId<TypeFamily>; 21pub type AssocTypeId = chalk_ir::AssocTypeId<TypeFamily>;
22pub type AssociatedTyDatum = chalk_rust_ir::AssociatedTyDatum<TypeFamily>; 22pub type AssociatedTyDatum = chalk_rust_ir::AssociatedTyDatum<TypeFamily>;
23pub type TraitId = chalk_ir::TraitId<TypeFamily>; 23pub type TraitId = chalk_ir::TraitId<TypeFamily>;
@@ -46,21 +46,11 @@ where
46} 46}
47 47
48impl ToChalk for Ty { 48impl ToChalk for Ty {
49 type Chalk = chalk_ir::Ty<ChalkIr>; 49 type Chalk = chalk_ir::Ty<TypeFamily>;
50 fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::Ty<ChalkIr> { 50 fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::Ty<TypeFamily> {
51 match self { 51 match self {
52 Ty::Apply(apply_ty) => { 52 Ty::Apply(apply_ty) => {
53 let name = match apply_ty.ctor { 53 let name = apply_ty.ctor.to_chalk(db);
54 TypeCtor::AssociatedType(type_alias) => {
55 let type_id = type_alias.to_chalk(db);
56 TypeName::AssociatedType(type_id)
57 }
58 _ => {
59 // other TypeCtors get interned and turned into a chalk StructId
60 let struct_id = apply_ty.ctor.to_chalk(db);
61 TypeName::Struct(struct_id.into())
62 }
63 };
64 let parameters = apply_ty.parameters.to_chalk(db); 54 let parameters = apply_ty.parameters.to_chalk(db);
65 chalk_ir::ApplicationTy { name, parameters }.cast().intern() 55 chalk_ir::ApplicationTy { name, parameters }.cast().intern()
66 } 56 }
@@ -70,7 +60,8 @@ impl ToChalk for Ty {
70 chalk_ir::ProjectionTy { associated_ty_id, parameters }.cast().intern() 60 chalk_ir::ProjectionTy { associated_ty_id, parameters }.cast().intern()
71 } 61 }
72 Ty::Param { idx, .. } => { 62 Ty::Param { idx, .. } => {
73 PlaceholderIndex { ui: UniverseIndex::ROOT, idx: idx as usize }.to_ty::<ChalkIr>() 63 PlaceholderIndex { ui: UniverseIndex::ROOT, idx: idx as usize }
64 .to_ty::<TypeFamily>()
74 } 65 }
75 Ty::Bound(idx) => chalk_ir::TyData::BoundVar(idx as usize).intern(), 66 Ty::Bound(idx) => chalk_ir::TyData::BoundVar(idx as usize).intern(),
76 Ty::Infer(_infer_ty) => panic!("uncanonicalized infer ty"), 67 Ty::Infer(_infer_ty) => panic!("uncanonicalized infer ty"),
@@ -91,24 +82,16 @@ impl ToChalk for Ty {
91 } 82 }
92 } 83 }
93 } 84 }
94 fn from_chalk(db: &impl HirDatabase, chalk: chalk_ir::Ty<ChalkIr>) -> Self { 85 fn from_chalk(db: &impl HirDatabase, chalk: chalk_ir::Ty<TypeFamily>) -> Self {
95 match chalk.data().clone() { 86 match chalk.data().clone() {
96 chalk_ir::TyData::Apply(apply_ty) => { 87 chalk_ir::TyData::Apply(apply_ty) => match apply_ty.name {
97 // TODO clean this up now that Placeholder isn't in TypeName anymore 88 TypeName::Error => Ty::Unknown,
98 match apply_ty.name { 89 _ => {
99 TypeName::Struct(struct_id) => { 90 let ctor = from_chalk(db, apply_ty.name);
100 let ctor = from_chalk(db, struct_id); 91 let parameters = from_chalk(db, apply_ty.parameters);
101 let parameters = from_chalk(db, apply_ty.parameters); 92 Ty::Apply(ApplicationTy { ctor, parameters })
102 Ty::Apply(ApplicationTy { ctor, parameters })
103 }
104 TypeName::AssociatedType(type_id) => {
105 let ctor = TypeCtor::AssociatedType(from_chalk(db, type_id));
106 let parameters = from_chalk(db, apply_ty.parameters);
107 Ty::Apply(ApplicationTy { ctor, parameters })
108 }
109 TypeName::Error => Ty::Unknown,
110 } 93 }
111 } 94 },
112 chalk_ir::TyData::Placeholder(idx) => { 95 chalk_ir::TyData::Placeholder(idx) => {
113 assert_eq!(idx.ui, UniverseIndex::ROOT); 96 assert_eq!(idx.ui, UniverseIndex::ROOT);
114 Ty::Param { idx: idx.idx as u32, name: crate::Name::missing() } 97 Ty::Param { idx: idx.idx as u32, name: crate::Name::missing() }
@@ -138,13 +121,16 @@ impl ToChalk for Ty {
138} 121}
139 122
140impl ToChalk for Substs { 123impl ToChalk for Substs {
141 type Chalk = Vec<chalk_ir::Parameter<ChalkIr>>; 124 type Chalk = Vec<chalk_ir::Parameter<TypeFamily>>;
142 125
143 fn to_chalk(self, db: &impl HirDatabase) -> Vec<Parameter<ChalkIr>> { 126 fn to_chalk(self, db: &impl HirDatabase) -> Vec<Parameter<TypeFamily>> {
144 self.iter().map(|ty| ty.clone().to_chalk(db).cast()).collect() 127 self.iter().map(|ty| ty.clone().to_chalk(db).cast()).collect()
145 } 128 }
146 129
147 fn from_chalk(db: &impl HirDatabase, parameters: Vec<chalk_ir::Parameter<ChalkIr>>) -> Substs { 130 fn from_chalk(
131 db: &impl HirDatabase,
132 parameters: Vec<chalk_ir::Parameter<TypeFamily>>,
133 ) -> Substs {
148 let tys = parameters 134 let tys = parameters
149 .into_iter() 135 .into_iter()
150 .map(|p| match p.ty() { 136 .map(|p| match p.ty() {
@@ -157,15 +143,15 @@ impl ToChalk for Substs {
157} 143}
158 144
159impl ToChalk for TraitRef { 145impl ToChalk for TraitRef {
160 type Chalk = chalk_ir::TraitRef<ChalkIr>; 146 type Chalk = chalk_ir::TraitRef<TypeFamily>;
161 147
162 fn to_chalk(self: TraitRef, db: &impl HirDatabase) -> chalk_ir::TraitRef<ChalkIr> { 148 fn to_chalk(self: TraitRef, db: &impl HirDatabase) -> chalk_ir::TraitRef<TypeFamily> {
163 let trait_id = self.trait_.to_chalk(db); 149 let trait_id = self.trait_.to_chalk(db);
164 let parameters = self.substs.to_chalk(db); 150 let parameters = self.substs.to_chalk(db);
165 chalk_ir::TraitRef { trait_id, parameters } 151 chalk_ir::TraitRef { trait_id, parameters }
166 } 152 }
167 153
168 fn from_chalk(db: &impl HirDatabase, trait_ref: chalk_ir::TraitRef<ChalkIr>) -> Self { 154 fn from_chalk(db: &impl HirDatabase, trait_ref: chalk_ir::TraitRef<TypeFamily>) -> Self {
169 let trait_ = from_chalk(db, trait_ref.trait_id); 155 let trait_ = from_chalk(db, trait_ref.trait_id);
170 let substs = from_chalk(db, trait_ref.parameters); 156 let substs = from_chalk(db, trait_ref.parameters);
171 TraitRef { trait_, substs } 157 TraitRef { trait_, substs }
@@ -185,14 +171,31 @@ impl ToChalk for hir_def::TraitId {
185} 171}
186 172
187impl ToChalk for TypeCtor { 173impl ToChalk for TypeCtor {
188 type Chalk = StructId; 174 type Chalk = TypeName<TypeFamily>;
189 175
190 fn to_chalk(self, db: &impl HirDatabase) -> StructId { 176 fn to_chalk(self, db: &impl HirDatabase) -> TypeName<TypeFamily> {
191 db.intern_type_ctor(self).into() 177 match self {
178 TypeCtor::AssociatedType(type_alias) => {
179 let type_id = type_alias.to_chalk(db);
180 TypeName::AssociatedType(type_id)
181 }
182 _ => {
183 // other TypeCtors get interned and turned into a chalk StructId
184 let struct_id = db.intern_type_ctor(self).into();
185 TypeName::Struct(struct_id)
186 }
187 }
192 } 188 }
193 189
194 fn from_chalk(db: &impl HirDatabase, struct_id: StructId) -> TypeCtor { 190 fn from_chalk(db: &impl HirDatabase, type_name: TypeName<TypeFamily>) -> TypeCtor {
195 db.lookup_intern_type_ctor(struct_id.into()) 191 match type_name {
192 TypeName::Struct(struct_id) => db.lookup_intern_type_ctor(struct_id.into()),
193 TypeName::AssociatedType(type_id) => TypeCtor::AssociatedType(from_chalk(db, type_id)),
194 TypeName::Error => {
195 // this should not be reached, since we don't represent TypeName::Error with TypeCtor
196 unreachable!()
197 }
198 }
196 } 199 }
197} 200}
198 201
@@ -233,9 +236,9 @@ impl ToChalk for AssocTyValue {
233} 236}
234 237
235impl ToChalk for GenericPredicate { 238impl ToChalk for GenericPredicate {
236 type Chalk = chalk_ir::QuantifiedWhereClause<ChalkIr>; 239 type Chalk = chalk_ir::QuantifiedWhereClause<TypeFamily>;
237 240
238 fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::QuantifiedWhereClause<ChalkIr> { 241 fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::QuantifiedWhereClause<TypeFamily> {
239 match self { 242 match self {
240 GenericPredicate::Implemented(trait_ref) => { 243 GenericPredicate::Implemented(trait_ref) => {
241 make_binders(chalk_ir::WhereClause::Implemented(trait_ref.to_chalk(db)), 0) 244 make_binders(chalk_ir::WhereClause::Implemented(trait_ref.to_chalk(db)), 0)
@@ -259,7 +262,7 @@ impl ToChalk for GenericPredicate {
259 262
260 fn from_chalk( 263 fn from_chalk(
261 db: &impl HirDatabase, 264 db: &impl HirDatabase,
262 where_clause: chalk_ir::QuantifiedWhereClause<ChalkIr>, 265 where_clause: chalk_ir::QuantifiedWhereClause<TypeFamily>,
263 ) -> GenericPredicate { 266 ) -> GenericPredicate {
264 match where_clause.value { 267 match where_clause.value {
265 chalk_ir::WhereClause::Implemented(tr) => { 268 chalk_ir::WhereClause::Implemented(tr) => {
@@ -279,9 +282,9 @@ impl ToChalk for GenericPredicate {
279} 282}
280 283
281impl ToChalk for ProjectionTy { 284impl ToChalk for ProjectionTy {
282 type Chalk = chalk_ir::ProjectionTy<ChalkIr>; 285 type Chalk = chalk_ir::ProjectionTy<TypeFamily>;
283 286
284 fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::ProjectionTy<ChalkIr> { 287 fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::ProjectionTy<TypeFamily> {
285 chalk_ir::ProjectionTy { 288 chalk_ir::ProjectionTy {
286 associated_ty_id: self.associated_ty.to_chalk(db), 289 associated_ty_id: self.associated_ty.to_chalk(db),
287 parameters: self.parameters.to_chalk(db), 290 parameters: self.parameters.to_chalk(db),
@@ -290,7 +293,7 @@ impl ToChalk for ProjectionTy {
290 293
291 fn from_chalk( 294 fn from_chalk(
292 db: &impl HirDatabase, 295 db: &impl HirDatabase,
293 projection_ty: chalk_ir::ProjectionTy<ChalkIr>, 296 projection_ty: chalk_ir::ProjectionTy<TypeFamily>,
294 ) -> ProjectionTy { 297 ) -> ProjectionTy {
295 ProjectionTy { 298 ProjectionTy {
296 associated_ty: from_chalk(db, projection_ty.associated_ty_id), 299 associated_ty: from_chalk(db, projection_ty.associated_ty_id),
@@ -300,31 +303,31 @@ impl ToChalk for ProjectionTy {
300} 303}
301 304
302impl ToChalk for super::ProjectionPredicate { 305impl ToChalk for super::ProjectionPredicate {
303 type Chalk = chalk_ir::Normalize<ChalkIr>; 306 type Chalk = chalk_ir::Normalize<TypeFamily>;
304 307
305 fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::Normalize<ChalkIr> { 308 fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::Normalize<TypeFamily> {
306 chalk_ir::Normalize { 309 chalk_ir::Normalize {
307 projection: self.projection_ty.to_chalk(db), 310 projection: self.projection_ty.to_chalk(db),
308 ty: self.ty.to_chalk(db), 311 ty: self.ty.to_chalk(db),
309 } 312 }
310 } 313 }
311 314
312 fn from_chalk(_db: &impl HirDatabase, _normalize: chalk_ir::Normalize<ChalkIr>) -> Self { 315 fn from_chalk(_db: &impl HirDatabase, _normalize: chalk_ir::Normalize<TypeFamily>) -> Self {
313 unimplemented!() 316 unimplemented!()
314 } 317 }
315} 318}
316 319
317impl ToChalk for Obligation { 320impl ToChalk for Obligation {
318 type Chalk = chalk_ir::DomainGoal<ChalkIr>; 321 type Chalk = chalk_ir::DomainGoal<TypeFamily>;
319 322
320 fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::DomainGoal<ChalkIr> { 323 fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::DomainGoal<TypeFamily> {
321 match self { 324 match self {
322 Obligation::Trait(tr) => tr.to_chalk(db).cast(), 325 Obligation::Trait(tr) => tr.to_chalk(db).cast(),
323 Obligation::Projection(pr) => pr.to_chalk(db).cast(), 326 Obligation::Projection(pr) => pr.to_chalk(db).cast(),
324 } 327 }
325 } 328 }
326 329
327 fn from_chalk(_db: &impl HirDatabase, _goal: chalk_ir::DomainGoal<ChalkIr>) -> Self { 330 fn from_chalk(_db: &impl HirDatabase, _goal: chalk_ir::DomainGoal<TypeFamily>) -> Self {
328 unimplemented!() 331 unimplemented!()
329 } 332 }
330} 333}
@@ -348,16 +351,17 @@ where
348} 351}
349 352
350impl ToChalk for Arc<super::TraitEnvironment> { 353impl ToChalk for Arc<super::TraitEnvironment> {
351 type Chalk = chalk_ir::Environment<ChalkIr>; 354 type Chalk = chalk_ir::Environment<TypeFamily>;
352 355
353 fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::Environment<ChalkIr> { 356 fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::Environment<TypeFamily> {
354 let mut clauses = Vec::new(); 357 let mut clauses = Vec::new();
355 for pred in &self.predicates { 358 for pred in &self.predicates {
356 if pred.is_error() { 359 if pred.is_error() {
357 // for env, we just ignore errors 360 // for env, we just ignore errors
358 continue; 361 continue;
359 } 362 }
360 let program_clause: chalk_ir::ProgramClause<ChalkIr> = pred.clone().to_chalk(db).cast(); 363 let program_clause: chalk_ir::ProgramClause<TypeFamily> =
364 pred.clone().to_chalk(db).cast();
361 clauses.push(program_clause.into_from_env_clause()); 365 clauses.push(program_clause.into_from_env_clause());
362 } 366 }
363 chalk_ir::Environment::new().add_clauses(clauses) 367 chalk_ir::Environment::new().add_clauses(clauses)
@@ -365,7 +369,7 @@ impl ToChalk for Arc<super::TraitEnvironment> {
365 369
366 fn from_chalk( 370 fn from_chalk(
367 _db: &impl HirDatabase, 371 _db: &impl HirDatabase,
368 _env: chalk_ir::Environment<ChalkIr>, 372 _env: chalk_ir::Environment<TypeFamily>,
369 ) -> Arc<super::TraitEnvironment> { 373 ) -> Arc<super::TraitEnvironment> {
370 unimplemented!() 374 unimplemented!()
371 } 375 }
@@ -373,7 +377,7 @@ impl ToChalk for Arc<super::TraitEnvironment> {
373 377
374impl<T: ToChalk> ToChalk for super::InEnvironment<T> 378impl<T: ToChalk> ToChalk for super::InEnvironment<T>
375where 379where
376 T::Chalk: chalk_ir::family::HasTypeFamily<TypeFamily = ChalkIr>, 380 T::Chalk: chalk_ir::family::HasTypeFamily<TypeFamily = TypeFamily>,
377{ 381{
378 type Chalk = chalk_ir::InEnvironment<T::Chalk>; 382 type Chalk = chalk_ir::InEnvironment<T::Chalk>;
379 383
@@ -396,9 +400,9 @@ where
396} 400}
397 401
398impl ToChalk for builtin::BuiltinImplData { 402impl ToChalk for builtin::BuiltinImplData {
399 type Chalk = chalk_rust_ir::ImplDatum<ChalkIr>; 403 type Chalk = ImplDatum;
400 404
401 fn to_chalk(self, db: &impl HirDatabase) -> chalk_rust_ir::ImplDatum<ChalkIr> { 405 fn to_chalk(self, db: &impl HirDatabase) -> ImplDatum {
402 let impl_type = chalk_rust_ir::ImplType::External; 406 let impl_type = chalk_rust_ir::ImplType::External;
403 let where_clauses = self.where_clauses.into_iter().map(|w| w.to_chalk(db)).collect(); 407 let where_clauses = self.where_clauses.into_iter().map(|w| w.to_chalk(db)).collect();
404 408
@@ -414,15 +418,15 @@ impl ToChalk for builtin::BuiltinImplData {
414 } 418 }
415 } 419 }
416 420
417 fn from_chalk(_db: &impl HirDatabase, _data: chalk_rust_ir::ImplDatum<ChalkIr>) -> Self { 421 fn from_chalk(_db: &impl HirDatabase, _data: ImplDatum) -> Self {
418 unimplemented!() 422 unimplemented!()
419 } 423 }
420} 424}
421 425
422impl ToChalk for builtin::BuiltinImplAssocTyValueData { 426impl ToChalk for builtin::BuiltinImplAssocTyValueData {
423 type Chalk = chalk_rust_ir::AssociatedTyValue<ChalkIr>; 427 type Chalk = AssociatedTyValue;
424 428
425 fn to_chalk(self, db: &impl HirDatabase) -> chalk_rust_ir::AssociatedTyValue<ChalkIr> { 429 fn to_chalk(self, db: &impl HirDatabase) -> AssociatedTyValue {
426 let value_bound = chalk_rust_ir::AssociatedTyValueBound { ty: self.value.to_chalk(db) }; 430 let value_bound = chalk_rust_ir::AssociatedTyValueBound { ty: self.value.to_chalk(db) };
427 431
428 chalk_rust_ir::AssociatedTyValue { 432 chalk_rust_ir::AssociatedTyValue {
@@ -434,7 +438,7 @@ impl ToChalk for builtin::BuiltinImplAssocTyValueData {
434 438
435 fn from_chalk( 439 fn from_chalk(
436 _db: &impl HirDatabase, 440 _db: &impl HirDatabase,
437 _data: chalk_rust_ir::AssociatedTyValue<ChalkIr>, 441 _data: AssociatedTyValue,
438 ) -> builtin::BuiltinImplAssocTyValueData { 442 ) -> builtin::BuiltinImplAssocTyValueData {
439 unimplemented!() 443 unimplemented!()
440 } 444 }
@@ -451,7 +455,7 @@ fn convert_where_clauses(
451 db: &impl HirDatabase, 455 db: &impl HirDatabase,
452 def: GenericDefId, 456 def: GenericDefId,
453 substs: &Substs, 457 substs: &Substs,
454) -> Vec<chalk_ir::QuantifiedWhereClause<ChalkIr>> { 458) -> Vec<chalk_ir::QuantifiedWhereClause<TypeFamily>> {
455 let generic_predicates = db.generic_predicates(def); 459 let generic_predicates = db.generic_predicates(def);
456 let mut result = Vec::with_capacity(generic_predicates.len()); 460 let mut result = Vec::with_capacity(generic_predicates.len());
457 for pred in generic_predicates.iter() { 461 for pred in generic_predicates.iter() {
@@ -465,7 +469,7 @@ fn convert_where_clauses(
465 result 469 result
466} 470}
467 471
468impl<'a, DB> chalk_solve::RustIrDatabase<ChalkIr> for ChalkContext<'a, DB> 472impl<'a, DB> chalk_solve::RustIrDatabase<TypeFamily> for ChalkContext<'a, DB>
469where 473where
470 DB: HirDatabase, 474 DB: HirDatabase,
471{ 475{
@@ -516,7 +520,7 @@ where
516 fn associated_ty_value(&self, id: AssociatedTyValueId) -> Arc<AssociatedTyValue> { 520 fn associated_ty_value(&self, id: AssociatedTyValueId) -> Arc<AssociatedTyValue> {
517 self.db.associated_ty_value(self.krate.into(), id) 521 self.db.associated_ty_value(self.krate.into(), id)
518 } 522 }
519 fn custom_clauses(&self) -> Vec<chalk_ir::ProgramClause<ChalkIr>> { 523 fn custom_clauses(&self) -> Vec<chalk_ir::ProgramClause<TypeFamily>> {
520 vec![] 524 vec![]
521 } 525 }
522 fn local_impls_to_coherence_check(&self, _trait_id: TraitId) -> Vec<ImplId> { 526 fn local_impls_to_coherence_check(&self, _trait_id: TraitId) -> Vec<ImplId> {
@@ -613,7 +617,7 @@ pub(crate) fn struct_datum_query(
613 struct_id: StructId, 617 struct_id: StructId,
614) -> Arc<StructDatum> { 618) -> Arc<StructDatum> {
615 debug!("struct_datum {:?}", struct_id); 619 debug!("struct_datum {:?}", struct_id);
616 let type_ctor: TypeCtor = from_chalk(db, struct_id); 620 let type_ctor: TypeCtor = from_chalk(db, TypeName::Struct(struct_id));
617 debug!("struct {:?} = {:?}", struct_id, type_ctor); 621 debug!("struct {:?} = {:?}", struct_id, type_ctor);
618 let num_params = type_ctor.num_ty_params(db); 622 let num_params = type_ctor.num_ty_params(db);
619 let upstream = type_ctor.krate(db) != Some(krate); 623 let upstream = type_ctor.krate(db) != Some(krate);
@@ -733,8 +737,8 @@ fn invalid_impl_datum() -> Arc<ImplDatum> {
733pub(crate) fn associated_ty_value_query( 737pub(crate) fn associated_ty_value_query(
734 db: &impl HirDatabase, 738 db: &impl HirDatabase,
735 krate: CrateId, 739 krate: CrateId,
736 id: chalk_rust_ir::AssociatedTyValueId, 740 id: AssociatedTyValueId,
737) -> Arc<chalk_rust_ir::AssociatedTyValue<ChalkIr>> { 741) -> Arc<AssociatedTyValue> {
738 let data: AssocTyValue = from_chalk(db, id); 742 let data: AssocTyValue = from_chalk(db, id);
739 match data { 743 match data {
740 AssocTyValue::TypeAlias(type_alias) => { 744 AssocTyValue::TypeAlias(type_alias) => {