diff options
author | Florian Diebold <[email protected]> | 2021-04-05 20:29:20 +0100 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2021-04-05 20:58:03 +0100 |
commit | b443e5304ec43ae2049c72b694ff62baf4314cbb (patch) | |
tree | 30a4648745c87468d435c30edf9dbe851a7830ae /crates/hir_ty/src/lib.rs | |
parent | 738174671ae40092684d7a9a543f939e318051e5 (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.rs | 29 |
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 | ||
102 | impl<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 | |||
111 | pub fn make_only_type_binders<T>(num_vars: usize, value: T) -> Binders<T> { | 102 | pub 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 | ||
122 | impl TraitRef { | 113 | impl 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 | ||
132 | impl 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 | |||
148 | impl<T> Canonical<T> { | 119 | impl<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| { |