aboutsummaryrefslogtreecommitdiff
path: root/crates/hir/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir/src/lib.rs')
-rw-r--r--crates/hir/src/lib.rs26
1 files changed, 18 insertions, 8 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index 86b36c565..13aaa408a 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -1972,9 +1972,9 @@ impl Type {
1972 pub fn type_parameters(&self) -> impl Iterator<Item = Type> + '_ { 1972 pub fn type_parameters(&self) -> impl Iterator<Item = Type> + '_ {
1973 self.ty 1973 self.ty
1974 .strip_references() 1974 .strip_references()
1975 .substs() 1975 .as_adt()
1976 .into_iter() 1976 .into_iter()
1977 .flat_map(|substs| substs.iter(&Interner)) 1977 .flat_map(|(_, substs)| substs.iter(&Interner))
1978 .filter_map(|arg| arg.ty(&Interner).cloned()) 1978 .filter_map(|arg| arg.ty(&Interner).cloned())
1979 .map(move |ty| self.derived(ty)) 1979 .map(move |ty| self.derived(ty))
1980 } 1980 }
@@ -2115,18 +2115,22 @@ impl Type {
2115 fn walk_type(db: &dyn HirDatabase, type_: &Type, cb: &mut impl FnMut(Type)) { 2115 fn walk_type(db: &dyn HirDatabase, type_: &Type, cb: &mut impl FnMut(Type)) {
2116 let ty = type_.ty.strip_references(); 2116 let ty = type_.ty.strip_references();
2117 match ty.kind(&Interner) { 2117 match ty.kind(&Interner) {
2118 TyKind::Adt(..) => { 2118 TyKind::Adt(_, substs) => {
2119 cb(type_.derived(ty.clone())); 2119 cb(type_.derived(ty.clone()));
2120 walk_substs(db, type_, &substs, cb);
2120 } 2121 }
2121 TyKind::AssociatedType(..) => { 2122 TyKind::AssociatedType(_, substs) => {
2122 if let Some(_) = ty.associated_type_parent_trait(db) { 2123 if let Some(_) = ty.associated_type_parent_trait(db) {
2123 cb(type_.derived(ty.clone())); 2124 cb(type_.derived(ty.clone()));
2124 } 2125 }
2126 walk_substs(db, type_, &substs, cb);
2125 } 2127 }
2126 TyKind::OpaqueType(..) => { 2128 TyKind::OpaqueType(_, subst) => {
2127 if let Some(bounds) = ty.impl_trait_bounds(db) { 2129 if let Some(bounds) = ty.impl_trait_bounds(db) {
2128 walk_bounds(db, &type_.derived(ty.clone()), &bounds, cb); 2130 walk_bounds(db, &type_.derived(ty.clone()), &bounds, cb);
2129 } 2131 }
2132
2133 walk_substs(db, type_, subst, cb);
2130 } 2134 }
2131 TyKind::Alias(AliasTy::Opaque(opaque_ty)) => { 2135 TyKind::Alias(AliasTy::Opaque(opaque_ty)) => {
2132 if let Some(bounds) = ty.impl_trait_bounds(db) { 2136 if let Some(bounds) = ty.impl_trait_bounds(db) {
@@ -2156,11 +2160,17 @@ impl Type {
2156 walk_type(db, &type_.derived(ty.clone()), cb); 2160 walk_type(db, &type_.derived(ty.clone()), cb);
2157 } 2161 }
2158 2162
2163 TyKind::FnDef(_, substs)
2164 | TyKind::Tuple(_, substs)
2165 | TyKind::Closure(.., substs) => {
2166 walk_substs(db, type_, &substs, cb);
2167 }
2168 TyKind::Function(hir_ty::FnPointer { substitution, .. }) => {
2169 walk_substs(db, type_, &substitution.0, cb);
2170 }
2171
2159 _ => {} 2172 _ => {}
2160 } 2173 }
2161 if let Some(substs) = ty.substs() {
2162 walk_substs(db, type_, &substs, cb);
2163 }
2164 } 2174 }
2165 2175
2166 walk_type(db, self, &mut cb); 2176 walk_type(db, self, &mut cb);