zebra
zebra copied to clipboard
Enforce unwrap-pertinent Clippy lints
Motivation
We have a few bugs that have crept in due to unwrap()
s being trigger-able in production.
Solution
Enforce these Clippy lints in production (i.e. non-test code), by either adding clippy:(allow|deny)
annotations at the top of each crate or in each module.
https://rust-lang.github.io/rust-clippy/master/#fallible_impl_from
Checks for impls of From<..> that contain panic!() or unwrap()
https://rust-lang.github.io/rust-clippy/master/#unwrap_in_result
Checks for functions of type Result that contain expect() or unwrap()
This might be extra pedantic: https://rust-lang.github.io/rust-clippy/master/#unwrap_used
Checks for impls of From<..> that contain panic!() or unwrap()
Alternatives
Try to enforce these rules at review time, by a human. Try to write a custom Clippy lint to enforce these rules: https://github.com/trailofbits/dylint (why, if Clippy proper has the above lints?)
Related Work
I think we should enforce fallible_impl_from
in test code as well.
We're unlikely to have From
impls in test code, and if we do, we might as well get them right.
@dconnolly what do you think?
This is not a priority for Zebra right now.