Closed
Description
STR
trait FooChar {
fn foo(&self, char) {}
}
trait FooInt {
fn foo(&self, int) {}
}
impl FooChar for char {}
impl FooInt for char {}
trait Bar<T> {
fn bar(&self, T) {}
}
impl Bar<char> for char {}
impl Bar<int> for char {}
fn main() {
'a'.foo('b'); //~ error: multiple applicable methods in scope
'a'.bar('b'); // OK
}
Output
conflict.rs:20:9: 20:17 error: multiple applicable methods in scope [E0034]
conflict.rs:20 'a'.foo('b'); //~ error: multiple applicable methods in scope
^~~~~~~~
conflict.rs:2:5: 2:24 note: candidate #1 is defined in the trait `FooChar`
conflict.rs:2 fn foo(&self, char) {}
^~~~~~~~~~~~~~~~~~~
conflict.rs:6:5: 6:23 note: candidate #2 is defined in the trait `FooInt`
conflict.rs:6 fn foo(&self, int) {}
^~~~~~~~~~~~~~~~~~
error: aborting due to previous error
Version
rustc 0.13.0-dev (98958bcaf 2014-11-05 10:21:38 +0000)
I'm under the impression that 'a'.foo('b')
should just work, although there are two traits that provide the foo
method, it's clear from the signature of the method call that FooChar
should be used. After all, it's possible to do something similar using multidispatch (the Bar
trait)
Metadata
Metadata
Assignees
Labels
No labels