diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2015-06-19 13:59:51 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2015-06-19 13:59:51 +0200 |
| commit | d4c37088ca873a23e58d512d9418f59056477226 (patch) | |
| tree | df1a5654a97951b8ad11e8e191b33e57320127e6 | |
| parent | b4481e68deeffc9e6cf4648d10c51750adbb4c3b (diff) | |
| download | rust-d4c37088ca873a23e58d512d9418f59056477226.tar.gz rust-d4c37088ca873a23e58d512d9418f59056477226.zip | |
Add E0034 error explanation
| -rw-r--r-- | src/librustc_typeck/diagnostics.rs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index f338a774e90..431880c2076 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -211,6 +211,47 @@ Reference: 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: |
