mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
Complete trait assoc items
This commit is contained in:
parent
5da941897d
commit
79cb0a0dab
5 changed files with 56 additions and 17 deletions
|
@ -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,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -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,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -176,7 +176,7 @@ pub(crate) fn lookup_method(
|
|||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub(crate) enum LookupMode {
|
||||
pub enum LookupMode {
|
||||
MethodCall,
|
||||
Path,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue