diff options
author | Florian Diebold <[email protected]> | 2021-04-07 16:26:01 +0100 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2021-04-07 16:56:53 +0100 |
commit | 92dcc53f94455e8933d76a8ba20642ceb069362d (patch) | |
tree | a9f009f2a47f4292b35e0470cb0b1ade9e86de14 /crates/hir_ty/src/walk.rs | |
parent | 8e900cb4a1c5a4faef801518272d56a5683dd488 (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/walk.rs')
-rw-r--r-- | crates/hir_ty/src/walk.rs | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/crates/hir_ty/src/walk.rs b/crates/hir_ty/src/walk.rs index 41ebf6137..91116dcda 100644 --- a/crates/hir_ty/src/walk.rs +++ b/crates/hir_ty/src/walk.rs | |||
@@ -162,13 +162,15 @@ impl TypeWalk for Ty { | |||
162 | TyKind::Function(fn_pointer) => { | 162 | TyKind::Function(fn_pointer) => { |
163 | fn_pointer.substitution.0.walk(f); | 163 | fn_pointer.substitution.0.walk(f); |
164 | } | 164 | } |
165 | _ => { | 165 | TyKind::Adt(_, substs) |
166 | if let Some(substs) = self.substs() { | 166 | | TyKind::FnDef(_, substs) |
167 | for t in substs.iter(&Interner) { | 167 | | TyKind::Tuple(_, substs) |
168 | t.walk(f); | 168 | | TyKind::OpaqueType(_, substs) |
169 | } | 169 | | TyKind::AssociatedType(_, substs) |
170 | } | 170 | | TyKind::Closure(.., substs) => { |
171 | substs.walk(f); | ||
171 | } | 172 | } |
173 | _ => {} | ||
172 | } | 174 | } |
173 | f(self); | 175 | f(self); |
174 | } | 176 | } |
@@ -199,11 +201,15 @@ impl TypeWalk for Ty { | |||
199 | TyKind::Function(fn_pointer) => { | 201 | TyKind::Function(fn_pointer) => { |
200 | fn_pointer.substitution.0.walk_mut_binders(f, binders.shifted_in()); | 202 | fn_pointer.substitution.0.walk_mut_binders(f, binders.shifted_in()); |
201 | } | 203 | } |
202 | _ => { | 204 | TyKind::Adt(_, substs) |
203 | if let Some(substs) = self.substs_mut() { | 205 | | TyKind::FnDef(_, substs) |
204 | substs.walk_mut_binders(f, binders); | 206 | | TyKind::Tuple(_, substs) |
205 | } | 207 | | TyKind::OpaqueType(_, substs) |
208 | | TyKind::AssociatedType(_, substs) | ||
209 | | TyKind::Closure(.., substs) => { | ||
210 | substs.walk_mut_binders(f, binders); | ||
206 | } | 211 | } |
212 | _ => {} | ||
207 | } | 213 | } |
208 | f(self, binders); | 214 | f(self, binders); |
209 | } | 215 | } |