Skip to content

False positive on non_exhaustive_omitted_patterns_lint with closures #99815

Closed
@Nemo157

Description

@Nemo157

I tried this code (playground):

#![warn(non_exhaustive_omitted_patterns)]

// in other library:
// #[non_exhaustive] pub enum Foo { A, B }
use lib::Foo;

fn foo(_: impl Fn(Foo)) {}

fn main() {
    foo(|_: Foo| { todo!() });
}

I expected to see this happen: no warnings.

Instead, this happened:

warning: some variants are not matched explicitly
  --> src/main.rs:10:14
   |
10 |         foo(|_: Foo| { todo!() });
   |              ^ patterns `A` and `B` not covered
   |

Meta

1.64.0-nightly (2022-07-26 4d6d601c8a83284d6b23)

cc #89554

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions