Skip to content

ambiguous associated item accepted in item signature #103640

Open
@aliemjay

Description

@aliemjay

The following should not compile, but it does:

trait Test {
    type Variant;
    fn test(_: ());
}

enum Enum {
    Variant,
}

impl Test for <[Enum; 0] as IntoIterator>::Item { // <- Self is a projection
    type Variant = ();
    fn test(_: Self::Variant) { // <- this is accepted.
        //None::<Self::Variant>; // <- this is rejected.
    }
}

Self::Variant here is ambiguous and should be rejected for the same reason it's rejected in the fn body.

This bug is seemingly an unintended fallout from:
https://github.com/rust-lang/rust/blob/master/compiler/rustc_hir_analysis/src/collect.rs#L520

@rustbot label T-lang A-resolve

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyT-langRelevant to the language team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions