Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

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

Closed
bluss opened this issue Apr 17, 2016 · 1 comment
Labels
A-typesystem Area: The 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-typesystem Area: The type system label Jul 25, 2016
@Mark-Simulacrum
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-typesystem Area: The type system
Projects
None yet
Development

No branches or pull requests

3 participants