Skip to content

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

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
bluss opened this issue Apr 17, 2016 · 1 comment
Labels
A-type-system Area: Type system

Comments

@bluss
Copy link
Member

bluss commented Apr 17, 2016

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,
}
@steveklabnik steveklabnik added the A-type-system Area: Type system label Jul 25, 2016
@Mark-Simulacrum
Copy link
Member

Closing in favor of #35237, since it has more detailed explanation.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-type-system Area: Type system
Projects
None yet
Development

No branches or pull requests

3 participants