Skip to content

Display {integer}::MIN/MAX in integer range suggestions rather than the expanded value #56393

Closed
@varkor

Description

@varkor
fn main() {
    match 0i32 {
      1 => {} //~ ERROR
    }
}

Once exhaustive integer matching has been stabilised, we'll be getting errors like this:

error[E0004]: non-exhaustive patterns: `-2147483648i32..=0i32` and `2i32..=2147483647i32` not covered
 --> src/main.rs:5:11
  |
5 |     match 0i32 {
  |           ^^^^ patterns `-2147483648i32..=0i32` and `2i32..=2147483647i32` not covered

It would be nicer to display these as ::std::i32::MIN (or ::core, etc.) instead (or provide a hint telling the user this).

See https://github.com/rust-lang/rust/pull/56362/files/4fc5758a67e38b21e975fc9efe071dd58f4b98c6#diff-1d41dba9e92e851833cbeb40c504a40b for instance, where we display -2147483648i32 rather than ::std::i32::MIN.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: 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