diff options
Diffstat (limited to 'crates/hir')
-rw-r--r-- | crates/hir/src/lib.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index debc3ee62..0bb3767c1 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs | |||
@@ -191,6 +191,7 @@ impl Crate { | |||
191 | db: &dyn DefDatabase, | 191 | db: &dyn DefDatabase, |
192 | query: import_map::Query, | 192 | query: import_map::Query, |
193 | ) -> impl Iterator<Item = Either<ModuleDef, MacroDef>> { | 193 | ) -> impl Iterator<Item = Either<ModuleDef, MacroDef>> { |
194 | let _p = profile::span("query_external_importables"); | ||
194 | import_map::search_dependencies(db, self.into(), query).into_iter().map(|item| match item { | 195 | import_map::search_dependencies(db, self.into(), query).into_iter().map(|item| match item { |
195 | ItemInNs::Types(mod_id) | ItemInNs::Values(mod_id) => Either::Left(mod_id.into()), | 196 | ItemInNs::Types(mod_id) | ItemInNs::Values(mod_id) => Either::Left(mod_id.into()), |
196 | ItemInNs::Macros(mac_id) => Either::Right(mac_id.into()), | 197 | ItemInNs::Macros(mac_id) => Either::Right(mac_id.into()), |
@@ -1450,6 +1451,20 @@ impl AssocItem { | |||
1450 | _ => None, | 1451 | _ => None, |
1451 | } | 1452 | } |
1452 | } | 1453 | } |
1454 | |||
1455 | pub fn containing_trait_impl(self, db: &dyn HirDatabase) -> Option<Trait> { | ||
1456 | match self.container(db) { | ||
1457 | AssocItemContainer::Impl(i) => i.trait_(db), | ||
1458 | _ => None, | ||
1459 | } | ||
1460 | } | ||
1461 | |||
1462 | pub fn containing_trait_or_trait_impl(self, db: &dyn HirDatabase) -> Option<Trait> { | ||
1463 | match self.container(db) { | ||
1464 | AssocItemContainer::Trait(t) => Some(t), | ||
1465 | AssocItemContainer::Impl(i) => i.trait_(db), | ||
1466 | } | ||
1467 | } | ||
1453 | } | 1468 | } |
1454 | 1469 | ||
1455 | impl HasVisibility for AssocItem { | 1470 | impl HasVisibility for AssocItem { |
@@ -2185,6 +2200,7 @@ impl Type { | |||
2185 | name: Option<&Name>, | 2200 | name: Option<&Name>, |
2186 | mut callback: impl FnMut(&Ty, Function) -> Option<T>, | 2201 | mut callback: impl FnMut(&Ty, Function) -> Option<T>, |
2187 | ) -> Option<T> { | 2202 | ) -> Option<T> { |
2203 | let _p = profile::span("iterate_method_candidates"); | ||
2188 | // There should be no inference vars in types passed here | 2204 | // There should be no inference vars in types passed here |
2189 | // FIXME check that? | 2205 | // FIXME check that? |
2190 | // FIXME replace Unknown by bound vars here | 2206 | // FIXME replace Unknown by bound vars here |
@@ -2218,6 +2234,7 @@ impl Type { | |||
2218 | name: Option<&Name>, | 2234 | name: Option<&Name>, |
2219 | mut callback: impl FnMut(&Ty, AssocItem) -> Option<T>, | 2235 | mut callback: impl FnMut(&Ty, AssocItem) -> Option<T>, |
2220 | ) -> Option<T> { | 2236 | ) -> Option<T> { |
2237 | let _p = profile::span("iterate_path_candidates"); | ||
2221 | let canonical = hir_ty::replace_errors_with_variables(&self.ty); | 2238 | let canonical = hir_ty::replace_errors_with_variables(&self.ty); |
2222 | 2239 | ||
2223 | let env = self.env.clone(); | 2240 | let env = self.env.clone(); |
@@ -2255,6 +2272,7 @@ impl Type { | |||
2255 | &'a self, | 2272 | &'a self, |
2256 | db: &'a dyn HirDatabase, | 2273 | db: &'a dyn HirDatabase, |
2257 | ) -> impl Iterator<Item = Trait> + 'a { | 2274 | ) -> impl Iterator<Item = Trait> + 'a { |
2275 | let _p = profile::span("applicable_inherent_traits"); | ||
2258 | self.autoderef(db) | 2276 | self.autoderef(db) |
2259 | .filter_map(|derefed_type| derefed_type.ty.dyn_trait()) | 2277 | .filter_map(|derefed_type| derefed_type.ty.dyn_trait()) |
2260 | .flat_map(move |dyn_trait_id| hir_ty::all_super_traits(db.upcast(), dyn_trait_id)) | 2278 | .flat_map(move |dyn_trait_id| hir_ty::all_super_traits(db.upcast(), dyn_trait_id)) |