You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
structA;implA{fnget(&self) -> u8{42}}implA{fnget(&self) -> u8{24}}fnmain(){let a = A;
a.get();}
I would expect to get
error: duplicate method
but instead I get
error: multiple applicable items in scope
As far as I am aware, there's no way to actually pick one of the multiple methods, is there?
This seems to be highly related to #22889, but the same behavior occurs with the nightly on the playground, even when using static methods instead of instance methods.
The text was updated successfully, but these errors were encountered:
If you remove the use (line with a.get()) you see this new warning for this in nightly:
dup.rs:4:5:4:31 warning: duplicate definitions with name `get`,#[warn(overlapping_inherent_impls)] on by default
dup.rs:4fnget(&self) -> u8{42}
^~~~~~~~~~~~~~~~~~~~~~~~~~
dup.rs:4:5:4:31 warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
dup.rs:4:5:4:31note:for more information, see issue #22889 <https://github.com/rust-lang/rust/issues/22889>
dup.rs:4:5:4:31 warning: method is never used: `get`,#[warn(dead_code)] on by default
dup.rs:4fnget(&self) -> u8{42}
So it used to be allowed but is now a warning and will be an error in the future. Methods with the same name but with some kind of type difference in the implementing type will still be allowed. I think this issue is fixed in nightly for this reason.
Given this code:
I would expect to get
but instead I get
As far as I am aware, there's no way to actually pick one of the multiple methods, is there?
This seems to be highly related to #22889, but the same behavior occurs with the nightly on the playground, even when using static methods instead of instance methods.
The text was updated successfully, but these errors were encountered: