Skip to content

non-exhaustive patterns false positive #73919

Closed

Description

@leonardo-m
fn foo(x: usize) -> u32 {
    match x {
        0 ..= usize::MAX => 0
    }
}
fn main() {}

Gives:

error[E0004]: non-exhaustive patterns: `_` not covered
 --> ...\test.rs:2:11
  |
2 |     match x {
  |           ^ pattern `_` not covered
  |
  = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
  = note: the matched value is of type `usize`

Activity

  1. jonas-schievink commented on Jul 1, 2020

    @jonas-schievink
    Contributor

    Fairly sure this is intentional for usize

  2. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    C-enhancementCategory: An issue proposing an enhancement or a PR with one.
    A-exhaustiveness-checkingRelating to exhaustiveness / usefulness checking of patterns
    and removed
    C-bugCategory: This is a bug.
    on Jul 1, 2020
  3. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Jul 1, 2020
  4. leonardo-m commented on Jul 1, 2020

    @leonardo-m
    Author

    From the pull 73937 I've seen a part that I didn't see/remember:

    An unstable feature precise_pointer_size_matching will be added to permit matching exactly on pointer-size integer types.

    So you're right, this isn't a new bug, it's a known unfinished part. I hope to see that precise_pointer_size_matching implemented.

  5. varkor commented on Jul 3, 2020

    @varkor
    Contributor

    I hope to see that precise_pointer_size_matching implemented.

    It already exists.

  6. leonardo-m commented on Jul 3, 2020

    @leonardo-m
    Author

    I see, then what do I have to hope to see? :-)

  7. varkor commented on Jul 3, 2020

    @varkor
    Contributor

    I'm not sure the feature is ever going to be stabilised, because there are concerns that this isn't a desirable feature. But hopefully the diagnostics will at least be improved in #73937.

  8. leonardo-m commented on Jul 4, 2020

    @leonardo-m
    Author

    Do you have a link to such concerns? (Or are you willing to summarize them?)
    (I value your work on the compiler a lot varkor :-) )

  9. varkor commented on Jul 4, 2020

    @varkor
    Contributor

    I think the relevant concerns arose in the RFC thread (from this comment up). The overview is that we ought not to make assumptions about pointer sizes on the target platform, because they're not guaranteed to be fixed, so this could cause compatibility issues.

  10. added a commit that references this issue on Jul 5, 2020
    a1ac4d6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-exhaustiveness-checkingRelating to exhaustiveness / usefulness checking of patternsC-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