-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Incorrect promotion for projection in a const #65727
Copy link
Copy link
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.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.
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.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.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Consider the following code:
Playground
The borrow of the tuple field in
mainis promoted out along with the tuple itself in accordance with the rules for rvalue static promotion. However, in theconst, the mechanism for promotion does not removeDrop/StorageDeadfor the tuple, causingxto dangle. On stable, this is only caught during const-evaluation and results in aconst_errwarning. If this warning is supressed, an ICE occurs.On nightly, the MIR borrow checker prevents this from happening, and this code is rejected instead. It should be accepted in all contexts.