Fix 1.66 Clippy warnings (#3178)

1.66 release speeds up compile times for over 10% according to tests.

Also its Clippy finds plenty of old nits in our code:
* useless conversion, `foo as u8` where `foo: u8` and similar, removed
`as u8` and similar
* useless references and dereferenced (that were automatically adjusted
by the compiler), removed various `&` and `*`
* bool -> u8 conversion via `if/else`, changed to `u8::from`
* Map `.iter()` calls where only values were used, changed to
`.values()` instead

Standing out lints:
* `Eq` is missing in our protoc generated structs. Silenced, does not
seem crucial for us.
* `fn default` looks like the one from `Default` trait, so I've
implemented that instead and replaced the `dummy_*` method in tests with
`::default()` invocation
* Clippy detected that
```
if retry_attempt < u32::MAX {
    retry_attempt += 1;
}
```
is a saturating add and proposed to replace it.
This commit is contained in:
Kirill Bulatov
2022-12-22 14:27:48 +02:00
committed by GitHub
parent f5f1197e15
commit fca25edae8
39 changed files with 123 additions and 152 deletions

View File

@@ -160,7 +160,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}
for _i in 0..args.num_pubs {
let c = None;
tokio::spawn(publish(c, args.num_subs as u64));
tokio::spawn(publish(c, args.num_subs));
}
h.await?;

View File

@@ -13,6 +13,10 @@ use proto::{
// Code generated by protobuf.
pub mod proto {
// Tonic does derives as `#[derive(Clone, PartialEq, ::prost::Message)]`
// we don't use these types for anything but broker data transmission,
// so it's ok to ignore this one.
#![allow(clippy::derive_partial_eq_without_eq)]
tonic::include_proto!("storage_broker");
}