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

Non-exhaustive pattern error when matching on ! #115716

Open
cjgillot opened this issue Sep 9, 2023 · 1 comment
Open

Non-exhaustive pattern error when matching on ! #115716

cjgillot opened this issue Sep 9, 2023 · 1 comment
Labels
C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@cjgillot
Copy link
Contributor

cjgillot commented Sep 9, 2023

I tried this code:

#![feature(never_type)]

fn main() {
    let x: !;
    match x {
        _ if { loop {} } => (),
    }
}

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=4a9450423c54a62242360d62e9480bf3

I expected to see this happen: complain about the uninitialized binding x.
Like it does in https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=99dc49582c1bce26b084e33bfd366026

Instead, this happened: error E0004: non-exhaustive patterns: () not covered
A match on a scrutinee of type ! should not expect a pattern of type ().

Meta

rustc --version --verbose:

rustc 1.71.1 (eb26296b5 2023-08-03)
binary: rustc
commit-hash: eb26296b556cef10fb713a38f3d16b9886080f26
commit-date: 2023-08-03
host: x86_64-unknown-linux-gnu
release: 1.71.1
LLVM version: 16.0.5
@cjgillot cjgillot added the C-bug Category: This is a bug. label Sep 9, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 9, 2023
@asquared31415
Copy link
Contributor

Adding the never_type_fallback feature causes the code to compile.

@saethlin saethlin added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Sep 10, 2023
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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants