aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/lib.rs
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2021-04-05 20:14:49 +0100
committerFlorian Diebold <[email protected]>2021-04-05 20:58:01 +0100
commit788533d38091472ed05c8b55fd7a2002c49f4eb7 (patch)
tree25d131cb108e52f8abc585642730c4f29abb3727 /crates/hir_ty/src/lib.rs
parent8c96a7d81e29061537d78b5670a3474cb136422d (diff)
Move ProjectionTy methods to extension trait
Diffstat (limited to 'crates/hir_ty/src/lib.rs')
-rw-r--r--crates/hir_ty/src/lib.rs26
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
44pub use autoderef::autoderef; 44pub use autoderef::autoderef;
45pub use builder::TyBuilder; 45pub use builder::TyBuilder;
46pub use chalk_ext::TyExt; 46pub use chalk_ext::{ProjectionTyExt, TyExt};
47pub use infer::{could_unify, InferenceResult, InferenceVar}; 47pub use infer::{could_unify, InferenceResult, InferenceVar};
48pub use lower::{ 48pub 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};
52pub use traits::TraitEnvironment; 52pub use traits::{chalk::Interner, TraitEnvironment};
53pub use types::*; 53pub use types::*;
54pub use walk::TypeWalk; 54pub 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
60pub use crate::traits::chalk::Interner;
61
62pub type ForeignDefId = chalk_ir::ForeignDefId<Interner>; 60pub type ForeignDefId = chalk_ir::ForeignDefId<Interner>;
63pub type AssocTypeId = chalk_ir::AssocTypeId<Interner>; 61pub type AssocTypeId = chalk_ir::AssocTypeId<Interner>;
64pub type FnDefId = chalk_ir::FnDefId<Interner>; 62pub type FnDefId = chalk_ir::FnDefId<Interner>;
@@ -76,26 +74,6 @@ pub type LifetimeOutlives = chalk_ir::LifetimeOutlives<Interner>;
76 74
77pub type ChalkTraitId = chalk_ir::TraitId<Interner>; 75pub type ChalkTraitId = chalk_ir::TraitId<Interner>;
78 76
79impl 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
99pub type FnSig = chalk_ir::FnSig<Interner>; 77pub type FnSig = chalk_ir::FnSig<Interner>;
100 78
101impl Substitution { 79impl Substitution {