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
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Uh oh!
There was an error while loading. Please reload this page.
Code
Current output
Output when run:
Desired output
I expected the call to
Self::one
inB::two
to either callB::one
, or generate an ambiguous function call error.Rationale and extra context
The code compiles, and it looks like
B::one
will be called fromB::two
, butA::one
is called instead. The only warning is thatB::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.
Rust Version
Anything else?
Playground link
It happens on latest stable and nightly.
The text was updated successfully, but these errors were encountered: