Skip to content

Improve "no type for local variable" error when in check_const_with_ty  #24414

Closed

Description

The control flow for rustc_typeck::check::check_const_with_ty can end up spitting out an error of the form:

non-constant-expr-for-fixed-len-vec.rs:15:25: 15:26 error: no type for local variable 10
non-constant-expr-for-fixed-len-vec.rs:15         let _x: [isize; n];

With the compiler as it stands today, this is usually coupled with an error of the form:

error: array length constant evaluation error: non-constant path in constant expr

but other changes being made may lead to only the "no type for local variable" message being emitted.

We can do better here, e.g. by passing along knowledge that we are looking at a const-expr and then reporting that local variables simply are invalid within const-exprs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lints

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions