-
-
Notifications
You must be signed in to change notification settings - Fork 15.6k
Inline const errors are opt-level-dependent #160964
Copy link
Copy link
Open
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)A-monomorphizationArea: MonomorphizationArea: MonomorphizationC-bugCategory: This is a bug.Category: This is a bug.I-lang-radarItems that are on lang's radar and will need eventual work or consideration.Items that are on lang's radar and will need eventual work or consideration.T-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.T-langRelevant to the language teamRelevant to the language team
Description
Activity
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, ...)A-monomorphizationArea: MonomorphizationArea: MonomorphizationC-bugCategory: This is a bug.Category: This is a bug.I-lang-radarItems that are on lang's radar and will need eventual work or consideration.Items that are on lang's radar and will need eventual work or consideration.T-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.T-langRelevant to the language teamRelevant to the language team
I tried this code:
I expected to see this happen:
The compile error should always occur, regardless of opt-level
Instead, this happened:
Meta
rustc --version --verbose:The issue also reproduces with
rustc 1.99.0-nightly (ad3d0bc14 2026-07-31).Related
Note
While I used an LLM to investigate this issue and perform machine translation, I myself conducted the issue reproduction and original text creation, as required by the Rust LLM Usage Policy, which I note here.