use hir::def::Def;
use hir::def_id::{CRATE_DEF_INDEX, DefId};
use middle::lang_items::FnOnceTraitLangItem;
+use namespace::Namespace;
use rustc::traits::{Obligation, SelectionContext};
use util::nodemap::FxHashSet;
CandidateSource::ImplSource(impl_did) => {
// Provide the best span we can. Use the item, if local to crate, else
// the impl, if local to crate (item may be defaulted), else nothing.
- let item = self.associated_item(impl_did, item_name)
+ let item = self.associated_item(impl_did, item_name, Namespace::Value)
.or_else(|| {
self.associated_item(
self.tcx.impl_trait_ref(impl_did).unwrap().def_id,
-
- item_name
+ item_name,
+ Namespace::Value,
)
}).unwrap();
let note_span = self.tcx.hir.span_if_local(item.def_id).or_else(|| {
}
}
CandidateSource::TraitSource(trait_did) => {
- let item = self.associated_item(trait_did, item_name).unwrap();
+ let item = self
+ .associated_item(trait_did, item_name, Namespace::Value)
+ .unwrap();
let item_span = self.tcx.def_span(item.def_id);
span_note!(err,
item_span,
// implementing a trait would be legal but is rejected
// here).
(type_is_local || info.def_id.is_local())
- && self.associated_item(info.def_id, item_name).is_some()
+ && self.associated_item(info.def_id, item_name, Namespace::Value).is_some()
})
.collect::<Vec<_>>();
fn is_local(ty: Ty) -> bool {
match ty.sty {
ty::TyAdt(def, _) => def.did.is_local(),
+ ty::TyForeign(did) => did.is_local(),
ty::TyDynamic(ref tr, ..) => tr.principal()
.map_or(false, |p| p.def_id().is_local()),