О, clippy в стабильный компилятор завезли:
https://blog.rust-lang.org/2018/09/13/Rust-1.29.html
"cargo clippy
Speaking of warnings, you can now check out a preview of cargo clippy through Rustup. Clippy is a large number of additional warnings that you can run against your Rust code.
For example:
let mut lock_guard = mutex.lock();
std::mem::drop(&lock_guard)
operation_that_requires_mutex_to_be_unlocked();
This code is syntactically correct, but may have a deadlock! You see, we dropped a reference to lock_guard, not the guard itself. Dropping a reference is a no-op, and so this is almost certainly a bug.
We can get the preview of Clippy from Rustup:
$ rustup component add clippy-preview
and then run it:
$ cargo clippy
error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing.
--> src\main.rs:5:5
|
5 | std::mem::drop(&lock_guard);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[deny(drop_ref)] on by default
note: argument has type &std::result::Result<std::sync::MutexGuard<&
#39;_, i32>, std::sync::PoisonError<std::sync::MutexGuard<&
#39;_, i32>>>
--> src\main.rs:5:20
|
5 | std::mem::drop(&lock_guard);
| ^^^^^^^^^^^
= help: for further information visit
https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#drop_ref
As you can see from that help message, you can view all of the lints that clippy offers on the web.
Please note that this is a preview; clippy has not yet reached 1.0. As such, its lints may change. We’ll release a clippy component once it has stabilized; please give the preview a try and let us know how it goes."