Skip to content

"Unreachable pattern" if matched variant is not imported #19100

Closed
@vhbit

Description

@vhbit
enum Foo {
  Bar,
  Baz
}

impl Foo {
   fn foo(&self) {
      match self {
         &Bar => println!("bar"),
         &Baz => println!("baz"),
      }
   }
}

It reports unreachable pattern:

test.rs:12:9: 12:13 error: unreachable pattern [E0001]
test.rs:12         &Baz => println!("baz"), 
                   ^~~~
test.rs:12:9: 12:13 help: pass `--explain E0001` to see a detailed explanation

while actually it should report unknown identifier

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