Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive on non_exhaustive_omitted_patterns_lint with closures #99815

Closed
Nemo157 opened this issue Jul 27, 2022 · 2 comments · Fixed by #109836
Closed

False positive on non_exhaustive_omitted_patterns_lint with closures #99815

Nemo157 opened this issue Jul 27, 2022 · 2 comments · Fixed by #109836
Labels
C-bug Category: This is a bug. F-non_exhaustive_omitted_patterns_lint `#![feature(non_exhaustive_omitted_patterns_lint)]`

Comments

@Nemo157
Copy link
Member

Nemo157 commented Jul 27, 2022

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

@Nemo157 Nemo157 added C-bug Category: This is a bug. F-non_exhaustive_omitted_patterns_lint `#![feature(non_exhaustive_omitted_patterns_lint)]` labels Jul 27, 2022
@Nemo157
Copy link
Member Author

Nemo157 commented Jul 27, 2022

(Note: it's not to do with the _ pattern, in the real code I found this in the argument was used).

@Mark-Simulacrum
Copy link
Member

I think this is a good thing to fix, but I don't think this would block stabilization since:

  • It's unlikely you're enabling the lint across an entire crate -- most of the time, it'll be limited to a few tests or specific matches, probably.
  • The lint can be fixed in the future (we should definitely do that though!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-non_exhaustive_omitted_patterns_lint `#![feature(non_exhaustive_omitted_patterns_lint)]`
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants