// Add the names of all the items to the trait info.
for item in items {
let item_def_id = self.ast_map.local_def_id(item.id);
+ let mut is_static_method = false;
let (def, ns) = match item.node {
hir::ConstTraitItem(..) => (Def::AssociatedConst(item_def_id), ValueNS),
- hir::MethodTraitItem(..) => (Def::Method(item_def_id), ValueNS),
+ hir::MethodTraitItem(ref sig, _) => {
+ is_static_method = sig.explicit_self.node == hir::SelfStatic;
+ (Def::Method(item_def_id), ValueNS)
+ }
hir::TypeTraitItem(..) => (Def::AssociatedTy(def_id, item_def_id), TypeNS),
};
self.define(module_parent, item.name, ns, (def, item.span, vis));
- self.trait_item_map.insert((item.name, def_id), item_def_id);
+ self.trait_item_map.insert((item.name, def_id), is_static_method);
}
}
}
'{}'",
trait_item_name);
- self.trait_item_map.insert((trait_item_name, def_id), trait_item_def.def_id());
+ self.trait_item_map.insert((trait_item_name, def_id), false);
}
let parent_link = ModuleParentLink(parent, name);
graph_root: Module<'a>,
- trait_item_map: FnvHashMap<(Name, DefId), DefId>,
+ trait_item_map: FnvHashMap<(Name, DefId), bool /* is static method? */>,
structs: FnvHashMap<DefId, Vec<Name>>,
}
}
- fn is_static_method(this: &Resolver, did: DefId) -> bool {
- if let Some(node_id) = this.ast_map.as_local_node_id(did) {
- let sig = match this.ast_map.get(node_id) {
- hir_map::NodeTraitItem(trait_item) => match trait_item.node {
- hir::MethodTraitItem(ref sig, _) => sig,
- _ => return false,
- },
- hir_map::NodeImplItem(impl_item) => match impl_item.node {
- hir::ImplItemKind::Method(ref sig, _) => sig,
- _ => return false,
- },
- _ => return false,
- };
- sig.explicit_self.node == hir::SelfStatic
- } else {
- this.session.cstore.is_static_method(did)
- }
- }
-
if let Some(node_id) = self.current_self_type.as_ref().and_then(extract_node_id) {
// Look for a field with the same name in the current self_type.
match self.def_map.borrow().get(&node_id).map(|d| d.full_def()) {
// Look for a method in the current trait.
if let Some((trait_did, ref trait_ref)) = self.current_trait_ref {
- if let Some(&did) = self.trait_item_map.get(&(name, trait_did)) {
- if is_static_method(self, did) {
+ if let Some(&is_static_method) = self.trait_item_map.get(&(name, trait_did)) {
+ if is_static_method {
return TraitMethod(path_names_to_string(&trait_ref.path, 0));
} else {
return TraitItem;