- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Closed
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.Category: This is a bug.P-highHigh priorityHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.Performance or correctness regression from stable to beta.
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`.
Metadata
Metadata
Assignees
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.Category: This is a bug.P-highHigh priorityHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.Performance or correctness regression from stable to beta.