diff options
Diffstat (limited to 'crates/ra_hir_ty/src/traits/chalk')
-rw-r--r-- | crates/ra_hir_ty/src/traits/chalk/interner.rs | 14 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/traits/chalk/mapping.rs | 40 |
2 files changed, 27 insertions, 27 deletions
diff --git a/crates/ra_hir_ty/src/traits/chalk/interner.rs b/crates/ra_hir_ty/src/traits/chalk/interner.rs index 2a27f8ed8..e27074ba6 100644 --- a/crates/ra_hir_ty/src/traits/chalk/interner.rs +++ b/crates/ra_hir_ty/src/traits/chalk/interner.rs | |||
@@ -11,17 +11,17 @@ use std::{fmt, sync::Arc}; | |||
11 | pub struct Interner; | 11 | pub struct Interner; |
12 | 12 | ||
13 | pub type AssocTypeId = chalk_ir::AssocTypeId<Interner>; | 13 | pub type AssocTypeId = chalk_ir::AssocTypeId<Interner>; |
14 | pub type AssociatedTyDatum = chalk_rust_ir::AssociatedTyDatum<Interner>; | 14 | pub type AssociatedTyDatum = chalk_solve::rust_ir::AssociatedTyDatum<Interner>; |
15 | pub type TraitId = chalk_ir::TraitId<Interner>; | 15 | pub type TraitId = chalk_ir::TraitId<Interner>; |
16 | pub type TraitDatum = chalk_rust_ir::TraitDatum<Interner>; | 16 | pub type TraitDatum = chalk_solve::rust_ir::TraitDatum<Interner>; |
17 | pub type AdtId = chalk_ir::AdtId<Interner>; | 17 | pub type AdtId = chalk_ir::AdtId<Interner>; |
18 | pub type StructDatum = chalk_rust_ir::AdtDatum<Interner>; | 18 | pub type StructDatum = chalk_solve::rust_ir::AdtDatum<Interner>; |
19 | pub type ImplId = chalk_ir::ImplId<Interner>; | 19 | pub type ImplId = chalk_ir::ImplId<Interner>; |
20 | pub type ImplDatum = chalk_rust_ir::ImplDatum<Interner>; | 20 | pub type ImplDatum = chalk_solve::rust_ir::ImplDatum<Interner>; |
21 | pub type AssociatedTyValueId = chalk_rust_ir::AssociatedTyValueId<Interner>; | 21 | pub type AssociatedTyValueId = chalk_solve::rust_ir::AssociatedTyValueId<Interner>; |
22 | pub type AssociatedTyValue = chalk_rust_ir::AssociatedTyValue<Interner>; | 22 | pub type AssociatedTyValue = chalk_solve::rust_ir::AssociatedTyValue<Interner>; |
23 | pub type FnDefId = chalk_ir::FnDefId<Interner>; | 23 | pub type FnDefId = chalk_ir::FnDefId<Interner>; |
24 | pub type FnDefDatum = chalk_rust_ir::FnDefDatum<Interner>; | 24 | pub type FnDefDatum = chalk_solve::rust_ir::FnDefDatum<Interner>; |
25 | 25 | ||
26 | impl chalk_ir::interner::Interner for Interner { | 26 | impl chalk_ir::interner::Interner for Interner { |
27 | type InternedType = Box<chalk_ir::TyData<Self>>; // FIXME use Arc? | 27 | type InternedType = Box<chalk_ir::TyData<Self>>; // FIXME use Arc? |
diff --git a/crates/ra_hir_ty/src/traits/chalk/mapping.rs b/crates/ra_hir_ty/src/traits/chalk/mapping.rs index 7082cb095..5f6daf842 100644 --- a/crates/ra_hir_ty/src/traits/chalk/mapping.rs +++ b/crates/ra_hir_ty/src/traits/chalk/mapping.rs | |||
@@ -7,6 +7,7 @@ use chalk_ir::{ | |||
7 | cast::Cast, fold::shift::Shift, interner::HasInterner, PlaceholderIndex, Scalar, TypeName, | 7 | cast::Cast, fold::shift::Shift, interner::HasInterner, PlaceholderIndex, Scalar, TypeName, |
8 | UniverseIndex, | 8 | UniverseIndex, |
9 | }; | 9 | }; |
10 | use chalk_solve::rust_ir; | ||
10 | 11 | ||
11 | use hir_def::{type_ref::Mutability, AssocContainerId, GenericDefId, Lookup, TypeAliasId}; | 12 | use hir_def::{type_ref::Mutability, AssocContainerId, GenericDefId, Lookup, TypeAliasId}; |
12 | use ra_db::salsa::InternKey; | 13 | use ra_db::salsa::InternKey; |
@@ -106,7 +107,7 @@ impl ToChalk for Ty { | |||
106 | }) | 107 | }) |
107 | } | 108 | } |
108 | chalk_ir::TyData::BoundVar(idx) => Ty::Bound(idx), | 109 | chalk_ir::TyData::BoundVar(idx) => Ty::Bound(idx), |
109 | chalk_ir::TyData::InferenceVar(_iv) => Ty::Unknown, | 110 | chalk_ir::TyData::InferenceVar(_iv, _kind) => Ty::Unknown, |
110 | chalk_ir::TyData::Dyn(where_clauses) => { | 111 | chalk_ir::TyData::Dyn(where_clauses) => { |
111 | assert_eq!(where_clauses.bounds.binders.len(&Interner), 1); | 112 | assert_eq!(where_clauses.bounds.binders.len(&Interner), 1); |
112 | let predicates = where_clauses | 113 | let predicates = where_clauses |
@@ -232,12 +233,13 @@ impl ToChalk for TypeCtor { | |||
232 | let id = callable_def.to_chalk(db); | 233 | let id = callable_def.to_chalk(db); |
233 | TypeName::FnDef(id) | 234 | TypeName::FnDef(id) |
234 | } | 235 | } |
236 | TypeCtor::Never => TypeName::Never, | ||
237 | |||
235 | TypeCtor::Int(Uncertain::Unknown) | 238 | TypeCtor::Int(Uncertain::Unknown) |
236 | | TypeCtor::Float(Uncertain::Unknown) | 239 | | TypeCtor::Float(Uncertain::Unknown) |
237 | | TypeCtor::Adt(_) | 240 | | TypeCtor::Adt(_) |
238 | | TypeCtor::Array | 241 | | TypeCtor::Array |
239 | | TypeCtor::FnPtr { .. } | 242 | | TypeCtor::FnPtr { .. } |
240 | | TypeCtor::Never | ||
241 | | TypeCtor::Closure { .. } => { | 243 | | TypeCtor::Closure { .. } => { |
242 | // other TypeCtors get interned and turned into a chalk StructId | 244 | // other TypeCtors get interned and turned into a chalk StructId |
243 | let struct_id = db.intern_type_ctor(self).into(); | 245 | let struct_id = db.intern_type_ctor(self).into(); |
@@ -273,13 +275,14 @@ impl ToChalk for TypeCtor { | |||
273 | TypeName::Slice => TypeCtor::Slice, | 275 | TypeName::Slice => TypeCtor::Slice, |
274 | TypeName::Ref(mutability) => TypeCtor::Ref(from_chalk(db, mutability)), | 276 | TypeName::Ref(mutability) => TypeCtor::Ref(from_chalk(db, mutability)), |
275 | TypeName::Str => TypeCtor::Str, | 277 | TypeName::Str => TypeCtor::Str, |
278 | TypeName::Never => TypeCtor::Never, | ||
276 | 279 | ||
277 | TypeName::FnDef(fn_def_id) => { | 280 | TypeName::FnDef(fn_def_id) => { |
278 | let callable_def = from_chalk(db, fn_def_id); | 281 | let callable_def = from_chalk(db, fn_def_id); |
279 | TypeCtor::FnDef(callable_def) | 282 | TypeCtor::FnDef(callable_def) |
280 | } | 283 | } |
281 | 284 | ||
282 | TypeName::Error => { | 285 | TypeName::Array | TypeName::Error => { |
283 | // this should not be reached, since we don't represent TypeName::Error with TypeCtor | 286 | // this should not be reached, since we don't represent TypeName::Error with TypeCtor |
284 | unreachable!() | 287 | unreachable!() |
285 | } | 288 | } |
@@ -508,7 +511,7 @@ where | |||
508 | 511 | ||
509 | fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Canonical<T::Chalk> { | 512 | fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Canonical<T::Chalk> { |
510 | let parameter = chalk_ir::CanonicalVarKind::new( | 513 | let parameter = chalk_ir::CanonicalVarKind::new( |
511 | chalk_ir::VariableKind::Ty, | 514 | chalk_ir::VariableKind::Ty(chalk_ir::TyKind::General), |
512 | chalk_ir::UniverseIndex::ROOT, | 515 | chalk_ir::UniverseIndex::ROOT, |
513 | ); | 516 | ); |
514 | let value = self.value.to_chalk(db); | 517 | let value = self.value.to_chalk(db); |
@@ -579,17 +582,17 @@ impl ToChalk for builtin::BuiltinImplData { | |||
579 | type Chalk = ImplDatum; | 582 | type Chalk = ImplDatum; |
580 | 583 | ||
581 | fn to_chalk(self, db: &dyn HirDatabase) -> ImplDatum { | 584 | fn to_chalk(self, db: &dyn HirDatabase) -> ImplDatum { |
582 | let impl_type = chalk_rust_ir::ImplType::External; | 585 | let impl_type = rust_ir::ImplType::External; |
583 | let where_clauses = self.where_clauses.into_iter().map(|w| w.to_chalk(db)).collect(); | 586 | let where_clauses = self.where_clauses.into_iter().map(|w| w.to_chalk(db)).collect(); |
584 | 587 | ||
585 | let impl_datum_bound = | 588 | let impl_datum_bound = |
586 | chalk_rust_ir::ImplDatumBound { trait_ref: self.trait_ref.to_chalk(db), where_clauses }; | 589 | rust_ir::ImplDatumBound { trait_ref: self.trait_ref.to_chalk(db), where_clauses }; |
587 | let associated_ty_value_ids = | 590 | let associated_ty_value_ids = |
588 | self.assoc_ty_values.into_iter().map(|v| v.to_chalk(db)).collect(); | 591 | self.assoc_ty_values.into_iter().map(|v| v.to_chalk(db)).collect(); |
589 | chalk_rust_ir::ImplDatum { | 592 | rust_ir::ImplDatum { |
590 | binders: make_binders(impl_datum_bound, self.num_vars), | 593 | binders: make_binders(impl_datum_bound, self.num_vars), |
591 | impl_type, | 594 | impl_type, |
592 | polarity: chalk_rust_ir::Polarity::Positive, | 595 | polarity: rust_ir::Polarity::Positive, |
593 | associated_ty_value_ids, | 596 | associated_ty_value_ids, |
594 | } | 597 | } |
595 | } | 598 | } |
@@ -604,9 +607,9 @@ impl ToChalk for builtin::BuiltinImplAssocTyValueData { | |||
604 | 607 | ||
605 | fn to_chalk(self, db: &dyn HirDatabase) -> AssociatedTyValue { | 608 | fn to_chalk(self, db: &dyn HirDatabase) -> AssociatedTyValue { |
606 | let ty = self.value.to_chalk(db); | 609 | let ty = self.value.to_chalk(db); |
607 | let value_bound = chalk_rust_ir::AssociatedTyValueBound { ty }; | 610 | let value_bound = rust_ir::AssociatedTyValueBound { ty }; |
608 | 611 | ||
609 | chalk_rust_ir::AssociatedTyValue { | 612 | rust_ir::AssociatedTyValue { |
610 | associated_ty_id: self.assoc_ty_id.to_chalk(db), | 613 | associated_ty_id: self.assoc_ty_id.to_chalk(db), |
611 | impl_id: self.impl_.to_chalk(db), | 614 | impl_id: self.impl_.to_chalk(db), |
612 | value: make_binders(value_bound, self.num_vars), | 615 | value: make_binders(value_bound, self.num_vars), |
@@ -628,7 +631,7 @@ where | |||
628 | chalk_ir::Binders::new( | 631 | chalk_ir::Binders::new( |
629 | chalk_ir::VariableKinds::from( | 632 | chalk_ir::VariableKinds::from( |
630 | &Interner, | 633 | &Interner, |
631 | std::iter::repeat(chalk_ir::VariableKind::Ty).take(num_vars), | 634 | std::iter::repeat(chalk_ir::VariableKind::Ty(chalk_ir::TyKind::General)).take(num_vars), |
632 | ), | 635 | ), |
633 | value, | 636 | value, |
634 | ) | 637 | ) |
@@ -655,7 +658,7 @@ pub(super) fn generic_predicate_to_inline_bound( | |||
655 | db: &dyn HirDatabase, | 658 | db: &dyn HirDatabase, |
656 | pred: &GenericPredicate, | 659 | pred: &GenericPredicate, |
657 | self_ty: &Ty, | 660 | self_ty: &Ty, |
658 | ) -> Option<chalk_rust_ir::InlineBound<Interner>> { | 661 | ) -> Option<rust_ir::InlineBound<Interner>> { |
659 | // An InlineBound is like a GenericPredicate, except the self type is left out. | 662 | // An InlineBound is like a GenericPredicate, except the self type is left out. |
660 | // We don't have a special type for this, but Chalk does. | 663 | // We don't have a special type for this, but Chalk does. |
661 | match pred { | 664 | match pred { |
@@ -670,8 +673,8 @@ pub(super) fn generic_predicate_to_inline_bound( | |||
670 | .map(|ty| ty.clone().to_chalk(db).cast(&Interner)) | 673 | .map(|ty| ty.clone().to_chalk(db).cast(&Interner)) |
671 | .collect(); | 674 | .collect(); |
672 | let trait_bound = | 675 | let trait_bound = |
673 | chalk_rust_ir::TraitBound { trait_id: trait_ref.trait_.to_chalk(db), args_no_self }; | 676 | rust_ir::TraitBound { trait_id: trait_ref.trait_.to_chalk(db), args_no_self }; |
674 | Some(chalk_rust_ir::InlineBound::TraitBound(trait_bound)) | 677 | Some(rust_ir::InlineBound::TraitBound(trait_bound)) |
675 | } | 678 | } |
676 | GenericPredicate::Projection(proj) => { | 679 | GenericPredicate::Projection(proj) => { |
677 | if &proj.projection_ty.parameters[0] != self_ty { | 680 | if &proj.projection_ty.parameters[0] != self_ty { |
@@ -685,16 +688,13 @@ pub(super) fn generic_predicate_to_inline_bound( | |||
685 | .iter() | 688 | .iter() |
686 | .map(|ty| ty.clone().to_chalk(db).cast(&Interner)) | 689 | .map(|ty| ty.clone().to_chalk(db).cast(&Interner)) |
687 | .collect(); | 690 | .collect(); |
688 | let alias_eq_bound = chalk_rust_ir::AliasEqBound { | 691 | let alias_eq_bound = rust_ir::AliasEqBound { |
689 | value: proj.ty.clone().to_chalk(db), | 692 | value: proj.ty.clone().to_chalk(db), |
690 | trait_bound: chalk_rust_ir::TraitBound { | 693 | trait_bound: rust_ir::TraitBound { trait_id: trait_.to_chalk(db), args_no_self }, |
691 | trait_id: trait_.to_chalk(db), | ||
692 | args_no_self, | ||
693 | }, | ||
694 | associated_ty_id: proj.projection_ty.associated_ty.to_chalk(db), | 694 | associated_ty_id: proj.projection_ty.associated_ty.to_chalk(db), |
695 | parameters: Vec::new(), // FIXME we don't support generic associated types yet | 695 | parameters: Vec::new(), // FIXME we don't support generic associated types yet |
696 | }; | 696 | }; |
697 | Some(chalk_rust_ir::InlineBound::AliasEqBound(alias_eq_bound)) | 697 | Some(rust_ir::InlineBound::AliasEqBound(alias_eq_bound)) |
698 | } | 698 | } |
699 | GenericPredicate::Error => None, | 699 | GenericPredicate::Error => None, |
700 | } | 700 | } |