use crate::check::autoderef::{self, Autoderef};
use crate::check::FnCtxt;
use crate::hir::def_id::DefId;
-use crate::hir::def::Def;
+use crate::hir::def::DefKind;
use crate::namespace::Namespace;
use rustc_data_structures::sync::Lrc;
use rustc::ty::{self, ParamEnvAnd, Ty, TyCtxt, ToPolyTraitRef, ToPredicate, TraitRef, TypeFoldable};
use rustc::ty::GenericParamDefKind;
use rustc::infer::type_variable::TypeVariableOrigin;
+use rustc::infer::unify_key::ConstVariableOrigin;
use rustc::util::nodemap::FxHashSet;
use rustc::infer::{self, InferOk};
use rustc::infer::canonical::{Canonical, QueryResponse};
allow_similar_names: bool,
/// Some(candidate) if there is a private candidate
- private_candidate: Option<Def>,
+ private_candidate: Option<(DefKind, DefId)>,
/// Collects near misses when trait bounds for type parameters are unsatisfied and is only used
/// for error reporting
self.extension_candidates.push(candidate);
}
} else if self.private_candidate.is_none() {
- self.private_candidate = Some(candidate.item.def());
+ self.private_candidate =
+ Some((candidate.item.def_kind(), candidate.item.def_id));
}
}
method: &ty::AssociatedItem,
self_ty: Option<Ty<'tcx>>,
expected: Ty<'tcx>) -> bool {
- match method.def() {
- Def::Method(def_id) => {
- let fty = self.tcx.fn_sig(def_id);
+ match method.kind {
+ ty::AssociatedKind::Method => {
+ let fty = self.tcx.fn_sig(method.def_id);
self.probe(|_| {
let substs = self.fresh_substs_for_item(self.span, method.def_id);
let fty = fty.subst(self.tcx, substs);
_ => vec![],
};
- if let Some(def) = private_candidate {
- return Err(MethodError::PrivateMatch(def, out_of_scope_traits));
+ if let Some((kind, def_id)) = private_candidate {
+ return Err(MethodError::PrivateMatch(kind, def_id, out_of_scope_traits));
}
let lev_candidate = self.probe_for_lev_candidate()?;
self.tcx.def_span(def_id))).into()
}
GenericParamDefKind::Const { .. } => {
- unimplemented!() // FIXME(const_generics)
+ let span = self.tcx.def_span(def_id);
+ let origin = ConstVariableOrigin::SubstitutionPlaceholder(span);
+ self.next_const_var(self.tcx.type_of(param.def_id), origin).into()
}
}
})