// except according to those terms.
use middle::free_region::FreeRegionMap;
-use middle::infer;
+use middle::infer::{self, TypeOrigin};
use middle::traits;
use middle::ty::{self};
use middle::subst::{self, Subst, Substs, VecPerParamSpace};
use syntax::ast;
use syntax::codemap::Span;
-use syntax::parse::token;
use super::assoc;
span_err!(tcx.sess, impl_m_span, E0049,
"method `{}` has {} type parameter{} \
but its trait declaration has {} type parameter{}",
- token::get_name(trait_m.name),
+ trait_m.name,
num_impl_m_type_params,
if num_impl_m_type_params == 1 {""} else {"s"},
num_trait_m_type_params,
span_err!(tcx.sess, impl_m_span, E0050,
"method `{}` has {} parameter{} \
but the declaration in trait `{}` has {}",
- token::get_name(trait_m.name),
+ trait_m.name,
impl_m.fty.sig.0.inputs.len(),
if impl_m.fty.sig.0.inputs.len() == 1 {""} else {"s"},
tcx.item_path_str(trait_m.def_id),
// Create a parameter environment that represents the implementation's
// method.
- let impl_param_env =
- ty::ParameterEnvironment::for_item(tcx, impl_m.def_id.node);
+ let impl_m_node_id = tcx.map.as_local_node_id(impl_m.def_id).unwrap();
+ let impl_param_env = ty::ParameterEnvironment::for_item(tcx, impl_m_node_id);
// Create mapping from impl to skolemized.
let impl_to_skol_substs = &impl_param_env.free_substs;
let trait_fty = trait_fty.subst(tcx, &trait_to_skol_substs);
let err = infcx.commit_if_ok(|snapshot| {
- let origin = infer::MethodCompatCheck(impl_m_span);
+ let origin = TypeOrigin::MethodCompatCheck(impl_m_span);
let (impl_sig, _) =
infcx.replace_late_bound_regions_with_fresh_var(impl_m_span,
trait_fty);
span_err!(tcx.sess, impl_m_span, E0053,
"method `{}` has an incompatible type for trait: {}",
- token::get_name(trait_m.name),
+ trait_m.name,
terr);
return;
}
span_err!(tcx.sess, span, E0195,
"lifetime parameters or bounds on method `{}` do \
not match the trait declaration",
- token::get_name(impl_m.name));
+ impl_m.name);
return false;
}
// Create a parameter environment that represents the implementation's
// method.
- let impl_param_env =
- ty::ParameterEnvironment::for_item(tcx, impl_c.def_id.node);
+ let impl_c_node_id = tcx.map.as_local_node_id(impl_c.def_id).unwrap();
+ let impl_param_env = ty::ParameterEnvironment::for_item(tcx, impl_c_node_id);
// Create mapping from impl to skolemized.
let impl_to_skol_substs = &impl_param_env.free_substs;
let trait_ty = trait_c.ty.subst(tcx, &trait_to_skol_substs);
let err = infcx.commit_if_ok(|_| {
- let origin = infer::Misc(impl_c_span);
+ let origin = TypeOrigin::Misc(impl_c_span);
// There is no "body" here, so just pass dummy id.
let impl_ty =
span_err!(tcx.sess, impl_c_span, E0326,
"implemented const `{}` has an incompatible type for \
trait: {}",
- token::get_name(trait_c.name),
+ trait_c.name,
terr);
return;
}