Skip to content

non_exhaustive_omitted_patterns should not warn matches! macro #117304

Open
@taiki-e

Description

@taiki-e

I tried this code:

#![feature(non_exhaustive_omitted_patterns_lint)]
#![warn(non_exhaustive_omitted_patterns)]

use std::sync::atomic::Ordering; // #[non_exhaustive] enum

pub fn is_seqcst(order: Ordering) -> bool {
    matches!(order, Ordering::SeqCst)
}

I expected to see this happen: no warning

Instead, this happened:

warning: some variants are not matched explicitly
 --> src/lib.rs:7:14
  |
7 |     matches!(order, Ordering::SeqCst)
  |              ^^^^^ patterns `std::sync::atomic::Ordering::Relaxed`, `std::sync::atomic::Ordering::Release`, `std::sync::atomic::Ordering::Acquire` and 1 more not covered
  |
  = help: ensure that all variants are matched explicitly by adding the suggested match arms
  = note: the matched value is of type `std::sync::atomic::Ordering` and the `non_exhaustive_omitted_patterns` attribute was found

playground

Meta

rustc --version --verbose:

rustc 1.75.0-nightly (2f1bd0729 2023-10-27)
binary: rustc
commit-hash: 2f1bd0729b74787f55d4cbc7818cfd787cd43a99
commit-date: 2023-10-27
host: aarch64-apple-darwin
release: 1.75.0-nightly
LLVM version: 17.0.3

@rustbot label +F-non_exhaustive_omitted_patterns_lint

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.F-non_exhaustive_omitted_patterns_lint`#![feature(non_exhaustive_omitted_patterns_lint)]`T-libsRelevant to the library 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