Open rootCircle opened 8 months ago
This should ignore both unimplemented!
and todo!
when checking.
Yes, I agree. The linter should only warn when a function either:
Checking for infinite loops comprehensively might be difficult, but even basic checks would be helpful.
FYI, function contains infinite loop is already linted 😄 infinite_loop
FYI, function contains infinite loop is already linted 😄 infinite_loop
Thanks for pointing it out! I think that lint can be used as reference for implementing this one! Also, I think it will be more sane to merge this one in infinite loop one, as both are targeting never return only?(need opinions) 😄
What it does
Rust's
!
type, also known as thenever
type, signifies that a function never returns normally. Clippy currently doesn't have a lint to suggest using!
when a function never returns a value or will result into diverging computation(eg., an infinite loop or panic), which could lead to potential type safety issues and misleading code patterns.Advantage
Drawbacks
never
type is still in nightly, and still will take time before it's stabilized, so better to wait in that case. (https://doc.rust-lang.org/nightly/std/primitive.never.html)Example
This function always panics, but its return type is implicitly () (unit), suggesting it might return a value. Adding ! as the return type would clarify its behavior:
Specifying a
never
return type will make it easier for its usage in where other functions are dependent on this function.