aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/lib.rs
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2021-04-05 20:29:20 +0100
committerFlorian Diebold <[email protected]>2021-04-05 20:58:03 +0100
commitb443e5304ec43ae2049c72b694ff62baf4314cbb (patch)
tree30a4648745c87468d435c30edf9dbe851a7830ae /crates/hir_ty/src/lib.rs
parent738174671ae40092684d7a9a543f939e318051e5 (diff)
Remove some unused methods, move some to types.rs
Diffstat (limited to 'crates/hir_ty/src/lib.rs')
-rw-r--r--crates/hir_ty/src/lib.rs29
1 files changed, 0 insertions, 29 deletions
diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs
index 61f5adbc4..2c70c4277 100644
--- a/crates/hir_ty/src/lib.rs
+++ b/crates/hir_ty/src/lib.rs
@@ -99,15 +99,6 @@ where
99 Binders::empty(&Interner, value.shifted_in_from(DebruijnIndex::ONE)) 99 Binders::empty(&Interner, value.shifted_in_from(DebruijnIndex::ONE))
100} 100}
101 101
102impl<T: TypeWalk> Binders<T> {
103 /// Substitutes all variables.
104 pub fn substitute(self, interner: &Interner, subst: &Substitution) -> T {
105 let (value, binders) = self.into_value_and_skipped_binders();
106 assert_eq!(subst.len(interner), binders.len(interner));
107 value.subst_bound_vars(subst)
108 }
109}
110
111pub fn make_only_type_binders<T>(num_vars: usize, value: T) -> Binders<T> { 102pub fn make_only_type_binders<T>(num_vars: usize, value: T) -> Binders<T> {
112 Binders::new( 103 Binders::new(
113 VariableKinds::from_iter( 104 VariableKinds::from_iter(
@@ -120,31 +111,11 @@ pub fn make_only_type_binders<T>(num_vars: usize, value: T) -> Binders<T> {
120} 111}
121 112
122impl TraitRef { 113impl TraitRef {
123 pub fn self_type_parameter(&self, interner: &Interner) -> &Ty {
124 &self.substitution.at(interner, 0).assert_ty_ref(interner)
125 }
126
127 pub fn hir_trait_id(&self) -> TraitId { 114 pub fn hir_trait_id(&self) -> TraitId {
128 from_chalk_trait_id(self.trait_id) 115 from_chalk_trait_id(self.trait_id)
129 } 116 }
130} 117}
131 118
132impl WhereClause {
133 pub fn is_implemented(&self) -> bool {
134 matches!(self, WhereClause::Implemented(_))
135 }
136
137 pub fn trait_ref(&self, db: &dyn HirDatabase) -> Option<TraitRef> {
138 match self {
139 WhereClause::Implemented(tr) => Some(tr.clone()),
140 WhereClause::AliasEq(AliasEq { alias: AliasTy::Projection(proj), .. }) => {
141 Some(proj.trait_ref(db))
142 }
143 WhereClause::AliasEq(_) => None,
144 }
145 }
146}
147
148impl<T> Canonical<T> { 119impl<T> Canonical<T> {
149 pub fn new(value: T, kinds: impl IntoIterator<Item = TyVariableKind>) -> Self { 120 pub fn new(value: T, kinds: impl IntoIterator<Item = TyVariableKind>) -> Self {
150 let kinds = kinds.into_iter().map(|tk| { 121 let kinds = kinds.into_iter().map(|tk| {