Closed
Description
Let's tying to compile this code.This code compiled ok on stable and on nightly-2019-06-17 (for example at rust play site)
struct Foo {
foo: Option<&'static Foo>
}
static FOO: Foo = Foo {
foo: Some(&FOO),
};
fn main() {
println!("Hello, world!");
}
But in current rustc 1.37.0-nightly (d3e2cec 2019-06-26) compilation fails with message:
error[E0391]: cycle detected when const-evaluating `FOO`
--> src/main.rs:6:1
|
6 | static FOO: Foo = Foo {
| ^^^^^^^^^^^^^^^^^^^^^
|
note: ...which requires const-evaluating `FOO`...
--> src/main.rs:6:1
|
6 | static FOO: Foo = Foo {
| ^^^^^^^^^^^^^^^^^^^^^
= note: ...which again requires const-evaluating `FOO`, completing the cycle
note: cycle used when const-evaluating + checking `FOO`
--> src/main.rs:6:1
|
6 | static FOO: Foo = Foo {
| ^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0391`.