]> git.lizzy.rs Git - rust.git/commitdiff
Add E0034 error explanation
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Fri, 19 Jun 2015 11:59:51 +0000 (13:59 +0200)
committerGuillaume Gomez <guillaume1.gomez@gmail.com>
Fri, 19 Jun 2015 11:59:51 +0000 (13:59 +0200)
src/librustc_typeck/diagnostics.rs

index f338a774e90e57ec842ea6ecbdf622e940b9746e..431880c2076bb693144a71bab9cb6e3074a32603 100644 (file)
@@ -211,6 +211,47 @@ struct Dog {
 http://doc.rust-lang.org/reference.html#trait-objects
 "##,
 
+E0034: r##"
+The compiler doesn't know what method to call because more than one does
+have the same prototype. Example:
+
+```
+struct Test;
+
+trait Trait1 {
+    fn foo();
+}
+
+trait Trait2 {
+    fn foo();
+}
+
+impl Trait1 for Test { fn foo() {} }
+impl Trait2 for Test { fn foo() {} }
+
+fn main() {
+    Test::foo() // error, what foo() to call?
+}
+```
+
+To avoid this error, you have to keep only one of them and remove the others.
+So let's take our example and fix it:
+
+```
+struct Test;
+
+trait Trait1 {
+    fn foo();
+}
+
+impl Trait1 for Test { fn foo() {} }
+
+fn main() {
+    Test::foo() // and now that's good!
+}
+```
+"##,
+
 E0035: r##"
 You tried to give a type parameter where it wasn't needed. Bad example: