Skip to content

WIP: Add the "unwrap_used" lint.

S0AndS0 requested to merge clippy-unwrap_used into main

In some cases unwrap calls are converted to expect as a placeholder for providing more friendly panic messages, mostly this is done on Mutex and file locks; for reasons.

Check discussion on if unwrapping Mutex locks is a good idea...

https://users.rust-lang.org/t/should-i-unwrap-a-mutex-lock/61519

... TLDR, panicking may be the best option if lock was poisoned.

In other cases unwrap calls are converted to ok_or(Error::<kind>("..."))?, however, it likely be a good idea to expand the kinds of errors available.

Where comments were already present that explained unwrap safety, a Clippy allow configuration is added. And where safety is self evident a comment is added.

Note, tor-netdir/src/params.rs -- impl Default for NetParameters unwrapping is allowed for now because I am uncertain if panicking or macros are the preferred route for handling the collection of results.

Testing and mocking code in some places have been refactored to utilize Result types, because I felt more comfortable making such changes in non-runtime code.

Merge request reports

Loading