Skip to content

Commit 11543f1

Browse files
Add E0034 error explanation
1 parent 7a13b93 commit 11543f1

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

src/librustc_typeck/diagnostics.rs

+41-1
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,47 @@ Reference:
211211
http://doc.rust-lang.org/reference.html#trait-objects
212212
"##,
213213

214+
E0034: r##"
215+
The compiler doesn't know what method to call because more than one does
216+
have the same prototype. Example:
217+
218+
```
219+
struct Test;
220+
221+
trait Trait1 {
222+
fn foo();
223+
}
224+
225+
trait Trait2 {
226+
fn foo();
227+
}
228+
229+
impl Trait1 for Test { fn foo() {} }
230+
impl Trait2 for Test { fn foo() {} }
231+
232+
fn main() {
233+
Test::foo() // error, what foo() to call?
234+
}
235+
```
236+
237+
To avoid this error, you have to keep only one of them and remove the others.
238+
So let's take our example and fix it:
239+
240+
```
241+
struct Test;
242+
243+
trait Trait1 {
244+
fn foo();
245+
}
246+
247+
impl Trait1 for Test { fn foo() {} }
248+
249+
fn main() {
250+
Test::foo() // and now that's good!
251+
}
252+
```
253+
"##,
254+
214255
E0040: r##"
215256
It is not allowed to manually call destructors in Rust. It is also not
216257
necessary to do this since `drop` is called automatically whenever a value goes
@@ -1320,7 +1361,6 @@ For more information see the [opt-in builtin traits RFC](https://github.com/rust
13201361
}
13211362

13221363
register_diagnostics! {
1323-
E0034, // multiple applicable methods in scope
13241364
E0035, // does not take type parameters
13251365
E0036, // incorrect number of type parameters given for this method
13261366
E0044, // foreign items may not have type parameters

0 commit comments

Comments
 (0)