Show the name of the trait in the error message

This commit is contained in:
Jaemin Moon 2013-10-28 17:18:11 +09:00 committed by Corey Richardson
parent 90754ae9c9
commit 51bdec18b0
2 changed files with 8 additions and 6 deletions

View File

@ -863,11 +863,13 @@ pub fn compare_impl_method(tcx: ty::ctxt,
if impl_m.fty.sig.inputs.len() != trait_m.fty.sig.inputs.len() {
tcx.sess.span_err(
impl_m_span,
format!("method `{}` has {} parameter(s) \
but the trait has {} parameter(s)",
tcx.sess.str_of(trait_m.ident),
impl_m.fty.sig.inputs.len(),
trait_m.fty.sig.inputs.len()));
format!("method `{}` has {} parameter{} \
but the trait method `{}` has {}",
tcx.sess.str_of(trait_m.ident),
impl_m.fty.sig.inputs.len(),
if impl_m.fty.sig.inputs.len() == 1 { "" } else { "s" },
ty::item_path_str(tcx, trait_m.def_id),
trait_m.fty.sig.inputs.len()));
return;
}

View File

@ -13,7 +13,7 @@ trait foo {
}
impl foo for int {
fn bar(&self) -> int {
//~^ ERROR method `bar` has 0 parameter(s) but the trait has 1
//~^ ERROR method `bar` has 0 parameters but the trait method `foo::bar` has 1
*self
}
}