Skip to content

Tracking issue for future-incompatbility lint ambiguous_associated_items #57644

Open
@petrochenkov

Description

@petrochenkov

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-associated-itemsArea: Associated items (types, constants & functions)A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-future-incompatibilityCategory: Future-incompatibility lintsC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    Status

    Idea

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions