From a00acd23a6dbf0097fbdcc6118fc7bca358b8b98 Mon Sep 17 00:00:00 2001 From: gwenn Date: Thu, 5 Sep 2024 20:51:58 +0200 Subject: [PATCH] Use #[expect(lint)] where possible --- examples/loadable_extension.rs | 2 +- libsqlite3-sys/src/lib.rs | 3 +-- src/backup.rs | 5 +++-- src/blob/mod.rs | 2 +- src/cache.rs | 2 -- src/collation.rs | 2 +- src/config.rs | 3 +-- src/error.rs | 3 --- src/functions.rs | 6 +++--- src/hooks/mod.rs | 3 +-- src/hooks/preupdate_hook.rs | 4 ++-- src/inner_connection.rs | 5 ++--- src/lib.rs | 16 +++++----------- src/limits.rs | 2 +- src/load_extension_guard.rs | 2 +- src/row.rs | 6 +++--- src/session.rs | 10 +++++----- src/statement.rs | 8 ++++---- src/transaction.rs | 4 ++-- src/types/mod.rs | 4 ++-- src/unlock_notify.rs | 2 +- src/vtab/mod.rs | 5 ++--- src/vtab/series.rs | 4 ++-- 23 files changed, 44 insertions(+), 59 deletions(-) diff --git a/examples/loadable_extension.rs b/examples/loadable_extension.rs index 5aba2da..e596ea5 100644 --- a/examples/loadable_extension.rs +++ b/examples/loadable_extension.rs @@ -18,7 +18,7 @@ use rusqlite::{Connection, Result}; /// sqlite> SELECT rusqlite_test_function(); /// Rusqlite extension loaded correctly! /// ``` -#[allow(clippy::not_unsafe_ptr_arg_deref)] +#[expect(clippy::not_unsafe_ptr_arg_deref)] #[no_mangle] pub unsafe extern "C" fn sqlite3_extension_init( db: *mut ffi::sqlite3, diff --git a/libsqlite3-sys/src/lib.rs b/libsqlite3-sys/src/lib.rs index 75c031d..7682776 100644 --- a/libsqlite3-sys/src/lib.rs +++ b/libsqlite3-sys/src/lib.rs @@ -1,5 +1,4 @@ -#![allow(non_snake_case, non_camel_case_types)] -#![cfg_attr(test, allow(deref_nullptr))] // https://github.com/rust-lang/rust-bindgen/issues/2066 +#![expect(non_snake_case, non_camel_case_types)] // force linking to openssl #[cfg(feature = "bundled-sqlcipher-vendored-openssl")] diff --git a/src/backup.rs b/src/backup.rs index 3f983dd..bba0555 100644 --- a/src/backup.rs +++ b/src/backup.rs @@ -155,8 +155,9 @@ pub enum StepResult { Locked, } -/// Struct specifying the progress of a backup. The -/// percentage completion can be calculated as `(pagecount - remaining) / +/// Struct specifying the progress of a backup. +/// +/// The percentage completion can be calculated as `(pagecount - remaining) / /// pagecount`. The progress of a backup is as of the last call to /// [`step`](Backup::step) - if the source database is modified after a call to /// [`step`](Backup::step), the progress value will become outdated and diff --git a/src/blob/mod.rs b/src/blob/mod.rs index 6200bdb..4f0a245 100644 --- a/src/blob/mod.rs +++ b/src/blob/mod.rs @@ -393,7 +393,7 @@ impl io::Seek for Blob<'_> { } } -#[allow(unused_must_use)] +#[expect(unused_must_use)] impl Drop for Blob<'_> { #[inline] fn drop(&mut self) { diff --git a/src/cache.rs b/src/cache.rs index bf653b8..342dbac 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -60,7 +60,6 @@ impl Connection { #[derive(Debug)] pub struct StatementCache(RefCell, RawStatement>>); -#[allow(clippy::non_send_fields_in_send_ty)] unsafe impl Send for StatementCache {} /// Cacheable statement. @@ -90,7 +89,6 @@ impl<'conn> DerefMut for CachedStatement<'conn> { } impl Drop for CachedStatement<'_> { - #[allow(unused_must_use)] #[inline] fn drop(&mut self) { if let Some(stmt) = self.stmt.take() { diff --git a/src/collation.rs b/src/collation.rs index 272d7b1..8f58950 100644 --- a/src/collation.rs +++ b/src/collation.rs @@ -129,7 +129,7 @@ impl InnerConnection { x_coll_needed: fn(&Connection, &str) -> Result<()>, ) -> Result<()> { use std::mem; - #[allow(clippy::needless_return)] + #[expect(clippy::needless_return)] unsafe extern "C" fn collation_needed_callback( arg1: *mut c_void, arg2: *mut ffi::sqlite3, diff --git a/src/config.rs b/src/config.rs index f54724d..bc85303 100644 --- a/src/config.rs +++ b/src/config.rs @@ -10,9 +10,8 @@ use crate::{Connection, Result}; /// See [Database Connection Configuration Options](https://sqlite.org/c3ref/c_dbconfig_enable_fkey.html) for details. #[repr(i32)] #[derive(Copy, Clone, Debug)] -#[allow(non_snake_case, non_camel_case_types)] +#[expect(non_camel_case_types)] #[non_exhaustive] -#[allow(clippy::upper_case_acronyms)] pub enum DbConfig { //SQLITE_DBCONFIG_MAINDBNAME = 1000, /* const char* */ //SQLITE_DBCONFIG_LOOKASIDE = 1001, /* void* int int */ diff --git a/src/error.rs b/src/error.rs index 2a89b62..3435081 100644 --- a/src/error.rs +++ b/src/error.rs @@ -9,7 +9,6 @@ use std::str; /// Enum listing possible errors from rusqlite. #[derive(Debug)] -#[allow(clippy::enum_variant_names)] #[non_exhaustive] pub enum Error { /// An error from an underlying SQLite call. @@ -84,7 +83,6 @@ pub enum Error { /// [`create_scalar_function`](crate::Connection::create_scalar_function)). #[cfg(feature = "functions")] #[cfg_attr(docsrs, doc(cfg(feature = "functions")))] - #[allow(dead_code)] UserFunctionError(Box), /// Error available for the implementors of the @@ -98,7 +96,6 @@ pub enum Error { /// [`create_module`](crate::Connection::create_module)). #[cfg(feature = "vtab")] #[cfg_attr(docsrs, doc(cfg(feature = "vtab")))] - #[allow(dead_code)] ModuleError(String), /// An unwinding panic occurs in a UDF (user-defined function). diff --git a/src/functions.rs b/src/functions.rs index c0d67c1..6aec627 100644 --- a/src/functions.rs +++ b/src/functions.rs @@ -707,7 +707,7 @@ unsafe extern "C" fn call_boxed_step( args: slice::from_raw_parts(argv, argc as usize), }; - #[allow(clippy::unnecessary_cast)] + #[expect(clippy::unnecessary_cast)] if (*pac as *mut A).is_null() { *pac = Box::into_raw(Box::new((*boxed_aggr).init(&mut ctx)?)); } @@ -778,7 +778,7 @@ where let a: Option = match aggregate_context(ctx, 0) { Some(pac) => { - #[allow(clippy::unnecessary_cast)] + #[expect(clippy::unnecessary_cast)] if (*pac as *mut A).is_null() { None } else { @@ -818,7 +818,7 @@ where // Within the xValue callback, it is customary to set N=0 in calls to // sqlite3_aggregate_context(C,N) so that no pointless memory allocations occur. let pac = aggregate_context(ctx, 0).filter(|&pac| { - #[allow(clippy::unnecessary_cast)] + #[expect(clippy::unnecessary_cast)] !(*pac as *mut A).is_null() }); diff --git a/src/hooks/mod.rs b/src/hooks/mod.rs index 3022a32..c7ab248 100644 --- a/src/hooks/mod.rs +++ b/src/hooks/mod.rs @@ -1,5 +1,5 @@ //! Commit, Data Change and Rollback Notification Callbacks -#![allow(non_camel_case_types)] +#![expect(non_camel_case_types)] use std::os::raw::{c_char, c_int, c_void}; use std::panic::catch_unwind; @@ -19,7 +19,6 @@ mod preupdate_hook; #[derive(Clone, Copy, Debug, Eq, PartialEq)] #[repr(i32)] #[non_exhaustive] -#[allow(clippy::upper_case_acronyms)] pub enum Action { /// Unsupported / unexpected action UNKNOWN = -1, diff --git a/src/hooks/preupdate_hook.rs b/src/hooks/preupdate_hook.rs index a8f625a..59eff08 100644 --- a/src/hooks/preupdate_hook.rs +++ b/src/hooks/preupdate_hook.rs @@ -23,9 +23,9 @@ pub enum PreUpdateCase { Delete(PreUpdateOldValueAccessor), /// Pre-update hook was triggered by an update. Update { - #[allow(missing_docs)] + #[expect(missing_docs)] old_value_accessor: PreUpdateOldValueAccessor, - #[allow(missing_docs)] + #[expect(missing_docs)] new_value_accessor: PreUpdateNewValueAccessor, }, /// This variant is not normally produced by SQLite. You may encounter it diff --git a/src/inner_connection.rs b/src/inner_connection.rs index 42e61ad..4618054 100644 --- a/src/inner_connection.rs +++ b/src/inner_connection.rs @@ -41,7 +41,7 @@ pub struct InnerConnection { unsafe impl Send for InnerConnection {} impl InnerConnection { - #[allow(clippy::mutex_atomic, clippy::arc_with_non_send_sync)] // See unsafe impl Send / Sync for InterruptHandle + #[expect(clippy::mutex_atomic, clippy::arc_with_non_send_sync)] // See unsafe impl Send / Sync for InterruptHandle #[inline] pub unsafe fn new(db: *mut ffi::sqlite3, owned: bool) -> Self { Self { @@ -146,7 +146,6 @@ impl InnerConnection { } } - #[allow(clippy::mutex_atomic)] pub fn close(&mut self) -> Result<()> { if self.db.is_null() { return Ok(()); @@ -402,7 +401,7 @@ impl InnerConnection { } impl Drop for InnerConnection { - #[allow(unused_must_use)] + #[expect(unused_must_use)] #[inline] fn drop(&mut self) { self.close(); diff --git a/src/lib.rs b/src/lib.rs index 2bd324b..ea68b5c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1128,7 +1128,7 @@ impl<'conn, 'sql> Batch<'conn, 'sql> { /// Iterates on each batch statements. /// /// Returns `Ok(None)` when batch is completed. - #[allow(clippy::should_implement_trait)] // fallible iterator + #[expect(clippy::should_implement_trait)] // fallible iterator pub fn next(&mut self) -> Result>> { while self.tail < self.sql.len() { let sql = &self.sql[self.tail..]; @@ -1285,21 +1285,15 @@ mod test { // this function is never called, but is still type checked; in // particular, calls with specific instantiations will require // that those types are `Send`. - #[allow( - dead_code, - unconditional_recursion, - clippy::extra_unused_type_parameters - )] + #[allow(dead_code)] + #[expect(unconditional_recursion, clippy::extra_unused_type_parameters)] fn ensure_send() { ensure_send::(); ensure_send::(); } - #[allow( - dead_code, - unconditional_recursion, - clippy::extra_unused_type_parameters - )] + #[allow(dead_code)] + #[expect(unconditional_recursion, clippy::extra_unused_type_parameters)] fn ensure_sync() { ensure_sync::(); } diff --git a/src/limits.rs b/src/limits.rs index ef3f82d..2587b5c 100644 --- a/src/limits.rs +++ b/src/limits.rs @@ -12,7 +12,7 @@ use std::os::raw::c_int; #[derive(Copy, Clone, Debug)] #[repr(i32)] #[non_exhaustive] -#[allow(clippy::upper_case_acronyms, non_camel_case_types)] +#[expect(non_camel_case_types)] #[cfg_attr(docsrs, doc(cfg(feature = "limits")))] pub enum Limit { /// The maximum size of any string or BLOB or table row, in bytes. diff --git a/src/load_extension_guard.rs b/src/load_extension_guard.rs index deed3b4..f91d575 100644 --- a/src/load_extension_guard.rs +++ b/src/load_extension_guard.rs @@ -37,7 +37,7 @@ impl LoadExtensionGuard<'_> { } } -#[allow(unused_must_use)] +#[expect(unused_must_use)] impl Drop for LoadExtensionGuard<'_> { #[inline] fn drop(&mut self) { diff --git a/src/row.rs b/src/row.rs index 3943311..f730995 100644 --- a/src/row.rs +++ b/src/row.rs @@ -34,7 +34,7 @@ impl<'stmt> Rows<'stmt> { /// consider using [`query_map`](Statement::query_map) or /// [`query_and_then`](Statement::query_and_then) instead, which /// return types that implement `Iterator`. - #[allow(clippy::should_implement_trait)] // cannot implement Iterator + #[expect(clippy::should_implement_trait)] // cannot implement Iterator #[inline] pub fn next(&mut self) -> Result>> { self.advance()?; @@ -107,7 +107,7 @@ impl<'stmt> Rows<'stmt> { } impl Drop for Rows<'_> { - #[allow(unused_must_use)] + #[expect(unused_must_use)] #[inline] fn drop(&mut self) { self.reset(); @@ -438,7 +438,7 @@ macro_rules! tuple_try_from_row { fn try_from(row: &'a Row<'a>) -> Result { let mut index = 0; $( - #[allow(non_snake_case)] + #[expect(non_snake_case)] let $field = row.get::<_, $field>(index)?; index += 1; )* diff --git a/src/session.rs b/src/session.rs index a39de09..b53d2b1 100644 --- a/src/session.rs +++ b/src/session.rs @@ -1,5 +1,5 @@ //! [Session Extension](https://sqlite.org/sessionintro.html) -#![allow(non_camel_case_types)] +#![expect(non_camel_case_types)] use std::ffi::CStr; use std::io::{Read, Write}; @@ -662,11 +662,11 @@ impl Connection { /// Constants passed to the conflict handler /// See [here](https://sqlite.org/session.html#SQLITE_CHANGESET_CONFLICT) for details. -#[allow(missing_docs)] +#[expect(missing_docs)] #[repr(i32)] #[derive(Debug, PartialEq, Eq)] #[non_exhaustive] -#[allow(clippy::upper_case_acronyms)] +#[expect(clippy::upper_case_acronyms)] pub enum ConflictType { UNKNOWN = -1, SQLITE_CHANGESET_DATA = ffi::SQLITE_CHANGESET_DATA, @@ -690,11 +690,11 @@ impl From for ConflictType { /// Constants returned by the conflict handler /// See [here](https://sqlite.org/session.html#SQLITE_CHANGESET_ABORT) for details. -#[allow(missing_docs)] +#[expect(missing_docs)] #[repr(i32)] #[derive(Debug, PartialEq, Eq)] #[non_exhaustive] -#[allow(clippy::upper_case_acronyms)] +#[expect(clippy::upper_case_acronyms)] pub enum ConflictAction { SQLITE_CHANGESET_OMIT = ffi::SQLITE_CHANGESET_OMIT, SQLITE_CHANGESET_REPLACE = ffi::SQLITE_CHANGESET_REPLACE, diff --git a/src/statement.rs b/src/statement.rs index 4a3d104..f7b1e95 100644 --- a/src/statement.rs +++ b/src/statement.rs @@ -687,7 +687,7 @@ impl Statement<'_> { #[cfg(not(feature = "extra_check"))] #[inline] - #[allow(clippy::unnecessary_wraps)] + #[expect(clippy::unnecessary_wraps)] fn check_update(&self) -> Result<()> { Ok(()) } @@ -741,7 +741,7 @@ impl Statement<'_> { #[cfg(not(feature = "extra_check"))] #[inline] - #[allow(clippy::unnecessary_wraps)] + #[expect(clippy::unnecessary_wraps)] pub(crate) fn check_no_tail(&self) -> Result<()> { Ok(()) } @@ -778,7 +778,7 @@ impl fmt::Debug for Statement<'_> { } impl Drop for Statement<'_> { - #[allow(unused_must_use)] + #[expect(unused_must_use)] #[inline] fn drop(&mut self) { self.finalize_(); @@ -1020,7 +1020,7 @@ mod test { assert_eq!(1, doubled_id); // second row should be an `Err` - #[allow(clippy::match_wild_err_arm)] + #[expect(clippy::match_wild_err_arm)] match rows.next().unwrap() { Ok(_) => panic!("invalid Ok"), Err(Error::SqliteSingleThreadedMode) => (), diff --git a/src/transaction.rs b/src/transaction.rs index 7499f4a..ca95fcd 100644 --- a/src/transaction.rs +++ b/src/transaction.rs @@ -238,7 +238,7 @@ impl Deref for Transaction<'_> { } } -#[allow(unused_must_use)] +#[expect(unused_must_use)] impl Drop for Transaction<'_> { #[inline] fn drop(&mut self) { @@ -363,7 +363,7 @@ impl Deref for Savepoint<'_> { } } -#[allow(unused_must_use)] +#[expect(unused_must_use)] impl Drop for Savepoint<'_> { #[inline] fn drop(&mut self) { diff --git a/src/types/mod.rs b/src/types/mod.rs index c0550d3..6c840ab 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -242,7 +242,7 @@ mod test { } #[test] - #[allow(clippy::cognitive_complexity)] + #[expect(clippy::cognitive_complexity)] fn test_mismatched_types() -> Result<()> { fn is_invalid_column_type(err: Error) -> bool { matches!(err, Error::InvalidColumnType(..)) @@ -388,7 +388,7 @@ mod test { } #[test] - #[allow(clippy::float_cmp)] + #[expect(clippy::float_cmp)] fn test_numeric_conversions() -> Result<()> { // Test what happens when we store an f32 and retrieve an i32 etc. let db = Connection::open_in_memory()?; diff --git a/src/unlock_notify.rs b/src/unlock_notify.rs index 565c6cd..316fbd0 100644 --- a/src/unlock_notify.rs +++ b/src/unlock_notify.rs @@ -12,7 +12,7 @@ struct UnlockNotification { mutex: Mutex, // Mutex to protect structure } -#[allow(clippy::mutex_atomic)] +#[expect(clippy::mutex_atomic)] impl UnlockNotification { fn new() -> Self { Self { diff --git a/src/vtab/mod.rs b/src/vtab/mod.rs index eb0e56e..fed5abb 100644 --- a/src/vtab/mod.rs +++ b/src/vtab/mod.rs @@ -103,7 +103,6 @@ const ZERO_MODULE: ffi::sqlite3_module = unsafe { macro_rules! module { ($lt:lifetime, $vt:ty, $ct:ty, $xc:expr, $xd:expr, $xu:expr) => { - #[allow(clippy::needless_update)] &Module { base: ffi::sqlite3_module { // We don't use V3 @@ -322,8 +321,8 @@ pub trait UpdateVTab<'vtab>: CreateVTab<'vtab> { /// Index constraint operator. /// See [Virtual Table Constraint Operator Codes](https://sqlite.org/c3ref/c_index_constraint_eq.html) for details. #[derive(Debug, Eq, PartialEq)] -#[allow(non_snake_case, non_camel_case_types, missing_docs)] -#[allow(clippy::upper_case_acronyms)] +#[allow(missing_docs)] +#[expect(non_camel_case_types)] pub enum IndexConstraintOp { SQLITE_INDEX_CONSTRAINT_EQ, SQLITE_INDEX_CONSTRAINT_GT, diff --git a/src/vtab/series.rs b/src/vtab/series.rs index ffebcae..5c8ce2b 100644 --- a/src/vtab/series.rs +++ b/src/vtab/series.rs @@ -115,7 +115,7 @@ unsafe impl<'vtab> VTab<'vtab> for SeriesTab { } if idx_num.contains(QueryPlanFlags::BOTH) { // Both start= and stop= boundaries are available. - #[allow(clippy::bool_to_int_with_if)] + #[expect(clippy::bool_to_int_with_if)] info.set_estimated_cost(f64::from( 2 - if idx_num.contains(QueryPlanFlags::STEP) { 1 @@ -193,7 +193,7 @@ impl SeriesTabCursor<'_> { } } } -#[allow(clippy::comparison_chain)] +#[expect(clippy::comparison_chain)] unsafe impl VTabCursor for SeriesTabCursor<'_> { fn filter(&mut self, idx_num: c_int, _idx_str: Option<&str>, args: &Values<'_>) -> Result<()> { let mut idx_num = QueryPlanFlags::from_bits_truncate(idx_num);