diff options
author | Florian Diebold <[email protected]> | 2021-03-13 19:05:47 +0000 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2021-03-13 19:05:47 +0000 |
commit | b035c314b4b0ecd2477fde216dbe7e8801f94d0d (patch) | |
tree | a2e152f5f16dd92f4c4be011be2399998dc7eb6f /crates/hir_ty/src/lib.rs | |
parent | 1bf6b7360c3f1d0e20dece5227979bc4d74a352f (diff) |
Use chalk_ir::OpaqueTyId
Diffstat (limited to 'crates/hir_ty/src/lib.rs')
-rw-r--r-- | crates/hir_ty/src/lib.rs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs index d1c018283..d6ff968f0 100644 --- a/crates/hir_ty/src/lib.rs +++ b/crates/hir_ty/src/lib.rs | |||
@@ -54,6 +54,7 @@ pub type ForeignDefId = chalk_ir::ForeignDefId<Interner>; | |||
54 | pub type AssocTypeId = chalk_ir::AssocTypeId<Interner>; | 54 | pub type AssocTypeId = chalk_ir::AssocTypeId<Interner>; |
55 | pub type FnDefId = chalk_ir::FnDefId<Interner>; | 55 | pub type FnDefId = chalk_ir::FnDefId<Interner>; |
56 | pub type ClosureId = chalk_ir::ClosureId<Interner>; | 56 | pub type ClosureId = chalk_ir::ClosureId<Interner>; |
57 | pub type OpaqueTyId = chalk_ir::OpaqueTyId<Interner>; | ||
57 | pub type PlaceholderIndex = chalk_ir::PlaceholderIndex; | 58 | pub type PlaceholderIndex = chalk_ir::PlaceholderIndex; |
58 | 59 | ||
59 | #[derive(Clone, PartialEq, Eq, Debug, Hash)] | 60 | #[derive(Clone, PartialEq, Eq, Debug, Hash)] |
@@ -875,8 +876,8 @@ impl Ty { | |||
875 | pub fn impl_trait_bounds(&self, db: &dyn HirDatabase) -> Option<Vec<GenericPredicate>> { | 876 | pub fn impl_trait_bounds(&self, db: &dyn HirDatabase) -> Option<Vec<GenericPredicate>> { |
876 | match self.interned(&Interner) { | 877 | match self.interned(&Interner) { |
877 | TyKind::OpaqueType(opaque_ty_id, ..) => { | 878 | TyKind::OpaqueType(opaque_ty_id, ..) => { |
878 | match opaque_ty_id { | 879 | match db.lookup_intern_impl_trait_id((*opaque_ty_id).into()) { |
879 | OpaqueTyId::AsyncBlockTypeImplTrait(def, _expr) => { | 880 | ImplTraitId::AsyncBlockTypeImplTrait(def, _expr) => { |
880 | let krate = def.module(db.upcast()).krate(); | 881 | let krate = def.module(db.upcast()).krate(); |
881 | if let Some(future_trait) = db | 882 | if let Some(future_trait) = db |
882 | .lang_item(krate, "future_trait".into()) | 883 | .lang_item(krate, "future_trait".into()) |
@@ -894,12 +895,13 @@ impl Ty { | |||
894 | None | 895 | None |
895 | } | 896 | } |
896 | } | 897 | } |
897 | OpaqueTyId::ReturnTypeImplTrait(..) => None, | 898 | ImplTraitId::ReturnTypeImplTrait(..) => None, |
898 | } | 899 | } |
899 | } | 900 | } |
900 | TyKind::Alias(AliasTy::Opaque(opaque_ty)) => { | 901 | TyKind::Alias(AliasTy::Opaque(opaque_ty)) => { |
901 | let predicates = match opaque_ty.opaque_ty_id { | 902 | let predicates = match db.lookup_intern_impl_trait_id(opaque_ty.opaque_ty_id.into()) |
902 | OpaqueTyId::ReturnTypeImplTrait(func, idx) => { | 903 | { |
904 | ImplTraitId::ReturnTypeImplTrait(func, idx) => { | ||
903 | db.return_type_impl_traits(func).map(|it| { | 905 | db.return_type_impl_traits(func).map(|it| { |
904 | let data = (*it) | 906 | let data = (*it) |
905 | .as_ref() | 907 | .as_ref() |
@@ -908,7 +910,7 @@ impl Ty { | |||
908 | }) | 910 | }) |
909 | } | 911 | } |
910 | // It always has an parameter for Future::Output type. | 912 | // It always has an parameter for Future::Output type. |
911 | OpaqueTyId::AsyncBlockTypeImplTrait(..) => unreachable!(), | 913 | ImplTraitId::AsyncBlockTypeImplTrait(..) => unreachable!(), |
912 | }; | 914 | }; |
913 | 915 | ||
914 | predicates.map(|it| it.value) | 916 | predicates.map(|it| it.value) |
@@ -1123,7 +1125,7 @@ impl<T: TypeWalk> TypeWalk for Vec<T> { | |||
1123 | } | 1125 | } |
1124 | 1126 | ||
1125 | #[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)] | 1127 | #[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)] |
1126 | pub enum OpaqueTyId { | 1128 | pub enum ImplTraitId { |
1127 | ReturnTypeImplTrait(hir_def::FunctionId, u16), | 1129 | ReturnTypeImplTrait(hir_def::FunctionId, u16), |
1128 | AsyncBlockTypeImplTrait(hir_def::DefWithBodyId, ExprId), | 1130 | AsyncBlockTypeImplTrait(hir_def::DefWithBodyId, ExprId), |
1129 | } | 1131 | } |