From 79cb0a0dab5fd8e3e84cf4a3b927ec29d2b6e65c Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Thu, 31 Oct 2019 21:21:48 +0100 Subject: Complete trait assoc items --- crates/ra_hir/src/lib.rs | 3 ++- crates/ra_hir/src/source_binder.rs | 8 +++++--- crates/ra_hir/src/ty/method_resolution.rs | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) (limited to 'crates/ra_hir/src') diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs index 40f5562b4..4cace432e 100644 --- a/crates/ra_hir/src/lib.rs +++ b/crates/ra_hir/src/lib.rs @@ -76,7 +76,8 @@ pub use crate::{ resolve::ScopeDef, source_binder::{PathResolution, ScopeEntryWithSyntax, SourceAnalyzer}, ty::{ - display::HirDisplay, ApplicationTy, CallableDef, Substs, TraitRef, Ty, TypeCtor, TypeWalk, + display::HirDisplay, method_resolution::LookupMode, ApplicationTy, CallableDef, Substs, + TraitRef, Ty, TypeCtor, TypeWalk, }, }; diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index 0398806fd..82e6eb852 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs @@ -27,7 +27,7 @@ use crate::{ }, ids::LocationCtx, resolve::{ScopeDef, TypeNs, ValueNs}, - ty::method_resolution::implements_trait, + ty::method_resolution::{self, implements_trait}, AssocItem, Const, DefWithBody, Either, Enum, FromSource, Function, HasBody, HirFileId, MacroDef, Module, Name, Path, Resolver, Static, Struct, Ty, }; @@ -327,17 +327,19 @@ impl SourceAnalyzer { db: &impl HirDatabase, ty: Ty, name: Option<&Name>, + mode: method_resolution::LookupMode, callback: impl FnMut(&Ty, AssocItem) -> Option, ) -> Option { // There should be no inference vars in types passed here // FIXME check that? + // FIXME replace Unknown by bound vars here let canonical = crate::ty::Canonical { value: ty, num_vars: 0 }; - crate::ty::method_resolution::iterate_method_candidates( + method_resolution::iterate_method_candidates( &canonical, db, &self.resolver, name, - crate::ty::method_resolution::LookupMode::MethodCall, + mode, callback, ) } diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs index 43b485ec0..9caff422f 100644 --- a/crates/ra_hir/src/ty/method_resolution.rs +++ b/crates/ra_hir/src/ty/method_resolution.rs @@ -176,7 +176,7 @@ pub(crate) fn lookup_method( } #[derive(Copy, Clone, Debug, PartialEq, Eq)] -pub(crate) enum LookupMode { +pub enum LookupMode { MethodCall, Path, } -- cgit v1.2.3