diff options
Diffstat (limited to 'crates/ra_hir_ty/src/traits/chalk.rs')
-rw-r--r-- | crates/ra_hir_ty/src/traits/chalk.rs | 111 |
1 files changed, 54 insertions, 57 deletions
diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/ra_hir_ty/src/traits/chalk.rs index 62509bc29..943d5f125 100644 --- a/crates/ra_hir_ty/src/traits/chalk.rs +++ b/crates/ra_hir_ty/src/traits/chalk.rs | |||
@@ -127,11 +127,11 @@ pub type AssociatedTyValue = chalk_rust_ir::AssociatedTyValue<Interner>; | |||
127 | 127 | ||
128 | pub(super) trait ToChalk { | 128 | pub(super) trait ToChalk { |
129 | type Chalk; | 129 | type Chalk; |
130 | fn to_chalk(self, db: &impl HirDatabase) -> Self::Chalk; | 130 | fn to_chalk(self, db: &dyn HirDatabase) -> Self::Chalk; |
131 | fn from_chalk(db: &impl HirDatabase, chalk: Self::Chalk) -> Self; | 131 | fn from_chalk(db: &dyn HirDatabase, chalk: Self::Chalk) -> Self; |
132 | } | 132 | } |
133 | 133 | ||
134 | pub(super) fn from_chalk<T, ChalkT>(db: &impl HirDatabase, chalk: ChalkT) -> T | 134 | pub(super) fn from_chalk<T, ChalkT>(db: &dyn HirDatabase, chalk: ChalkT) -> T |
135 | where | 135 | where |
136 | T: ToChalk<Chalk = ChalkT>, | 136 | T: ToChalk<Chalk = ChalkT>, |
137 | { | 137 | { |
@@ -140,7 +140,7 @@ where | |||
140 | 140 | ||
141 | impl ToChalk for Ty { | 141 | impl ToChalk for Ty { |
142 | type Chalk = chalk_ir::Ty<Interner>; | 142 | type Chalk = chalk_ir::Ty<Interner>; |
143 | fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::Ty<Interner> { | 143 | fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Ty<Interner> { |
144 | match self { | 144 | match self { |
145 | Ty::Apply(apply_ty) => { | 145 | Ty::Apply(apply_ty) => { |
146 | let name = apply_ty.ctor.to_chalk(db); | 146 | let name = apply_ty.ctor.to_chalk(db); |
@@ -179,7 +179,7 @@ impl ToChalk for Ty { | |||
179 | } | 179 | } |
180 | } | 180 | } |
181 | } | 181 | } |
182 | fn from_chalk(db: &impl HirDatabase, chalk: chalk_ir::Ty<Interner>) -> Self { | 182 | fn from_chalk(db: &dyn HirDatabase, chalk: chalk_ir::Ty<Interner>) -> Self { |
183 | match chalk.data().clone() { | 183 | match chalk.data().clone() { |
184 | chalk_ir::TyData::Apply(apply_ty) => match apply_ty.name { | 184 | chalk_ir::TyData::Apply(apply_ty) => match apply_ty.name { |
185 | TypeName::Error => Ty::Unknown, | 185 | TypeName::Error => Ty::Unknown, |
@@ -217,11 +217,11 @@ impl ToChalk for Ty { | |||
217 | impl ToChalk for Substs { | 217 | impl ToChalk for Substs { |
218 | type Chalk = chalk_ir::Substitution<Interner>; | 218 | type Chalk = chalk_ir::Substitution<Interner>; |
219 | 219 | ||
220 | fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::Substitution<Interner> { | 220 | fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Substitution<Interner> { |
221 | chalk_ir::Substitution::from(self.iter().map(|ty| ty.clone().to_chalk(db))) | 221 | chalk_ir::Substitution::from(self.iter().map(|ty| ty.clone().to_chalk(db))) |
222 | } | 222 | } |
223 | 223 | ||
224 | fn from_chalk(db: &impl HirDatabase, parameters: chalk_ir::Substitution<Interner>) -> Substs { | 224 | fn from_chalk(db: &dyn HirDatabase, parameters: chalk_ir::Substitution<Interner>) -> Substs { |
225 | let tys = parameters | 225 | let tys = parameters |
226 | .into_iter() | 226 | .into_iter() |
227 | .map(|p| match p.ty() { | 227 | .map(|p| match p.ty() { |
@@ -236,13 +236,13 @@ impl ToChalk for Substs { | |||
236 | impl ToChalk for TraitRef { | 236 | impl ToChalk for TraitRef { |
237 | type Chalk = chalk_ir::TraitRef<Interner>; | 237 | type Chalk = chalk_ir::TraitRef<Interner>; |
238 | 238 | ||
239 | fn to_chalk(self: TraitRef, db: &impl HirDatabase) -> chalk_ir::TraitRef<Interner> { | 239 | fn to_chalk(self: TraitRef, db: &dyn HirDatabase) -> chalk_ir::TraitRef<Interner> { |
240 | let trait_id = self.trait_.to_chalk(db); | 240 | let trait_id = self.trait_.to_chalk(db); |
241 | let substitution = self.substs.to_chalk(db); | 241 | let substitution = self.substs.to_chalk(db); |
242 | chalk_ir::TraitRef { trait_id, substitution } | 242 | chalk_ir::TraitRef { trait_id, substitution } |
243 | } | 243 | } |
244 | 244 | ||
245 | fn from_chalk(db: &impl HirDatabase, trait_ref: chalk_ir::TraitRef<Interner>) -> Self { | 245 | fn from_chalk(db: &dyn HirDatabase, trait_ref: chalk_ir::TraitRef<Interner>) -> Self { |
246 | let trait_ = from_chalk(db, trait_ref.trait_id); | 246 | let trait_ = from_chalk(db, trait_ref.trait_id); |
247 | let substs = from_chalk(db, trait_ref.substitution); | 247 | let substs = from_chalk(db, trait_ref.substitution); |
248 | TraitRef { trait_, substs } | 248 | TraitRef { trait_, substs } |
@@ -252,11 +252,11 @@ impl ToChalk for TraitRef { | |||
252 | impl ToChalk for hir_def::TraitId { | 252 | impl ToChalk for hir_def::TraitId { |
253 | type Chalk = TraitId; | 253 | type Chalk = TraitId; |
254 | 254 | ||
255 | fn to_chalk(self, _db: &impl HirDatabase) -> TraitId { | 255 | fn to_chalk(self, _db: &dyn HirDatabase) -> TraitId { |
256 | chalk_ir::TraitId(self.as_intern_id()) | 256 | chalk_ir::TraitId(self.as_intern_id()) |
257 | } | 257 | } |
258 | 258 | ||
259 | fn from_chalk(_db: &impl HirDatabase, trait_id: TraitId) -> hir_def::TraitId { | 259 | fn from_chalk(_db: &dyn HirDatabase, trait_id: TraitId) -> hir_def::TraitId { |
260 | InternKey::from_intern_id(trait_id.0) | 260 | InternKey::from_intern_id(trait_id.0) |
261 | } | 261 | } |
262 | } | 262 | } |
@@ -264,7 +264,7 @@ impl ToChalk for hir_def::TraitId { | |||
264 | impl ToChalk for TypeCtor { | 264 | impl ToChalk for TypeCtor { |
265 | type Chalk = TypeName<Interner>; | 265 | type Chalk = TypeName<Interner>; |
266 | 266 | ||
267 | fn to_chalk(self, db: &impl HirDatabase) -> TypeName<Interner> { | 267 | fn to_chalk(self, db: &dyn HirDatabase) -> TypeName<Interner> { |
268 | match self { | 268 | match self { |
269 | TypeCtor::AssociatedType(type_alias) => { | 269 | TypeCtor::AssociatedType(type_alias) => { |
270 | let type_id = type_alias.to_chalk(db); | 270 | let type_id = type_alias.to_chalk(db); |
@@ -278,7 +278,7 @@ impl ToChalk for TypeCtor { | |||
278 | } | 278 | } |
279 | } | 279 | } |
280 | 280 | ||
281 | fn from_chalk(db: &impl HirDatabase, type_name: TypeName<Interner>) -> TypeCtor { | 281 | fn from_chalk(db: &dyn HirDatabase, type_name: TypeName<Interner>) -> TypeCtor { |
282 | match type_name { | 282 | match type_name { |
283 | TypeName::Struct(struct_id) => db.lookup_intern_type_ctor(struct_id.into()), | 283 | TypeName::Struct(struct_id) => db.lookup_intern_type_ctor(struct_id.into()), |
284 | TypeName::AssociatedType(type_id) => TypeCtor::AssociatedType(from_chalk(db, type_id)), | 284 | TypeName::AssociatedType(type_id) => TypeCtor::AssociatedType(from_chalk(db, type_id)), |
@@ -293,11 +293,11 @@ impl ToChalk for TypeCtor { | |||
293 | impl ToChalk for Impl { | 293 | impl ToChalk for Impl { |
294 | type Chalk = ImplId; | 294 | type Chalk = ImplId; |
295 | 295 | ||
296 | fn to_chalk(self, db: &impl HirDatabase) -> ImplId { | 296 | fn to_chalk(self, db: &dyn HirDatabase) -> ImplId { |
297 | db.intern_chalk_impl(self).into() | 297 | db.intern_chalk_impl(self).into() |
298 | } | 298 | } |
299 | 299 | ||
300 | fn from_chalk(db: &impl HirDatabase, impl_id: ImplId) -> Impl { | 300 | fn from_chalk(db: &dyn HirDatabase, impl_id: ImplId) -> Impl { |
301 | db.lookup_intern_chalk_impl(impl_id.into()) | 301 | db.lookup_intern_chalk_impl(impl_id.into()) |
302 | } | 302 | } |
303 | } | 303 | } |
@@ -305,11 +305,11 @@ impl ToChalk for Impl { | |||
305 | impl ToChalk for TypeAliasId { | 305 | impl ToChalk for TypeAliasId { |
306 | type Chalk = AssocTypeId; | 306 | type Chalk = AssocTypeId; |
307 | 307 | ||
308 | fn to_chalk(self, _db: &impl HirDatabase) -> AssocTypeId { | 308 | fn to_chalk(self, _db: &dyn HirDatabase) -> AssocTypeId { |
309 | chalk_ir::AssocTypeId(self.as_intern_id()) | 309 | chalk_ir::AssocTypeId(self.as_intern_id()) |
310 | } | 310 | } |
311 | 311 | ||
312 | fn from_chalk(_db: &impl HirDatabase, type_alias_id: AssocTypeId) -> TypeAliasId { | 312 | fn from_chalk(_db: &dyn HirDatabase, type_alias_id: AssocTypeId) -> TypeAliasId { |
313 | InternKey::from_intern_id(type_alias_id.0) | 313 | InternKey::from_intern_id(type_alias_id.0) |
314 | } | 314 | } |
315 | } | 315 | } |
@@ -317,11 +317,11 @@ impl ToChalk for TypeAliasId { | |||
317 | impl ToChalk for AssocTyValue { | 317 | impl ToChalk for AssocTyValue { |
318 | type Chalk = AssociatedTyValueId; | 318 | type Chalk = AssociatedTyValueId; |
319 | 319 | ||
320 | fn to_chalk(self, db: &impl HirDatabase) -> AssociatedTyValueId { | 320 | fn to_chalk(self, db: &dyn HirDatabase) -> AssociatedTyValueId { |
321 | db.intern_assoc_ty_value(self).into() | 321 | db.intern_assoc_ty_value(self).into() |
322 | } | 322 | } |
323 | 323 | ||
324 | fn from_chalk(db: &impl HirDatabase, assoc_ty_value_id: AssociatedTyValueId) -> AssocTyValue { | 324 | fn from_chalk(db: &dyn HirDatabase, assoc_ty_value_id: AssociatedTyValueId) -> AssocTyValue { |
325 | db.lookup_intern_assoc_ty_value(assoc_ty_value_id.into()) | 325 | db.lookup_intern_assoc_ty_value(assoc_ty_value_id.into()) |
326 | } | 326 | } |
327 | } | 327 | } |
@@ -329,7 +329,7 @@ impl ToChalk for AssocTyValue { | |||
329 | impl ToChalk for GenericPredicate { | 329 | impl ToChalk for GenericPredicate { |
330 | type Chalk = chalk_ir::QuantifiedWhereClause<Interner>; | 330 | type Chalk = chalk_ir::QuantifiedWhereClause<Interner>; |
331 | 331 | ||
332 | fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::QuantifiedWhereClause<Interner> { | 332 | fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::QuantifiedWhereClause<Interner> { |
333 | match self { | 333 | match self { |
334 | GenericPredicate::Implemented(trait_ref) => { | 334 | GenericPredicate::Implemented(trait_ref) => { |
335 | make_binders(chalk_ir::WhereClause::Implemented(trait_ref.to_chalk(db)), 0) | 335 | make_binders(chalk_ir::WhereClause::Implemented(trait_ref.to_chalk(db)), 0) |
@@ -346,7 +346,7 @@ impl ToChalk for GenericPredicate { | |||
346 | } | 346 | } |
347 | 347 | ||
348 | fn from_chalk( | 348 | fn from_chalk( |
349 | db: &impl HirDatabase, | 349 | db: &dyn HirDatabase, |
350 | where_clause: chalk_ir::QuantifiedWhereClause<Interner>, | 350 | where_clause: chalk_ir::QuantifiedWhereClause<Interner>, |
351 | ) -> GenericPredicate { | 351 | ) -> GenericPredicate { |
352 | match where_clause.value { | 352 | match where_clause.value { |
@@ -365,7 +365,7 @@ impl ToChalk for GenericPredicate { | |||
365 | impl ToChalk for ProjectionTy { | 365 | impl ToChalk for ProjectionTy { |
366 | type Chalk = chalk_ir::AliasTy<Interner>; | 366 | type Chalk = chalk_ir::AliasTy<Interner>; |
367 | 367 | ||
368 | fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::AliasTy<Interner> { | 368 | fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::AliasTy<Interner> { |
369 | chalk_ir::AliasTy { | 369 | chalk_ir::AliasTy { |
370 | associated_ty_id: self.associated_ty.to_chalk(db), | 370 | associated_ty_id: self.associated_ty.to_chalk(db), |
371 | substitution: self.parameters.to_chalk(db), | 371 | substitution: self.parameters.to_chalk(db), |
@@ -373,7 +373,7 @@ impl ToChalk for ProjectionTy { | |||
373 | } | 373 | } |
374 | 374 | ||
375 | fn from_chalk( | 375 | fn from_chalk( |
376 | db: &impl HirDatabase, | 376 | db: &dyn HirDatabase, |
377 | projection_ty: chalk_ir::AliasTy<Interner>, | 377 | projection_ty: chalk_ir::AliasTy<Interner>, |
378 | ) -> ProjectionTy { | 378 | ) -> ProjectionTy { |
379 | ProjectionTy { | 379 | ProjectionTy { |
@@ -386,11 +386,11 @@ impl ToChalk for ProjectionTy { | |||
386 | impl ToChalk for super::ProjectionPredicate { | 386 | impl ToChalk for super::ProjectionPredicate { |
387 | type Chalk = chalk_ir::Normalize<Interner>; | 387 | type Chalk = chalk_ir::Normalize<Interner>; |
388 | 388 | ||
389 | fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::Normalize<Interner> { | 389 | fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Normalize<Interner> { |
390 | chalk_ir::Normalize { alias: self.projection_ty.to_chalk(db), ty: self.ty.to_chalk(db) } | 390 | chalk_ir::Normalize { alias: self.projection_ty.to_chalk(db), ty: self.ty.to_chalk(db) } |
391 | } | 391 | } |
392 | 392 | ||
393 | fn from_chalk(_db: &impl HirDatabase, _normalize: chalk_ir::Normalize<Interner>) -> Self { | 393 | fn from_chalk(_db: &dyn HirDatabase, _normalize: chalk_ir::Normalize<Interner>) -> Self { |
394 | unimplemented!() | 394 | unimplemented!() |
395 | } | 395 | } |
396 | } | 396 | } |
@@ -398,14 +398,14 @@ impl ToChalk for super::ProjectionPredicate { | |||
398 | impl ToChalk for Obligation { | 398 | impl ToChalk for Obligation { |
399 | type Chalk = chalk_ir::DomainGoal<Interner>; | 399 | type Chalk = chalk_ir::DomainGoal<Interner>; |
400 | 400 | ||
401 | fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::DomainGoal<Interner> { | 401 | fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::DomainGoal<Interner> { |
402 | match self { | 402 | match self { |
403 | Obligation::Trait(tr) => tr.to_chalk(db).cast(), | 403 | Obligation::Trait(tr) => tr.to_chalk(db).cast(), |
404 | Obligation::Projection(pr) => pr.to_chalk(db).cast(), | 404 | Obligation::Projection(pr) => pr.to_chalk(db).cast(), |
405 | } | 405 | } |
406 | } | 406 | } |
407 | 407 | ||
408 | fn from_chalk(_db: &impl HirDatabase, _goal: chalk_ir::DomainGoal<Interner>) -> Self { | 408 | fn from_chalk(_db: &dyn HirDatabase, _goal: chalk_ir::DomainGoal<Interner>) -> Self { |
409 | unimplemented!() | 409 | unimplemented!() |
410 | } | 410 | } |
411 | } | 411 | } |
@@ -416,13 +416,13 @@ where | |||
416 | { | 416 | { |
417 | type Chalk = chalk_ir::Canonical<T::Chalk>; | 417 | type Chalk = chalk_ir::Canonical<T::Chalk>; |
418 | 418 | ||
419 | fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::Canonical<T::Chalk> { | 419 | fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Canonical<T::Chalk> { |
420 | let parameter = chalk_ir::ParameterKind::Ty(chalk_ir::UniverseIndex::ROOT); | 420 | let parameter = chalk_ir::ParameterKind::Ty(chalk_ir::UniverseIndex::ROOT); |
421 | let value = self.value.to_chalk(db); | 421 | let value = self.value.to_chalk(db); |
422 | chalk_ir::Canonical { value, binders: vec![parameter; self.num_vars] } | 422 | chalk_ir::Canonical { value, binders: vec![parameter; self.num_vars] } |
423 | } | 423 | } |
424 | 424 | ||
425 | fn from_chalk(db: &impl HirDatabase, canonical: chalk_ir::Canonical<T::Chalk>) -> Canonical<T> { | 425 | fn from_chalk(db: &dyn HirDatabase, canonical: chalk_ir::Canonical<T::Chalk>) -> Canonical<T> { |
426 | Canonical { num_vars: canonical.binders.len(), value: from_chalk(db, canonical.value) } | 426 | Canonical { num_vars: canonical.binders.len(), value: from_chalk(db, canonical.value) } |
427 | } | 427 | } |
428 | } | 428 | } |
@@ -430,7 +430,7 @@ where | |||
430 | impl ToChalk for Arc<super::TraitEnvironment> { | 430 | impl ToChalk for Arc<super::TraitEnvironment> { |
431 | type Chalk = chalk_ir::Environment<Interner>; | 431 | type Chalk = chalk_ir::Environment<Interner>; |
432 | 432 | ||
433 | fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::Environment<Interner> { | 433 | fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Environment<Interner> { |
434 | let mut clauses = Vec::new(); | 434 | let mut clauses = Vec::new(); |
435 | for pred in &self.predicates { | 435 | for pred in &self.predicates { |
436 | if pred.is_error() { | 436 | if pred.is_error() { |
@@ -445,7 +445,7 @@ impl ToChalk for Arc<super::TraitEnvironment> { | |||
445 | } | 445 | } |
446 | 446 | ||
447 | fn from_chalk( | 447 | fn from_chalk( |
448 | _db: &impl HirDatabase, | 448 | _db: &dyn HirDatabase, |
449 | _env: chalk_ir::Environment<Interner>, | 449 | _env: chalk_ir::Environment<Interner>, |
450 | ) -> Arc<super::TraitEnvironment> { | 450 | ) -> Arc<super::TraitEnvironment> { |
451 | unimplemented!() | 451 | unimplemented!() |
@@ -458,7 +458,7 @@ where | |||
458 | { | 458 | { |
459 | type Chalk = chalk_ir::InEnvironment<T::Chalk>; | 459 | type Chalk = chalk_ir::InEnvironment<T::Chalk>; |
460 | 460 | ||
461 | fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::InEnvironment<T::Chalk> { | 461 | fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::InEnvironment<T::Chalk> { |
462 | chalk_ir::InEnvironment { | 462 | chalk_ir::InEnvironment { |
463 | environment: self.environment.to_chalk(db), | 463 | environment: self.environment.to_chalk(db), |
464 | goal: self.value.to_chalk(db), | 464 | goal: self.value.to_chalk(db), |
@@ -466,7 +466,7 @@ where | |||
466 | } | 466 | } |
467 | 467 | ||
468 | fn from_chalk( | 468 | fn from_chalk( |
469 | db: &impl HirDatabase, | 469 | db: &dyn HirDatabase, |
470 | in_env: chalk_ir::InEnvironment<T::Chalk>, | 470 | in_env: chalk_ir::InEnvironment<T::Chalk>, |
471 | ) -> super::InEnvironment<T> { | 471 | ) -> super::InEnvironment<T> { |
472 | super::InEnvironment { | 472 | super::InEnvironment { |
@@ -479,7 +479,7 @@ where | |||
479 | impl ToChalk for builtin::BuiltinImplData { | 479 | impl ToChalk for builtin::BuiltinImplData { |
480 | type Chalk = ImplDatum; | 480 | type Chalk = ImplDatum; |
481 | 481 | ||
482 | fn to_chalk(self, db: &impl HirDatabase) -> ImplDatum { | 482 | fn to_chalk(self, db: &dyn HirDatabase) -> ImplDatum { |
483 | let impl_type = chalk_rust_ir::ImplType::External; | 483 | let impl_type = chalk_rust_ir::ImplType::External; |
484 | let where_clauses = self.where_clauses.into_iter().map(|w| w.to_chalk(db)).collect(); | 484 | let where_clauses = self.where_clauses.into_iter().map(|w| w.to_chalk(db)).collect(); |
485 | 485 | ||
@@ -495,7 +495,7 @@ impl ToChalk for builtin::BuiltinImplData { | |||
495 | } | 495 | } |
496 | } | 496 | } |
497 | 497 | ||
498 | fn from_chalk(_db: &impl HirDatabase, _data: ImplDatum) -> Self { | 498 | fn from_chalk(_db: &dyn HirDatabase, _data: ImplDatum) -> Self { |
499 | unimplemented!() | 499 | unimplemented!() |
500 | } | 500 | } |
501 | } | 501 | } |
@@ -503,7 +503,7 @@ impl ToChalk for builtin::BuiltinImplData { | |||
503 | impl ToChalk for builtin::BuiltinImplAssocTyValueData { | 503 | impl ToChalk for builtin::BuiltinImplAssocTyValueData { |
504 | type Chalk = AssociatedTyValue; | 504 | type Chalk = AssociatedTyValue; |
505 | 505 | ||
506 | fn to_chalk(self, db: &impl HirDatabase) -> AssociatedTyValue { | 506 | fn to_chalk(self, db: &dyn HirDatabase) -> AssociatedTyValue { |
507 | let value_bound = chalk_rust_ir::AssociatedTyValueBound { ty: self.value.to_chalk(db) }; | 507 | let value_bound = chalk_rust_ir::AssociatedTyValueBound { ty: self.value.to_chalk(db) }; |
508 | 508 | ||
509 | chalk_rust_ir::AssociatedTyValue { | 509 | chalk_rust_ir::AssociatedTyValue { |
@@ -514,7 +514,7 @@ impl ToChalk for builtin::BuiltinImplAssocTyValueData { | |||
514 | } | 514 | } |
515 | 515 | ||
516 | fn from_chalk( | 516 | fn from_chalk( |
517 | _db: &impl HirDatabase, | 517 | _db: &dyn HirDatabase, |
518 | _data: AssociatedTyValue, | 518 | _data: AssociatedTyValue, |
519 | ) -> builtin::BuiltinImplAssocTyValueData { | 519 | ) -> builtin::BuiltinImplAssocTyValueData { |
520 | unimplemented!() | 520 | unimplemented!() |
@@ -529,7 +529,7 @@ fn make_binders<T>(value: T, num_vars: usize) -> chalk_ir::Binders<T> { | |||
529 | } | 529 | } |
530 | 530 | ||
531 | fn convert_where_clauses( | 531 | fn convert_where_clauses( |
532 | db: &impl HirDatabase, | 532 | db: &dyn HirDatabase, |
533 | def: GenericDefId, | 533 | def: GenericDefId, |
534 | substs: &Substs, | 534 | substs: &Substs, |
535 | ) -> Vec<chalk_ir::QuantifiedWhereClause<Interner>> { | 535 | ) -> Vec<chalk_ir::QuantifiedWhereClause<Interner>> { |
@@ -545,10 +545,7 @@ fn convert_where_clauses( | |||
545 | result | 545 | result |
546 | } | 546 | } |
547 | 547 | ||
548 | impl<'a, DB> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a, DB> | 548 | impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> { |
549 | where | ||
550 | DB: HirDatabase, | ||
551 | { | ||
552 | fn associated_ty_data(&self, id: AssocTypeId) -> Arc<AssociatedTyDatum> { | 549 | fn associated_ty_data(&self, id: AssocTypeId) -> Arc<AssociatedTyDatum> { |
553 | self.db.associated_ty_data(id) | 550 | self.db.associated_ty_data(id) |
554 | } | 551 | } |
@@ -618,16 +615,16 @@ where | |||
618 | } | 615 | } |
619 | 616 | ||
620 | pub(crate) fn associated_ty_data_query( | 617 | pub(crate) fn associated_ty_data_query( |
621 | db: &impl HirDatabase, | 618 | db: &dyn HirDatabase, |
622 | id: AssocTypeId, | 619 | id: AssocTypeId, |
623 | ) -> Arc<AssociatedTyDatum> { | 620 | ) -> Arc<AssociatedTyDatum> { |
624 | debug!("associated_ty_data {:?}", id); | 621 | debug!("associated_ty_data {:?}", id); |
625 | let type_alias: TypeAliasId = from_chalk(db, id); | 622 | let type_alias: TypeAliasId = from_chalk(db, id); |
626 | let trait_ = match type_alias.lookup(db).container { | 623 | let trait_ = match type_alias.lookup(db.upcast()).container { |
627 | AssocContainerId::TraitId(t) => t, | 624 | AssocContainerId::TraitId(t) => t, |
628 | _ => panic!("associated type not in trait"), | 625 | _ => panic!("associated type not in trait"), |
629 | }; | 626 | }; |
630 | let generic_params = generics(db, type_alias.into()); | 627 | let generic_params = generics(db.upcast(), type_alias.into()); |
631 | let bound_data = chalk_rust_ir::AssociatedTyDatumBound { | 628 | let bound_data = chalk_rust_ir::AssociatedTyDatumBound { |
632 | // FIXME add bounds and where clauses | 629 | // FIXME add bounds and where clauses |
633 | bounds: vec![], | 630 | bounds: vec![], |
@@ -643,7 +640,7 @@ pub(crate) fn associated_ty_data_query( | |||
643 | } | 640 | } |
644 | 641 | ||
645 | pub(crate) fn trait_datum_query( | 642 | pub(crate) fn trait_datum_query( |
646 | db: &impl HirDatabase, | 643 | db: &dyn HirDatabase, |
647 | krate: CrateId, | 644 | krate: CrateId, |
648 | trait_id: TraitId, | 645 | trait_id: TraitId, |
649 | ) -> Arc<TraitDatum> { | 646 | ) -> Arc<TraitDatum> { |
@@ -651,11 +648,11 @@ pub(crate) fn trait_datum_query( | |||
651 | let trait_: hir_def::TraitId = from_chalk(db, trait_id); | 648 | let trait_: hir_def::TraitId = from_chalk(db, trait_id); |
652 | let trait_data = db.trait_data(trait_); | 649 | let trait_data = db.trait_data(trait_); |
653 | debug!("trait {:?} = {:?}", trait_id, trait_data.name); | 650 | debug!("trait {:?} = {:?}", trait_id, trait_data.name); |
654 | let generic_params = generics(db, trait_.into()); | 651 | let generic_params = generics(db.upcast(), trait_.into()); |
655 | let bound_vars = Substs::bound_vars(&generic_params); | 652 | let bound_vars = Substs::bound_vars(&generic_params); |
656 | let flags = chalk_rust_ir::TraitFlags { | 653 | let flags = chalk_rust_ir::TraitFlags { |
657 | auto: trait_data.auto, | 654 | auto: trait_data.auto, |
658 | upstream: trait_.lookup(db).container.module(db).krate != krate, | 655 | upstream: trait_.lookup(db.upcast()).container.module(db.upcast()).krate != krate, |
659 | non_enumerable: true, | 656 | non_enumerable: true, |
660 | coinductive: false, // only relevant for Chalk testing | 657 | coinductive: false, // only relevant for Chalk testing |
661 | // FIXME set these flags correctly | 658 | // FIXME set these flags correctly |
@@ -676,7 +673,7 @@ pub(crate) fn trait_datum_query( | |||
676 | } | 673 | } |
677 | 674 | ||
678 | pub(crate) fn struct_datum_query( | 675 | pub(crate) fn struct_datum_query( |
679 | db: &impl HirDatabase, | 676 | db: &dyn HirDatabase, |
680 | krate: CrateId, | 677 | krate: CrateId, |
681 | struct_id: StructId, | 678 | struct_id: StructId, |
682 | ) -> Arc<StructDatum> { | 679 | ) -> Arc<StructDatum> { |
@@ -688,7 +685,7 @@ pub(crate) fn struct_datum_query( | |||
688 | let where_clauses = type_ctor | 685 | let where_clauses = type_ctor |
689 | .as_generic_def() | 686 | .as_generic_def() |
690 | .map(|generic_def| { | 687 | .map(|generic_def| { |
691 | let generic_params = generics(db, generic_def); | 688 | let generic_params = generics(db.upcast(), generic_def); |
692 | let bound_vars = Substs::bound_vars(&generic_params); | 689 | let bound_vars = Substs::bound_vars(&generic_params); |
693 | convert_where_clauses(db, generic_def, &bound_vars) | 690 | convert_where_clauses(db, generic_def, &bound_vars) |
694 | }) | 691 | }) |
@@ -708,7 +705,7 @@ pub(crate) fn struct_datum_query( | |||
708 | } | 705 | } |
709 | 706 | ||
710 | pub(crate) fn impl_datum_query( | 707 | pub(crate) fn impl_datum_query( |
711 | db: &impl HirDatabase, | 708 | db: &dyn HirDatabase, |
712 | krate: CrateId, | 709 | krate: CrateId, |
713 | impl_id: ImplId, | 710 | impl_id: ImplId, |
714 | ) -> Arc<ImplDatum> { | 711 | ) -> Arc<ImplDatum> { |
@@ -722,7 +719,7 @@ pub(crate) fn impl_datum_query( | |||
722 | } | 719 | } |
723 | 720 | ||
724 | fn impl_def_datum( | 721 | fn impl_def_datum( |
725 | db: &impl HirDatabase, | 722 | db: &dyn HirDatabase, |
726 | krate: CrateId, | 723 | krate: CrateId, |
727 | chalk_id: ImplId, | 724 | chalk_id: ImplId, |
728 | impl_id: hir_def::ImplId, | 725 | impl_id: hir_def::ImplId, |
@@ -734,10 +731,10 @@ fn impl_def_datum( | |||
734 | .value; | 731 | .value; |
735 | let impl_data = db.impl_data(impl_id); | 732 | let impl_data = db.impl_data(impl_id); |
736 | 733 | ||
737 | let generic_params = generics(db, impl_id.into()); | 734 | let generic_params = generics(db.upcast(), impl_id.into()); |
738 | let bound_vars = Substs::bound_vars(&generic_params); | 735 | let bound_vars = Substs::bound_vars(&generic_params); |
739 | let trait_ = trait_ref.trait_; | 736 | let trait_ = trait_ref.trait_; |
740 | let impl_type = if impl_id.lookup(db).container.module(db).krate == krate { | 737 | let impl_type = if impl_id.lookup(db.upcast()).container.module(db.upcast()).krate == krate { |
741 | chalk_rust_ir::ImplType::Local | 738 | chalk_rust_ir::ImplType::Local |
742 | } else { | 739 | } else { |
743 | chalk_rust_ir::ImplType::External | 740 | chalk_rust_ir::ImplType::External |
@@ -786,7 +783,7 @@ fn impl_def_datum( | |||
786 | } | 783 | } |
787 | 784 | ||
788 | pub(crate) fn associated_ty_value_query( | 785 | pub(crate) fn associated_ty_value_query( |
789 | db: &impl HirDatabase, | 786 | db: &dyn HirDatabase, |
790 | krate: CrateId, | 787 | krate: CrateId, |
791 | id: AssociatedTyValueId, | 788 | id: AssociatedTyValueId, |
792 | ) -> Arc<AssociatedTyValue> { | 789 | ) -> Arc<AssociatedTyValue> { |
@@ -800,12 +797,12 @@ pub(crate) fn associated_ty_value_query( | |||
800 | } | 797 | } |
801 | 798 | ||
802 | fn type_alias_associated_ty_value( | 799 | fn type_alias_associated_ty_value( |
803 | db: &impl HirDatabase, | 800 | db: &dyn HirDatabase, |
804 | _krate: CrateId, | 801 | _krate: CrateId, |
805 | type_alias: TypeAliasId, | 802 | type_alias: TypeAliasId, |
806 | ) -> Arc<AssociatedTyValue> { | 803 | ) -> Arc<AssociatedTyValue> { |
807 | let type_alias_data = db.type_alias_data(type_alias); | 804 | let type_alias_data = db.type_alias_data(type_alias); |
808 | let impl_id = match type_alias.lookup(db).container { | 805 | let impl_id = match type_alias.lookup(db.upcast()).container { |
809 | AssocContainerId::ImplId(it) => it, | 806 | AssocContainerId::ImplId(it) => it, |
810 | _ => panic!("assoc ty value should be in impl"), | 807 | _ => panic!("assoc ty value should be in impl"), |
811 | }; | 808 | }; |