## AMBIGUOUS_ASSOCIATED_ITEMS

# Static AMBIGUOUS_ASSOCIATED_ITEMS

    pub static AMBIGUOUS_ASSOCIATED_ITEMS: &'static Lint

Expand description

The `ambiguous_associated_items` lint detects ambiguity between associated items and enum variants.

#### §Example

ⓘ

    enum E {
        V
    }

    trait Tr {
        type V;
        fn foo() -> Self::V;
    }

    impl Tr for E {
        type V = u8;
        // `Self::V` is ambiguous because it may refer to the associated type or
        // the enum variant.
        fn foo() -> Self::V { 0 }
    }

{{produces}}

#### §Explanation

Previous versions of Rust did not allow accessing enum variants through type aliases. When this ability was added (see RFC 2338), this introduced some situations where it can be ambiguous what a type was referring to.

To fix this ambiguity, you should use a qualified path to explicitly state which type to use. For example, in the above example the function can be written as `fn f() -> <Self as Tr>::V { 0 }` to specifically refer to the associated type.

This is a future-incompatible lint to transition this to a hard error in the future. See issue #57644 for more details.