Skip to content

Trait aliases considers same type as not equal to itself if used in impl Trait return type #57612

Closed
@matprec

Description

@matprec

Example:

#![feature(trait_alias)]
#![feature(existential_type)]

trait Foo {
    type Bar: Baz<Self, Self>;

    fn bar(&self) -> Self::Bar;
}

struct X;

impl Foo for X {
    existential type Bar: Baz<Self, Self>;

    fn bar(&self) -> Self::Bar {
        |x: &X| x
    }
}

trait Baz<A, B> = Fn(&A) -> &B;

Workaround: Replace existential type Bar: Baz<Self, Self>; with existential type Bar: Fn(&X) -> &X;
Possibly related to #57611
Playground

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.A-trait-systemArea: Trait systemA-type-systemArea: Type systemF-trait_alias`#![feature(trait_alias)]`

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions