diff options
Diffstat (limited to 'crates/ra_hir/src/source_binder.rs')
-rw-r--r-- | crates/ra_hir/src/source_binder.rs | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index 0008cb232..a4ca59bba 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs | |||
@@ -27,9 +27,9 @@ use crate::{ | |||
27 | }, | 27 | }, |
28 | ids::LocationCtx, | 28 | ids::LocationCtx, |
29 | resolve::{ScopeDef, TypeNs, ValueNs}, | 29 | resolve::{ScopeDef, TypeNs, ValueNs}, |
30 | ty::method_resolution::implements_trait, | 30 | ty::method_resolution::{self, implements_trait}, |
31 | Const, DefWithBody, Either, Enum, FromSource, Function, HasBody, HirFileId, MacroDef, Module, | 31 | AssocItem, Const, DefWithBody, Either, Enum, FromSource, Function, HasBody, HirFileId, |
32 | Name, Path, Resolver, Static, Struct, Ty, | 32 | MacroDef, Module, Name, Path, Resolver, Static, Struct, Ty, |
33 | }; | 33 | }; |
34 | 34 | ||
35 | fn try_get_resolver_for_node( | 35 | fn try_get_resolver_for_node( |
@@ -327,16 +327,42 @@ impl SourceAnalyzer { | |||
327 | db: &impl HirDatabase, | 327 | db: &impl HirDatabase, |
328 | ty: Ty, | 328 | ty: Ty, |
329 | name: Option<&Name>, | 329 | name: Option<&Name>, |
330 | callback: impl FnMut(&Ty, Function) -> Option<T>, | 330 | mut callback: impl FnMut(&Ty, Function) -> Option<T>, |
331 | ) -> Option<T> { | 331 | ) -> Option<T> { |
332 | // There should be no inference vars in types passed here | 332 | // There should be no inference vars in types passed here |
333 | // FIXME check that? | 333 | // FIXME check that? |
334 | // FIXME replace Unknown by bound vars here | ||
334 | let canonical = crate::ty::Canonical { value: ty, num_vars: 0 }; | 335 | let canonical = crate::ty::Canonical { value: ty, num_vars: 0 }; |
335 | crate::ty::method_resolution::iterate_method_candidates( | 336 | method_resolution::iterate_method_candidates( |
336 | &canonical, | 337 | &canonical, |
337 | db, | 338 | db, |
338 | &self.resolver, | 339 | &self.resolver, |
339 | name, | 340 | name, |
341 | method_resolution::LookupMode::MethodCall, | ||
342 | |ty, it| match it { | ||
343 | AssocItem::Function(f) => callback(ty, f), | ||
344 | _ => None, | ||
345 | }, | ||
346 | ) | ||
347 | } | ||
348 | |||
349 | pub fn iterate_path_candidates<T>( | ||
350 | &self, | ||
351 | db: &impl HirDatabase, | ||
352 | ty: Ty, | ||
353 | name: Option<&Name>, | ||
354 | callback: impl FnMut(&Ty, AssocItem) -> Option<T>, | ||
355 | ) -> Option<T> { | ||
356 | // There should be no inference vars in types passed here | ||
357 | // FIXME check that? | ||
358 | // FIXME replace Unknown by bound vars here | ||
359 | let canonical = crate::ty::Canonical { value: ty, num_vars: 0 }; | ||
360 | method_resolution::iterate_method_candidates( | ||
361 | &canonical, | ||
362 | db, | ||
363 | &self.resolver, | ||
364 | name, | ||
365 | method_resolution::LookupMode::Path, | ||
340 | callback, | 366 | callback, |
341 | ) | 367 | ) |
342 | } | 368 | } |