Description
Summary
The new uninhabited_reference
lint complains about deferencing a reference to an infallible type, saying this is UB. But it is possible to write such code in safe Rust, which will be provably impossible to call (absent unsafe code which itself is almost certainly incorrect).
The lint purpose would be better served by linting the creation of a reference to an uninhabited type. The original issue has some discussion saying that it's maybe not UB, but it's almost certainly wrong. Versus the dereference, which is safe to write and has legitimate usecases.
At the very least, the existing lint shouldn't trigger on trait implementations.
cc #11851
Lint Name
No response
Reproducer
impl PushBytesErrorReport for core::convert::Infallible {
#[inline]
fn input_len(&self) -> usize { match *self {} }
}
triggers the lint. But this code is clearly implementing an error-related trait for Infallible
, with the understanding that the trait method is impossible to call.
Version
No response
Additional Labels
No response