What is this lint about
With variants being resolved as inherent associated items (rust-lang/rfcs#2338) code like this become ambiguous:
enum E {
V
}
trait Tr {
type V;
fn f() -> Self::V;
}
impl Tr for E {
type V = u8;
fn f() -> Self::V { 0 } // `Self::V` in type namespace may refer to both variant and associated type
}
This is not a problem right now, because variants cannot be used in type positions, but it may become a problem in the future if rust-lang/rfcs#2593 is accepted.
So this lints warns against cases like this and recommends to rewrite them as <Self as Tr>::V.
How to fix this warning/error
Explicitly disambiguate in favor of associated types from traits: <Type as Trait>::Ambiguous.
Current status
What is this lint about
With variants being resolved as inherent associated items (rust-lang/rfcs#2338) code like this become ambiguous:
This is not a problem right now, because variants cannot be used in type positions, but it may become a problem in the future if rust-lang/rfcs#2593 is accepted.
So this lints warns against cases like this and recommends to rewrite them as
<Self as Tr>::V.How to fix this warning/error
Explicitly disambiguate in favor of associated types from traits:
<Type as Trait>::Ambiguous.Current status
ambiguous_associated_itemslint as warn-by-defaultambiguous_associated_itemsdeny-by-default #59928 makes theambiguous_associated_itemslint deny-by-defaultambiguous_associated_itemslint a hard error