Skip to content

E0005; should all constructors be listed? #56379

Description

@Centril

Activity

  1. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Nov 30, 2018
  2. estebank commented on Nov 30, 2018

    @estebank
    Contributor

    Maybe we could do that with an upper bound, as having more than ~3 listed ranges will get really noisy. Imagine if you had a check for every other integer in u16, you'd have 32K ranges! I'd be fine with it as long as this is handled gracefully.

    It'll also be nice to mention when a range between two values involves std::{integer}::MAX or MIN.

  3. Centril commented on Nov 30, 2018

    @Centril
    ContributorAuthor

    @estebank Yeah an upper bound makes sense.

  4. varkor commented on Nov 30, 2018

    @varkor
    Contributor

    It'll also be nice to mention when a range between two values involves std::{integer}::MAX or MIN.

    Yeah, this was a case I was thinking about too — it'll probably be fairly common case, so it'd be good to handle sensibly.

    Edit: I've filed #56393 for this specific suggestion.

  5. estebank commented on Oct 10, 2019

    @estebank
    Contributor

    @Centril is there still work left to do on this front?

  6. varkor commented on Oct 10, 2019

    @varkor
    Contributor

    The match algorithm still short-circuits and reports only the first unencountered constructor in some cases. You can see this in some of the test cases for #65160, for instance.

  7. added
    C-enhancementCategory: An issue proposing an enhancement or a PR with one.
    on Jun 11, 2020
  8. Nadrieril commented on Nov 22, 2020

    @Nadrieril
    Member

    Couldn't find an example with missing integer ranges like the one mentioned in the OP; I suspect we've fixed those. Here's a different one (play):

    enum Foo {
        A(bool),
        B(bool),
        C(bool),
    }
    fn main() {
        match Foo::A(true) {
            Foo::A(true) => {},
            Foo::B(true) => {},
            Foo::C(true) => {},
        }
    }

    This only errors about A(false) not being covered.

    I'm adding my favorite label so I can find this later.
    @rustbot modify labels: +A-exhaustiveness-checking

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

Metadata

Metadata

Assignees

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