From faf2dd49e4845e1437b704a28bb5603be5fd605b Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Sun, 28 Feb 2021 19:46:59 +0100 Subject: Fix code_model::Type::walk not walking all types --- crates/hir/src/code_model.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'crates/hir') diff --git a/crates/hir/src/code_model.rs b/crates/hir/src/code_model.rs index 8e77a4a41..cdb54eca2 100644 --- a/crates/hir/src/code_model.rs +++ b/crates/hir/src/code_model.rs @@ -1924,21 +1924,18 @@ impl Type { fn walk_type(db: &dyn HirDatabase, type_: &Type, cb: &mut impl FnMut(Type)) { let ty = type_.ty.value.strip_references(); match ty { - Ty::Adt(_, parameters) => { + Ty::Adt(..) => { cb(type_.derived(ty.clone())); - walk_substs(db, type_, parameters, cb); } - Ty::AssociatedType(_, parameters) => { + Ty::AssociatedType(..) => { if let Some(_) = ty.associated_type_parent_trait(db) { cb(type_.derived(ty.clone())); } - walk_substs(db, type_, parameters, cb); } - Ty::OpaqueType(_, parameters) => { + Ty::OpaqueType(..) => { if let Some(bounds) = ty.impl_trait_bounds(db) { walk_bounds(db, &type_.derived(ty.clone()), &bounds, cb); } - walk_substs(db, type_, parameters, cb); } Ty::Opaque(opaque_ty) => { if let Some(bounds) = ty.impl_trait_bounds(db) { @@ -1956,7 +1953,10 @@ impl Type { walk_bounds(db, &type_.derived(ty.clone()), bounds.as_ref(), cb); } - _ => (), + _ => {} + } + if let Some(substs) = ty.substs() { + walk_substs(db, type_, &substs, cb); } } -- cgit v1.2.3