Skip to content

An unusable constant should at least warn #47054

Closed
@scottmcm

Description

@scottmcm

The following produces no warnings:

pub const A: [i32;3] = [1,2,3];
pub const FOO: i32 = A[100000];

fn main() { println!("Verified"); }

But any attempt to use the FOO const will give error[E0080]: constant evaluation error.

It would be nice for it to at least warn. and perhaps start erring once the "error on use" case can be handled with a stable const fn.

Metadata

Metadata

Assignees

Labels

A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)C-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions