Skip to content

Associated type Self::Dim in trait constraint yields "unsupported cyclic reference" #33053

@bluss

Description

@bluss

Should this not be ok when the associated item exists in the current trait itself?

Erroring code:

pub trait ShapeBuilder : Into<Shape<Self::Dim>> {
    type Dim;
}
pub struct Shape<D> {
    dim: D,
}

src/impl_constructors.rs:25:37: 25:46 error: unsupported cyclic reference between types/traits detected [E0391]
src/impl_constructors.rs:25 pub trait ShapeBuilder : Into<Shape<Self::Dim>>
                                                                ^~~~~~~~~

Modifying it slightly compiles:

pub trait ShapeBuilder : Into<Shape<<Self as ShapeBuilder>::Dim>> {
    type Dim;
}

pub struct Shape<D> {
    dim: D,
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions