aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/lib.rs
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2021-04-07 16:26:01 +0100
committerFlorian Diebold <[email protected]>2021-04-07 16:56:53 +0100
commit92dcc53f94455e8933d76a8ba20642ceb069362d (patch)
treea9f009f2a47f4292b35e0470cb0b1ade9e86de14 /crates/hir_ty/src/lib.rs
parent8e900cb4a1c5a4faef801518272d56a5683dd488 (diff)
Remove Ty::substs{_mut}
Almost all uses actually only care about ADT substs, so it's better to be explicit. The methods were a bad abstraction anyway since they already didn't include the inner types of e.g. `TyKind::Ref` anymore.
Diffstat (limited to 'crates/hir_ty/src/lib.rs')
-rw-r--r--crates/hir_ty/src/lib.rs28
1 files changed, 0 insertions, 28 deletions
diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs
index ae3987752..84645c435 100644
--- a/crates/hir_ty/src/lib.rs
+++ b/crates/hir_ty/src/lib.rs
@@ -198,34 +198,6 @@ impl Ty {
198 _ => false, 198 _ => false,
199 } 199 }
200 } 200 }
201
202 /// Returns the type parameters of this type if it has some (i.e. is an ADT
203 /// or function); so if `self` is `Option<u32>`, this returns the `u32`.
204 pub fn substs(&self) -> Option<&Substitution> {
205 match self.kind(&Interner) {
206 TyKind::Adt(_, substs)
207 | TyKind::FnDef(_, substs)
208 | TyKind::Tuple(_, substs)
209 | TyKind::OpaqueType(_, substs)
210 | TyKind::AssociatedType(_, substs)
211 | TyKind::Closure(.., substs) => Some(substs),
212 TyKind::Function(FnPointer { substitution: substs, .. }) => Some(&substs.0),
213 _ => None,
214 }
215 }
216
217 fn substs_mut(&mut self) -> Option<&mut Substitution> {
218 match self.interned_mut() {
219 TyKind::Adt(_, substs)
220 | TyKind::FnDef(_, substs)
221 | TyKind::Tuple(_, substs)
222 | TyKind::OpaqueType(_, substs)
223 | TyKind::AssociatedType(_, substs)
224 | TyKind::Closure(.., substs) => Some(substs),
225 TyKind::Function(FnPointer { substitution: substs, .. }) => Some(&mut substs.0),
226 _ => None,
227 }
228 }
229} 201}
230 202
231#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)] 203#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]