From 92dcc53f94455e8933d76a8ba20642ceb069362d Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Wed, 7 Apr 2021 17:26:01 +0200 Subject: 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. --- crates/hir_ty/src/walk.rs | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'crates/hir_ty/src/walk.rs') 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 { TyKind::Function(fn_pointer) => { fn_pointer.substitution.0.walk(f); } - _ => { - if let Some(substs) = self.substs() { - for t in substs.iter(&Interner) { - t.walk(f); - } - } + TyKind::Adt(_, substs) + | TyKind::FnDef(_, substs) + | TyKind::Tuple(_, substs) + | TyKind::OpaqueType(_, substs) + | TyKind::AssociatedType(_, substs) + | TyKind::Closure(.., substs) => { + substs.walk(f); } + _ => {} } f(self); } @@ -199,11 +201,15 @@ impl TypeWalk for Ty { TyKind::Function(fn_pointer) => { fn_pointer.substitution.0.walk_mut_binders(f, binders.shifted_in()); } - _ => { - if let Some(substs) = self.substs_mut() { - substs.walk_mut_binders(f, binders); - } + TyKind::Adt(_, substs) + | TyKind::FnDef(_, substs) + | TyKind::Tuple(_, substs) + | TyKind::OpaqueType(_, substs) + | TyKind::AssociatedType(_, substs) + | TyKind::Closure(.., substs) => { + substs.walk_mut_binders(f, binders); } + _ => {} } f(self, binders); } -- cgit v1.2.3