Skip to content

Cycle detected when using associated type bounds in super trait #65913

@tage64

Description

@tage64

I don't know if this is a bug or expected behaviour. But I'm encountering the following error when compiling the following code.

#![feature(associated_type_bounds)] trait A { type T; } trait B: A<T: B> {}
error[E0391]: cycle detected when computing the supertraits of `B` --> src/main.rs:6:15 | 6 | trait B: A<T: B> {} | ^ | = note: ...which again requires computing the supertraits of `B`, completing the cycle note: cycle used when collecting item types in top-level module --> src/main.rs:6:1 | 6 | trait B: A<T: B> {} | ^^^^^^^^^^^^^^^^

But if I merge the traits A and B into the trait C it works.

trait C { type T: C; }

I think the first example should work as good as the second since the trait C is only split into two traits A and B with same functionality.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-trait-systemArea: Trait systemD-confusingDiagnostics: Confusing error or lint that should be reworked.D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.F-associated_type_bounds`#![feature(associated_type_bounds)]`I-cycleIssue: A query cycle occurred while none was expectedT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions