diff options
Diffstat (limited to 'crates/hir_ty/src/lib.rs')
-rw-r--r-- | crates/hir_ty/src/lib.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs index be6fe5016..e586d73d8 100644 --- a/crates/hir_ty/src/lib.rs +++ b/crates/hir_ty/src/lib.rs | |||
@@ -927,6 +927,35 @@ impl TyBuilder<hir_def::AdtId> { | |||
927 | } | 927 | } |
928 | } | 928 | } |
929 | 929 | ||
930 | impl TyBuilder<TraitId> { | ||
931 | pub fn trait_ref(db: &dyn HirDatabase, trait_id: TraitId) -> TyBuilder<TraitId> { | ||
932 | let generics = generics(db.upcast(), trait_id.into()); | ||
933 | let param_count = generics.len(); | ||
934 | TyBuilder::new(trait_id, param_count) | ||
935 | } | ||
936 | |||
937 | pub fn build(self) -> TraitRef { | ||
938 | let (trait_id, substitution) = self.build_internal(); | ||
939 | TraitRef { trait_id: to_chalk_trait_id(trait_id), substitution } | ||
940 | } | ||
941 | } | ||
942 | |||
943 | impl TyBuilder<TypeAliasId> { | ||
944 | pub fn assoc_type_projection( | ||
945 | db: &dyn HirDatabase, | ||
946 | type_alias: TypeAliasId, | ||
947 | ) -> TyBuilder<TypeAliasId> { | ||
948 | let generics = generics(db.upcast(), type_alias.into()); | ||
949 | let param_count = generics.len(); | ||
950 | TyBuilder::new(type_alias, param_count) | ||
951 | } | ||
952 | |||
953 | pub fn build(self) -> ProjectionTy { | ||
954 | let (type_alias, substitution) = self.build_internal(); | ||
955 | ProjectionTy { associated_ty_id: to_assoc_type_id(type_alias), substitution } | ||
956 | } | ||
957 | } | ||
958 | |||
930 | impl Ty { | 959 | impl Ty { |
931 | pub fn as_reference(&self) -> Option<(&Ty, Mutability)> { | 960 | pub fn as_reference(&self) -> Option<(&Ty, Mutability)> { |
932 | match self.kind(&Interner) { | 961 | match self.kind(&Interner) { |