Skip to content

RFC 2203 not implemented inside a const block #65732

Closed
@ecstatic-morse

Description

@ecstatic-morse

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

Metadata

Metadata

Labels

A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)B-unstableBlocker: Implemented in the nightly compiler and unstable.C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions