Skip to content

Infinite recursion with associated type bounded by its trait #23122

Closed
@laijs

Description

@laijs
trait Next {
    type Next: Next;
}

struct GetNext<T: Next> { t: T}

impl<T: Next> Next for GetNext<T> {
    // type Next = <GetNext<T> as Next>::Next; // thread 'rustc' has overflowed its stack and core dump
    type Next = <GetNext<T::Next> as Next>::Next; // the rustc runs forever
}

fn main() {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-associated-itemsArea: Associated items (types, constants & functions)A-type-systemArea: Type systemE-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions