Closed
Description
What it does
This lint will trigger whenever using a reference to an uninhabited type, such as !
, Infallible
, or Void
.
This should apply recursively, like when a struct has an uninhabited field. But care should be taken that this applies to an enum type only when all variants are uninhabited, such that &Result<(), !>
does not trigger the lint.
Advantage
Creating a reference to an uninhabited type is a footgun at best and UB at worst, and can only be achieved via unsafe code. Essentially, it's never correct to have a reference to an uninhabited type.
Drawbacks
No response
Example
// This function shouldn't be possible to call
fn impossible(_thing: &Infallible) {}
fn foo(thing: &Infallible) {
// But we call it here because somehow we have a reference
impossible(thing);
}
Should be denied wholesale.