Skip to content

impl-trait type alias is usable in impl blocks #65384

Closed
@DutchGhost

Description

@DutchGhost

As requested in #53345 (comment), here's a follow up.

The following code below implements the trait MyTrait for an alias Bar, which is an alias to MyTrait. It doesnt really make sense to implement a trait...for that same trait.

type_alias_impl_trait doesn't mention anything about this, however the previous existential_type notes:

One last difference between existential type aliases and normal type aliases is that existential type aliases cannot be used in impl blocks

#![feature(type_alias_impl_trait)]

trait MyTrait {}

impl MyTrait for () {}

type Bar = impl MyTrait;

impl MyTrait for Bar {}

fn bazr() -> Bar { }

fn main() {}

Im not sure this should be allowed.

cc @Aaron1011 @nikomatsakis @Centril

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions