Open
Description
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
- High priority resolutions for associated variants #57501 introduces the
ambiguous_associated_items
lint as warn-by-default - Make deprecation lint
ambiguous_associated_items
deny-by-default #59928 makes theambiguous_associated_items
lint deny-by-default - PR ? makes the
ambiguous_associated_items
lint a hard error
Metadata
Metadata
Assignees
Labels
Area: Associated items (types, constants & functions)Area: Lints (warnings about flaws in source code) such as unused_mut.Category: Future-incompatibility lintsCategory: An issue tracking the progress of sth. like the implementation of an RFCRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the language team, which will review and decide on the PR/issue.
Type
Projects
Status
Idea