Closed
Description
The following code used to compile on nightly:
#![feature(const_generics)]
#[derive(PartialEq, Eq)]
struct Inner;
#[derive(PartialEq, Eq)]
struct Outer<const I: Inner>;
error[E0391]: cycle detected when computing type of `Outer::I`
--> src\lib.rs:7:20
|
7 | struct Outer<const I: Inner>;
| ^
|
= note: ...which requires computing whether `Inner` implements `PartialStructuralEq` and `StructuralEq`...
= note: ...which requires evaluating trait selection obligation `Inner: std::marker::StructuralPartialEq`...
note: ...which requires trait impls of `std::marker::StructuralPartialEq`...
--> .../src/rust\library\core\src\marker.rs:152:1
|
152 | pub trait StructuralPartialEq {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires computing type of `<impl at src\lib.rs:6:10: 6:19>`...
--> src\lib.rs:6:10
|
6 | #[derive(PartialEq, Eq)]
| ^^^^^^^^^
= note: ...which again requires computing type of `Outer::I`, completing the cycle
note: cycle used when computing type of `<impl at src\lib.rs:6:21: 6:23>`
--> src\lib.rs:6:21
|
6 | #[derive(PartialEq, Eq)]
| ^^
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
The same is true for any non-primitive const param, i.e.:
#[derive(PartialEq, Eq)]
struct Outer<const I: Option<usize>>;