Open
Description
I tried this code:
#![feature(min_exhaustive_patterns)]
#![feature(never_type)]
use std::marker::PhantomData;
pub fn foo<B>(x: (!, PhantomData<B>)) -> ! {
match x {}
}
pub struct Bar<B>(!, PhantomData<B>);
impl<B> Bar<B> {
pub fn bar(&self) -> ! {
match *self {}
}
}
I expected to see this happen: No errors (because Bar<B>
is empty the same way foo
's parameter is).
Instead, this happened: non-exhaustive patterns: type Bar<B> is non-empty
.
Note that the tracking issue #119612 mentions "a struct with a visible field of empty type", so I also tried to make the first field pub !
to see, but it's the same behavior. Note that I consider the field visible in the scope it is used, which matches with the fact that adding pub
did not fix the issue. The issue seems thus to be a difference between struct-tuple and tuple.
Meta
rustc --version --verbose
:
rustc 1.82.0-nightly (f8060d282 2024-07-30)
binary: rustc
commit-hash: f8060d282d42770fadd73905e3eefb85660d3278
commit-date: 2024-07-30
host: x86_64-unknown-linux-gnu
release: 1.82.0-nightly
LLVM version: 18.1.7