uninhabited_references
warns on common patterns like match *x {}
#11985
Labels
C-bug
Category: Clippy is not doing the correct thing
I-false-positive
Issue: The lint was triggered on code it shouldn't have
Summary
It's very common to match on uninhabited types when we statically know they are uninhabited. It's a very common pattern to express that the code is known to be dead. Especially trait impls of uninhabited types. Aside from that I believe the whole lint is broken since dereferencing an uninhabited type is not UB - it cannot happen in the first place. Creating it is UB. The lint should instead disallow casting inhabited types to uninhabited (using
transmute
or pointers).Lint Name
uninhabited_references
Reproducer
I tried this code:
I saw this happen:
I expected to see this happen: No warning
Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: