Skip to content

Range bound error in match has bad error message when integer literal wraps #68972

Closed
@Lokathor

Description

@Lokathor

For a match where I'm matching on a u8, I put 251..=256 on accident, and then rather than saying that 256 is out of range for u8, it decided to wrap 256 to 0 and then error that 251 is lower than the end of the range:

error[E0030]: lower range bound must be less than or equal to upper                        
  --> src\lib.rs:86:7
   |
86 |       251..=256 => StarClass::BlueGiant,
   |       ^^^ lower bound larger than upper bound

Clearly this is not a good situation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-patternsRelating to patterns and pattern matchingC-bugCategory: This is a bug.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.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