Closed
Description
When a trait alias to a trait with a method with the same name as a method on a struct is in scope, rustc is suddenly unable to disambiguate the trait method from the struct method.
#![feature(trait_alias)]
trait SomeTrait {
fn map(&self) {}
}
impl<T> SomeTrait for Option<T> {}
trait SomeAlias = SomeTrait; // comment this out and everything works
fn main() {
let x = Some(123);
Option::map(x, |z| z); // Error: multiple `map` found
let x = Some(123);
x.map(|z| z); // Fine, no error.
}
error[E0034]: multiple applicable items in scope
--> src/main.rs:13:5
|
13 | Option::map(x, |z| z); // Error: multiple `map` found
| ^^^^^^^^^^^ multiple `map` found
|
note: candidate #1 is defined in an impl of the trait `SomeTrait` for the type `std::option::Option<_>`
--> src/main.rs:4:5
|
4 | fn map(&self) {}
| ^^^^^^^^^^^^^
= note: candidate #2 is defined in an impl for the type `std::option::Option<_>`