Skip to content

Ambiguity problems with associated types #234

Open

Description

While handling associated types in rust-analyzer, I ran into two problems that I want to ask about. These are probably not related, so I can split this up if necessary, but I wanted to discuss them a bit first 🙂

Number 1:
(moved to #235)

Number 2:

#[test]
fn projection_equality() {
    test! {
        program {
            trait Trait1 {
                type Type;
            }
            trait Trait2<T> { }
            impl<T, U> Trait2<T> for U where U: Trait1<Type = T> {}

            struct u32 {}
            struct S {}
            impl Trait1 for S {
                type Type = u32;
            }
        }

        goal {
            exists<U> {
                S: Trait2<U>
            }
        } yields {
            "Unique"
        }
    }
}

I'd expect this to pass, but it yields ambiguity, I think because the ProjectionEq is ambiguous between u32 and Trait1::Type<S>. But those are really the same type. I found #74, but it's not clear to me how this kind of thing is supposed to work with ProjectionEq. #111 is maybe related?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    C-chalk-engineIssues related to the chalk-engine cratebugA bugdesignNeeds design workrustc integrationRelated to or required for rustc integration

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions