Complete trait assoc items

This commit is contained in:
Florian Diebold 2019-10-31 21:21:48 +01:00
parent 5da941897d
commit 79cb0a0dab
5 changed files with 56 additions and 17 deletions

View file

@ -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,
},
};

View file

@ -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<T>,
) -> Option<T> {
// 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,
)
}

View file

@ -176,7 +176,7 @@ pub(crate) fn lookup_method(
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub(crate) enum LookupMode {
pub enum LookupMode {
MethodCall,
Path,
}