-
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, ...)B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.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.requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.
Description
Thanks to RFC 2203, code like the following compiles on nightly:
fn main() {
let _: [Option<Box<i32>>; 4] = [None; 4];
}
However, as pointed out by @RalfJung, the same code fails to compile in a const
block (Playground):
const _: [Option<Box<i32>>; 4] = [None; 4];
Currently, there's two distinct implementations for promotion of temps, one for fn
and const fn
and one for const
and static
. RFC 2203 is implemented for the first but not the second.
I didn't see an actual issue for this. I'll close this as a dupe if @RalfJung already opened one.
cc #49147
davidtwco
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, ...)B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.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.requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.