Skip to content

"error: integer literal is too large" should mention the actual type limit #105908

Closed
@matthiaskrgr

Description

@matthiaskrgr

Given the following code:

pub fn main() {
    let x = [0; 1111111111111111111111111111111111111111111111111111111_u128];
}

The current output is:

error: integer literal is too large
 --> src/main.rs:2:17
  |
2 |     let x = [0; 1111111111111111111111111111111111111111111111111111111_u128];
  |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: could not compile `playground` due to previous error

It would be nice if the message could say something like "integer literal is too large, value exceeds limit of ${u128::MAX}" or something like that

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsT-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