Performing operations like offset
or wrapping_add
/wrapping_sub
on raw pointers to zero-sized types (ZSTs)
results in no-op operations. This is likely unintended and could make the code misleading, potentially hiding bugs.
Code examples
Noncompliant code example
unsafe { (&() as *const ()).offset(1); } // Noncompliant: No-op on zero-sized type pointer.
Compliant solution
// Removing the no-op operation as it has no effect.