about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc_typeck/collect.rs6
-rw-r--r--src/librustc_typeck/diagnostics.rs18
-rw-r--r--src/test/compile-fail/impl-duplicate-methods.rs2
-rw-r--r--src/test/compile-fail/issue-4265.rs2
4 files changed, 21 insertions, 7 deletions
diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs
index 4ef17105923..be2774f46d9 100644
--- a/src/librustc_typeck/collect.rs
+++ b/src/librustc_typeck/collect.rs
@@ -752,7 +752,11 @@ fn convert_methods<'a,'tcx,'i,I>(ccx: &CrateCtxt<'a, 'tcx>,
     let mut seen_methods = FnvHashSet();
     for (sig, id, ident, vis, span) in methods {
         if !seen_methods.insert(ident.name) {
-            span_err!(tcx.sess, span, E0201, "duplicate method");
+            let fn_desc = match sig.explicit_self.node {
+                ast::SelfStatic => "associated function",
+                _               => "method",
+            };
+            span_err!(tcx.sess, span, E0201, "duplicate {}", fn_desc);
         }
 
         convert_method(ccx,
diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs
index 8f01f5787f4..10bae6f63d0 100644
--- a/src/librustc_typeck/diagnostics.rs
+++ b/src/librustc_typeck/diagnostics.rs
@@ -921,19 +921,29 @@ unsafe impl Bar for Foo { }
 "##,
 
 E0201: r##"
-It is an error to define a method--a trait method or an inherent method--more
-than once.
+It is an error to define an associated function more than once.
 
-For example,
+For example:
 
 ```
 struct Foo(u8);
 
 impl Foo {
+    fn bar(&self) -> bool { self.0 > 5 }
+
+    // error: duplicate associated function
     fn bar() {}
+}
+
+trait Baz {
+    fn baz(&self) -> bool;
+}
+
+impl Baz for Foo {
+    fn baz(&self) -> bool { true }
 
     // error: duplicate method
-    fn bar(&self) -> bool { self.0 > 5 }
+    fn baz(&self) -> bool { self.0 > 5 }
 }
 ```
 "##,
diff --git a/src/test/compile-fail/impl-duplicate-methods.rs b/src/test/compile-fail/impl-duplicate-methods.rs
index 3b4def8c508..6201d9862bb 100644
--- a/src/test/compile-fail/impl-duplicate-methods.rs
+++ b/src/test/compile-fail/impl-duplicate-methods.rs
@@ -11,7 +11,7 @@
 struct Foo;
 impl Foo {
     fn orange(&self){}
-    fn orange(&self){}   //~ ERROR error: duplicate method
+    fn orange(&self){}   //~ ERROR duplicate method
 }
 
 fn main() {}
diff --git a/src/test/compile-fail/issue-4265.rs b/src/test/compile-fail/issue-4265.rs
index 553436607d1..328de9f8187 100644
--- a/src/test/compile-fail/issue-4265.rs
+++ b/src/test/compile-fail/issue-4265.rs
@@ -17,7 +17,7 @@ impl Foo {
         Foo { baz: 0 }.bar();
     }
 
-    fn bar() { //~ ERROR duplicate method
+    fn bar() { //~ ERROR duplicate associated function
     }
 }