Skip to content

Better error message for matching against not-imported enum variant  #12594

Closed
@edwardw

Description

@edwardw

If only the enumeration type itself is imported but not its variants, a match expression reports unreachable pattern instead of unrecognised type:

pub mod inner {
  pub enum E {
    E1,
    E2
  }
}

pub mod foo {
  use inner::E; // change this to use inner::{E, E1, E2} then all will be fine

  pub fn bar(e: E) -> int {
    match e {
      E1 => 0,
      E2 => 1    // error: unreachable pattern
    }
  }
}

pub fn main() {}

Is this something intentional? Or should we give it a more sensible error message?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions