Incorrect promotion for projection in a const
#65727
Labels
A-const-eval
Area: Constant evaluation, covers all const contexts (static, const fn, ...)
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Consider the following code:
Playground
The borrow of the tuple field in
main
is 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
/StorageDead
for the tuple, causingx
to dangle. On stable, this is only caught during const-evaluation and results in aconst_err
warning. 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.
The text was updated successfully, but these errors were encountered: