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
Unintuitive behaviour and missing ambiguous function call error when a trait is implemented dependent on another trait and both traits define a function of the same name #127703
warning: associated function`one` is never used
--> src/main.rs:6:8
|
5 | trait B {
| - associated functionin this trait
6 | fn one();
| ^^^
|
= note: `#[warn(dead_code)]` on by default
warning: 1 warning emitted
Output when run:
B::two
A::one
Desired output
I expected the call to Self::one in B::two to either call B::one, or generate an ambiguous function call error.
Rationale and extra context
The code compiles, and it looks like B::one will be called from B::two, but A::one is called instead. The only warning is that B::one is unused, which it wouldn't be if it was used by other code. This is confusing and unintuitive.
Other cases
The same thing happens if the functions take a self parameter and are called via self.