-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.
Description
Code
I tried this code:
struct Value {
values: &'static [&'static Value],
}
static VALUE: Value = Value {
values: &[&VALUE],
};
I expected to see this happen: compile fine, with the VALUE
static containing a slice that references VALUE
.
Instead, this happened:
error[E0391]: cycle detected when const-evaluating + checking `VALUE`
--> src/main.rs:6:13
|
6 | values: &[&VALUE],
| ^^^^^^^^^
|
note: ...which requires simplifying constant for the type system `VALUE::promoted[0]`...
--> src/main.rs:5:1
|
5 | static VALUE: Value = Value {
| ^^^^^^^^^^^^^^^^^^^
note: ...which requires const-evaluating + checking `VALUE::promoted[0]`...
--> src/main.rs:5:1
|
5 | static VALUE: Value = Value {
| ^^^^^^^^^^^^^^^^^^^
= note: ...which again requires const-evaluating + checking `VALUE`, completing the cycle
note: cycle used when linting top-level module
--> src/main.rs:1:1
|
1 | / struct Value {
2 | | values: &'static [&'static Value],
3 | | }
4 | |
... |
8 | |
9 | | fn main() {}
| |____________^
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
Version it worked on
It most recently worked on: nightly-2024-02-10
Version with regression
nightly-2024-02-11
rustc --version --verbose
:
rustc 1.78.0-nightly (6cc484351 2024-02-10)
binary: rustc
commit-hash: 6cc4843512d613f51ec81aba689180c31b0b28b6
commit-date: 2024-02-10
host: aarch64-apple-darwin
release: 1.78.0-nightly
LLVM version: 17.0.6
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-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.