Use #[expect], lint reasons

This commit is contained in:
Lambda 2024-09-05 19:01:22 +00:00
parent e14b7f28f2
commit b09c44a0ca
49 changed files with 157 additions and 161 deletions

View file

@ -72,10 +72,11 @@ fn db_options(max_open_files: i32, rocksdb_cache: &Cache) -> Options {
impl KeyValueDatabaseEngine for Arc<Engine> {
fn open(config: &Config) -> Result<Self> {
#[allow(
#[expect(
clippy::as_conversions,
clippy::cast_sign_loss,
clippy::cast_possible_truncation
clippy::cast_possible_truncation,
reason = "saturating to usize is fine"
)]
let cache_capacity_bytes =
(config.database.cache_capacity_mb * 1024.0 * 1024.0) as usize;
@ -144,7 +145,11 @@ impl KeyValueDatabaseEngine for Arc<Engine> {
}))
}
#[allow(clippy::as_conversions, clippy::cast_precision_loss)]
#[expect(
clippy::as_conversions,
clippy::cast_precision_loss,
reason = "these are just informational"
)]
fn memory_usage(&self) -> Result<String> {
let stats =
get_memory_usage_stats(Some(&[&self.rocks]), Some(&[&self.cache]))?;

View file

@ -124,11 +124,12 @@ impl KeyValueDatabaseEngine for Arc<Engine> {
// 2. divide by permanent connections + permanent iter connections +
// write connection
// 3. round down to nearest integer
#[allow(
#[expect(
clippy::as_conversions,
clippy::cast_possible_truncation,
clippy::cast_precision_loss,
clippy::cast_sign_loss
clippy::cast_sign_loss,
reason = "saturating to u32 is fine"
)]
let cache_size_per_thread =
((config.database.cache_capacity_mb * 1024.0)

View file

@ -9,7 +9,10 @@ use tokio::sync::watch;
#[derive(Default)]
pub(super) struct Watchers {
#[allow(clippy::type_complexity)]
#[expect(
clippy::type_complexity,
reason = "not actually all that complex"
)]
watchers:
RwLock<HashMap<Vec<u8>, (watch::Sender<()>, watch::Receiver<()>)>>,
}

View file

@ -53,7 +53,7 @@ impl service::rooms::edus::read_receipt::Data for KeyValueDatabase {
}
#[tracing::instrument(skip(self))]
#[allow(clippy::type_complexity)]
#[expect(clippy::type_complexity)]
fn readreceipts_since<'a>(
&'a self,
room_id: &RoomId,

View file

@ -64,7 +64,7 @@ impl service::rooms::search::Data for KeyValueDatabase {
}
#[tracing::instrument(skip(self))]
#[allow(clippy::type_complexity)]
#[expect(clippy::type_complexity)]
fn search_pdus<'a>(
&'a self,
room_id: &RoomId,

View file

@ -482,7 +482,7 @@ impl service::rooms::state_cache::Data for KeyValueDatabase {
}
/// Returns an iterator over all rooms a user was invited to.
#[allow(clippy::type_complexity)]
#[expect(clippy::type_complexity)]
#[tracing::instrument(skip(self))]
fn rooms_invited<'a>(
&'a self,
@ -575,7 +575,7 @@ impl service::rooms::state_cache::Data for KeyValueDatabase {
}
/// Returns an iterator over all rooms a user left.
#[allow(clippy::type_complexity)]
#[expect(clippy::type_complexity)]
#[tracing::instrument(skip(self))]
fn rooms_left<'a>(
&'a self,