diff options
author | Florian Diebold <[email protected]> | 2021-04-05 20:14:49 +0100 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2021-04-05 20:58:01 +0100 |
commit | 788533d38091472ed05c8b55fd7a2002c49f4eb7 (patch) | |
tree | 25d131cb108e52f8abc585642730c4f29abb3727 /crates/hir_ty/src/lib.rs | |
parent | 8c96a7d81e29061537d78b5670a3474cb136422d (diff) |
Move ProjectionTy methods to extension trait
Diffstat (limited to 'crates/hir_ty/src/lib.rs')
-rw-r--r-- | crates/hir_ty/src/lib.rs | 26 |
1 files changed, 2 insertions, 24 deletions
diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs index a3addc8e9..928dd76e5 100644 --- a/crates/hir_ty/src/lib.rs +++ b/crates/hir_ty/src/lib.rs | |||
@@ -43,13 +43,13 @@ use crate::{db::HirDatabase, display::HirDisplay, utils::generics}; | |||
43 | 43 | ||
44 | pub use autoderef::autoderef; | 44 | pub use autoderef::autoderef; |
45 | pub use builder::TyBuilder; | 45 | pub use builder::TyBuilder; |
46 | pub use chalk_ext::TyExt; | 46 | pub use chalk_ext::{ProjectionTyExt, TyExt}; |
47 | pub use infer::{could_unify, InferenceResult, InferenceVar}; | 47 | pub use infer::{could_unify, InferenceResult, InferenceVar}; |
48 | pub use lower::{ | 48 | pub use lower::{ |
49 | associated_type_shorthand_candidates, callable_item_sig, CallableDefId, ImplTraitLoweringMode, | 49 | associated_type_shorthand_candidates, callable_item_sig, CallableDefId, ImplTraitLoweringMode, |
50 | TyDefId, TyLoweringContext, ValueTyDefId, | 50 | TyDefId, TyLoweringContext, ValueTyDefId, |
51 | }; | 51 | }; |
52 | pub use traits::TraitEnvironment; | 52 | pub use traits::{chalk::Interner, TraitEnvironment}; |
53 | pub use types::*; | 53 | pub use types::*; |
54 | pub use walk::TypeWalk; | 54 | pub use walk::TypeWalk; |
55 | 55 | ||
@@ -57,8 +57,6 @@ pub use chalk_ir::{ | |||
57 | cast::Cast, AdtId, BoundVar, DebruijnIndex, Mutability, Safety, Scalar, TyVariableKind, | 57 | cast::Cast, AdtId, BoundVar, DebruijnIndex, Mutability, Safety, Scalar, TyVariableKind, |
58 | }; | 58 | }; |
59 | 59 | ||
60 | pub use crate::traits::chalk::Interner; | ||
61 | |||
62 | pub type ForeignDefId = chalk_ir::ForeignDefId<Interner>; | 60 | pub type ForeignDefId = chalk_ir::ForeignDefId<Interner>; |
63 | pub type AssocTypeId = chalk_ir::AssocTypeId<Interner>; | 61 | pub type AssocTypeId = chalk_ir::AssocTypeId<Interner>; |
64 | pub type FnDefId = chalk_ir::FnDefId<Interner>; | 62 | pub type FnDefId = chalk_ir::FnDefId<Interner>; |
@@ -76,26 +74,6 @@ pub type LifetimeOutlives = chalk_ir::LifetimeOutlives<Interner>; | |||
76 | 74 | ||
77 | pub type ChalkTraitId = chalk_ir::TraitId<Interner>; | 75 | pub type ChalkTraitId = chalk_ir::TraitId<Interner>; |
78 | 76 | ||
79 | impl ProjectionTy { | ||
80 | pub fn trait_ref(&self, db: &dyn HirDatabase) -> TraitRef { | ||
81 | TraitRef { | ||
82 | trait_id: to_chalk_trait_id(self.trait_(db)), | ||
83 | substitution: self.substitution.clone(), | ||
84 | } | ||
85 | } | ||
86 | |||
87 | pub fn self_type_parameter(&self, interner: &Interner) -> &Ty { | ||
88 | &self.substitution.interned()[0].assert_ty_ref(interner) | ||
89 | } | ||
90 | |||
91 | fn trait_(&self, db: &dyn HirDatabase) -> TraitId { | ||
92 | match from_assoc_type_id(self.associated_ty_id).lookup(db.upcast()).container { | ||
93 | AssocContainerId::TraitId(it) => it, | ||
94 | _ => panic!("projection ty without parent trait"), | ||
95 | } | ||
96 | } | ||
97 | } | ||
98 | |||
99 | pub type FnSig = chalk_ir::FnSig<Interner>; | 77 | pub type FnSig = chalk_ir::FnSig<Interner>; |
100 | 78 | ||
101 | impl Substitution { | 79 | impl Substitution { |