Skip to content

Tracking issue for future-incompatbility lint ambiguous_associated_items #57644

Open

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

Activity

  1. added
    A-lints
    T-lang
    T-compiler
    C-future-incompatibility
    on Jan 15, 2019
  2. added a commit that references this issue on May 2, 2019
  3. added 2 commits that reference this issue on May 2, 2019
  4. mkpankov commented on Sep 30, 2020

    @mkpankov
    Contributor

    Self::V in type namespace may refer to both variant and associated type

    How is a variant present in type namespace? Syntactically only type is possible in that position, a function can't return a variant of an enum.

  5. 7 remaining items

  6. changed the title [-]Tracking issue for `ambiguous_associated_items` compatibility lint[/-] [+]Tracking issue for future-incompatbility lint `ambiguous_associated_items`[/+] on Sep 14, 2024
  7. added
    C-tracking-issue
    A-associated-items
    on Sep 14, 2024
  8. added 5 commits that reference this issue on Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-associated-itemsA-lintsC-future-incompatibilityC-tracking-issueT-compilerT-lang

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions