Skip to content

cycle detected when computing the super predicates of ... #96665

Closed
@sebschmi

Description

@sebschmi

Code

I tried this code:

pub trait Sequence<Item, Subsequence: Sequence<Item, Subsequence>> {}

pub trait NodeWalk<Graph: GraphBase, NodeSubwalk: NodeWalk<Graph, NodeSubwalk>>:
    Sequence<Graph::NodeIndex, NodeSubwalk>
{
}

pub trait GraphBase {
    type NodeIndex;
}

pub trait WalkableGraph: GraphBase {}

playground

(this example was created by stripping down https://crates.io/crates/traitgraph/0.10.0)

I expected to see this happen: it should build on nightly as it does on beta and stable

Instead, this happened:

Compiling playground v0.0.1 (/playground)
error[E0391]: cycle detected when computing the super predicates of `NodeWalk`
 --> src/lib.rs:5:1
  |
5 | / pub trait NodeWalk<Graph: GraphBase, NodeSubwalk: NodeWalk<Graph, NodeSubwalk>>:
6 | |     Sequence<Graph::NodeIndex, NodeSubwalk>
7 | | {
8 | | }
  | |_^
  |
note: ...which requires computing the super traits of `NodeWalk`...
 --> src/lib.rs:6:14
  |
6 |     Sequence<Graph::NodeIndex, NodeSubwalk>
  |              ^^^^^^^^^^^^^^^^
note: ...which requires computing the bounds for type parameter `Graph`...
 --> src/lib.rs:5:20
  |
5 | pub trait NodeWalk<Graph: GraphBase, NodeSubwalk: NodeWalk<Graph, NodeSubwalk>>:
  |                    ^^^^^
  = note: ...which again requires computing the super predicates of `NodeWalk`, completing the cycle
note: cycle used when collecting item types in top-level module
 --> src/lib.rs:5:1
  |
5 | / pub trait NodeWalk<Graph: GraphBase, NodeSubwalk: NodeWalk<Graph, NodeSubwalk>>:
6 | |     Sequence<Graph::NodeIndex, NodeSubwalk>
7 | | {
8 | | }
  | |_^

For more information about this error, try `rustc --explain E0391`.
error: could not compile `playground` due to previous error

Version it worked on

It most recently worked on: stable 1.60.0 and 1.61.0-beta.4 (69a6d12 2022-04-25)

Version with regression

rustc --version --verbose:

rustc 1.62.0-nightly (bed05e996 2022-05-02)
binary: rustc
commit-hash: bed05e996e37e44b1a3980b84754af621fd3c4ce
commit-date: 2022-05-02
host: x86_64-unknown-linux-gnu
release: 1.62.0-nightly
LLVM version: 14.0.1

@rustbot modify labels: +regression-from-stable-to-nightly -regression-untriaged

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions