Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/librustc/middle/typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 declaration in trait `{}` 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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/trait-impl-different-num-params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 declaration in trait `foo::bar` has 1
*self
}
}
Expand Down