Skip to content

Commit dff4f52

Browse files
committed
auto merge of #10509 : cmr/rust/trait_name, r=alexcrichton
Rebase + fix of #10118
2 parents 66df86a + ab9e3a6 commit dff4f52

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/librustc/middle/typeck/check/mod.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -863,11 +863,13 @@ pub fn compare_impl_method(tcx: ty::ctxt,
863863
if impl_m.fty.sig.inputs.len() != trait_m.fty.sig.inputs.len() {
864864
tcx.sess.span_err(
865865
impl_m_span,
866-
format!("method `{}` has {} parameter(s) \
867-
but the trait has {} parameter(s)",
868-
tcx.sess.str_of(trait_m.ident),
869-
impl_m.fty.sig.inputs.len(),
870-
trait_m.fty.sig.inputs.len()));
866+
format!("method `{}` has {} parameter{} \
867+
but the declaration in trait `{}` has {}",
868+
tcx.sess.str_of(trait_m.ident),
869+
impl_m.fty.sig.inputs.len(),
870+
if impl_m.fty.sig.inputs.len() == 1 { "" } else { "s" },
871+
ty::item_path_str(tcx, trait_m.def_id),
872+
trait_m.fty.sig.inputs.len()));
871873
return;
872874
}
873875

src/test/compile-fail/trait-impl-different-num-params.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ trait foo {
1313
}
1414
impl foo for int {
1515
fn bar(&self) -> int {
16-
//~^ ERROR method `bar` has 0 parameter(s) but the trait has 1
16+
//~^ ERROR method `bar` has 0 parameters but the declaration in trait `foo::bar` has 1
1717
*self
1818
}
1919
}

0 commit comments

Comments
 (0)