From f1e1095c0a02c4b1e9ca7ec0a0aa84247654562a Mon Sep 17 00:00:00 2001 From: "Dustin J. Mitchell" Date: Fri, 23 Dec 2022 18:56:58 +0000 Subject: [PATCH] apply clippy fixes --- taskchampion/integration-tests/build.rs | 2 +- taskchampion/lib/src/atomic.rs | 2 +- taskchampion/lib/src/replica.rs | 2 +- .../sync-server/src/storage/sqlite.rs | 12 +++---- taskchampion/taskchampion/src/server/local.rs | 10 +++--- .../taskchampion/src/storage/sqlite.rs | 36 +++++++++---------- 6 files changed, 32 insertions(+), 32 deletions(-) diff --git a/taskchampion/integration-tests/build.rs b/taskchampion/integration-tests/build.rs index deb72448c..ed87f40e7 100644 --- a/taskchampion/integration-tests/build.rs +++ b/taskchampion/integration-tests/build.rs @@ -36,7 +36,7 @@ fn make_suite_file(suites: &[&'static str]) { for suite in suites { content.push_str(format!("suite!({}_tests);\n", suite).as_ref()); } - fs::write(&dest_path, content).unwrap(); + fs::write(dest_path, content).unwrap(); } fn main() { diff --git a/taskchampion/lib/src/atomic.rs b/taskchampion/lib/src/atomic.rs index 21f7bc282..34e28bb36 100644 --- a/taskchampion/lib/src/atomic.rs +++ b/taskchampion/lib/src/atomic.rs @@ -23,7 +23,7 @@ impl PassByValue for libc::time_t { if self == 0 { None } else { - Some(Utc.timestamp(self as i64, 0)) + Some(Utc.timestamp(self, 0)) } } diff --git a/taskchampion/lib/src/replica.rs b/taskchampion/lib/src/replica.rs index d97b679b2..d6a805183 100644 --- a/taskchampion/lib/src/replica.rs +++ b/taskchampion/lib/src/replica.rs @@ -349,7 +349,7 @@ pub unsafe extern "C" fn tc_replica_undo(rep: *mut TCReplica, undone_out: *mut i wrap( rep, |rep| { - let undone = if rep.undo()? { 1 } else { 0 }; + let undone = i32::from(rep.undo()?); if !undone_out.is_null() { // SAFETY: // - undone_out is not NULL (just checked) diff --git a/taskchampion/sync-server/src/storage/sqlite.rs b/taskchampion/sync-server/src/storage/sqlite.rs index 47a07014a..b738a4008 100644 --- a/taskchampion/sync-server/src/storage/sqlite.rs +++ b/taskchampion/sync-server/src/storage/sqlite.rs @@ -310,7 +310,7 @@ mod test { fn test_emtpy_dir() -> anyhow::Result<()> { let tmp_dir = TempDir::new()?; let non_existant = tmp_dir.path().join("subdir"); - let storage = SqliteStorage::new(&non_existant)?; + let storage = SqliteStorage::new(non_existant)?; let mut txn = storage.txn()?; let maybe_client = txn.get_client(Uuid::new_v4())?; assert!(maybe_client.is_none()); @@ -320,7 +320,7 @@ mod test { #[test] fn test_get_client_empty() -> anyhow::Result<()> { let tmp_dir = TempDir::new()?; - let storage = SqliteStorage::new(&tmp_dir.path())?; + let storage = SqliteStorage::new(tmp_dir.path())?; let mut txn = storage.txn()?; let maybe_client = txn.get_client(Uuid::new_v4())?; assert!(maybe_client.is_none()); @@ -330,7 +330,7 @@ mod test { #[test] fn test_client_storage() -> anyhow::Result<()> { let tmp_dir = TempDir::new()?; - let storage = SqliteStorage::new(&tmp_dir.path())?; + let storage = SqliteStorage::new(tmp_dir.path())?; let mut txn = storage.txn()?; let client_key = Uuid::new_v4(); @@ -365,7 +365,7 @@ mod test { #[test] fn test_gvbp_empty() -> anyhow::Result<()> { let tmp_dir = TempDir::new()?; - let storage = SqliteStorage::new(&tmp_dir.path())?; + let storage = SqliteStorage::new(tmp_dir.path())?; let mut txn = storage.txn()?; let maybe_version = txn.get_version_by_parent(Uuid::new_v4(), Uuid::new_v4())?; assert!(maybe_version.is_none()); @@ -375,7 +375,7 @@ mod test { #[test] fn test_add_version_and_get_version() -> anyhow::Result<()> { let tmp_dir = TempDir::new()?; - let storage = SqliteStorage::new(&tmp_dir.path())?; + let storage = SqliteStorage::new(tmp_dir.path())?; let mut txn = storage.txn()?; let client_key = Uuid::new_v4(); @@ -409,7 +409,7 @@ mod test { #[test] fn test_snapshots() -> anyhow::Result<()> { let tmp_dir = TempDir::new()?; - let storage = SqliteStorage::new(&tmp_dir.path())?; + let storage = SqliteStorage::new(tmp_dir.path())?; let mut txn = storage.txn()?; let client_key = Uuid::new_v4(); diff --git a/taskchampion/taskchampion/src/server/local.rs b/taskchampion/taskchampion/src/server/local.rs index f50297bf6..13033c8ed 100644 --- a/taskchampion/taskchampion/src/server/local.rs +++ b/taskchampion/taskchampion/src/server/local.rs @@ -32,7 +32,7 @@ impl LocalServer { let db_file = directory .as_ref() .join("taskchampion-local-sync-server.sqlite3"); - let con = rusqlite::Connection::open(&db_file)?; + let con = rusqlite::Connection::open(db_file)?; let queries = vec![ "CREATE TABLE IF NOT EXISTS data (key STRING PRIMARY KEY, value STRING);", @@ -175,7 +175,7 @@ mod test { #[test] fn test_empty() -> anyhow::Result<()> { let tmp_dir = TempDir::new()?; - let mut server = LocalServer::new(&tmp_dir.path())?; + let mut server = LocalServer::new(tmp_dir.path())?; let child_version = server.get_child_version(NIL_VERSION_ID)?; assert_eq!(child_version, GetVersionResult::NoSuchVersion); Ok(()) @@ -184,7 +184,7 @@ mod test { #[test] fn test_add_zero_base() -> anyhow::Result<()> { let tmp_dir = TempDir::new()?; - let mut server = LocalServer::new(&tmp_dir.path())?; + let mut server = LocalServer::new(tmp_dir.path())?; let history = b"1234".to_vec(); match server.add_version(NIL_VERSION_ID, history.clone())?.0 { AddVersionResult::ExpectedParentVersion(_) => { @@ -209,7 +209,7 @@ mod test { #[test] fn test_add_nonzero_base() -> anyhow::Result<()> { let tmp_dir = TempDir::new()?; - let mut server = LocalServer::new(&tmp_dir.path())?; + let mut server = LocalServer::new(tmp_dir.path())?; let history = b"1234".to_vec(); let parent_version_id = Uuid::new_v4() as VersionId; @@ -237,7 +237,7 @@ mod test { #[test] fn test_add_nonzero_base_forbidden() -> anyhow::Result<()> { let tmp_dir = TempDir::new()?; - let mut server = LocalServer::new(&tmp_dir.path())?; + let mut server = LocalServer::new(tmp_dir.path())?; let history = b"1234".to_vec(); let parent_version_id = Uuid::new_v4() as VersionId; diff --git a/taskchampion/taskchampion/src/storage/sqlite.rs b/taskchampion/taskchampion/src/storage/sqlite.rs index cfc7bdd83..474174c1e 100644 --- a/taskchampion/taskchampion/src/storage/sqlite.rs +++ b/taskchampion/taskchampion/src/storage/sqlite.rs @@ -317,7 +317,7 @@ impl<'t> StorageTxn for Txn<'t> { } for r in rows { let (id, uuid) = r?; - res[id as usize] = Some(uuid); + res[id] = Some(uuid); } Ok(res) @@ -380,7 +380,7 @@ mod test { fn test_empty_dir() -> anyhow::Result<()> { let tmp_dir = TempDir::new()?; let non_existant = tmp_dir.path().join("subdir"); - let mut storage = SqliteStorage::new(&non_existant, true)?; + let mut storage = SqliteStorage::new(non_existant, true)?; let uuid = Uuid::new_v4(); { let mut txn = storage.txn()?; @@ -398,7 +398,7 @@ mod test { #[test] fn drop_transaction() -> anyhow::Result<()> { let tmp_dir = TempDir::new()?; - let mut storage = SqliteStorage::new(&tmp_dir.path(), true)?; + let mut storage = SqliteStorage::new(tmp_dir.path(), true)?; let uuid1 = Uuid::new_v4(); let uuid2 = Uuid::new_v4(); @@ -427,7 +427,7 @@ mod test { #[test] fn test_create() -> anyhow::Result<()> { let tmp_dir = TempDir::new()?; - let mut storage = SqliteStorage::new(&tmp_dir.path(), true)?; + let mut storage = SqliteStorage::new(tmp_dir.path(), true)?; let uuid = Uuid::new_v4(); { let mut txn = storage.txn()?; @@ -445,7 +445,7 @@ mod test { #[test] fn test_create_exists() -> anyhow::Result<()> { let tmp_dir = TempDir::new()?; - let mut storage = SqliteStorage::new(&tmp_dir.path(), true)?; + let mut storage = SqliteStorage::new(tmp_dir.path(), true)?; let uuid = Uuid::new_v4(); { let mut txn = storage.txn()?; @@ -463,7 +463,7 @@ mod test { #[test] fn test_get_missing() -> anyhow::Result<()> { let tmp_dir = TempDir::new()?; - let mut storage = SqliteStorage::new(&tmp_dir.path(), true)?; + let mut storage = SqliteStorage::new(tmp_dir.path(), true)?; let uuid = Uuid::new_v4(); { let mut txn = storage.txn()?; @@ -476,7 +476,7 @@ mod test { #[test] fn test_set_task() -> anyhow::Result<()> { let tmp_dir = TempDir::new()?; - let mut storage = SqliteStorage::new(&tmp_dir.path(), true)?; + let mut storage = SqliteStorage::new(tmp_dir.path(), true)?; let uuid = Uuid::new_v4(); { let mut txn = storage.txn()?; @@ -497,7 +497,7 @@ mod test { #[test] fn test_delete_task_missing() -> anyhow::Result<()> { let tmp_dir = TempDir::new()?; - let mut storage = SqliteStorage::new(&tmp_dir.path(), true)?; + let mut storage = SqliteStorage::new(tmp_dir.path(), true)?; let uuid = Uuid::new_v4(); { let mut txn = storage.txn()?; @@ -509,7 +509,7 @@ mod test { #[test] fn test_delete_task_exists() -> anyhow::Result<()> { let tmp_dir = TempDir::new()?; - let mut storage = SqliteStorage::new(&tmp_dir.path(), true)?; + let mut storage = SqliteStorage::new(tmp_dir.path(), true)?; let uuid = Uuid::new_v4(); { let mut txn = storage.txn()?; @@ -526,7 +526,7 @@ mod test { #[test] fn test_all_tasks_empty() -> anyhow::Result<()> { let tmp_dir = TempDir::new()?; - let mut storage = SqliteStorage::new(&tmp_dir.path(), true)?; + let mut storage = SqliteStorage::new(tmp_dir.path(), true)?; { let mut txn = storage.txn()?; let tasks = txn.all_tasks()?; @@ -538,7 +538,7 @@ mod test { #[test] fn test_all_tasks_and_uuids() -> anyhow::Result<()> { let tmp_dir = TempDir::new()?; - let mut storage = SqliteStorage::new(&tmp_dir.path(), true)?; + let mut storage = SqliteStorage::new(tmp_dir.path(), true)?; let uuid1 = Uuid::new_v4(); let uuid2 = Uuid::new_v4(); { @@ -592,7 +592,7 @@ mod test { #[test] fn test_base_version_default() -> anyhow::Result<()> { let tmp_dir = TempDir::new()?; - let mut storage = SqliteStorage::new(&tmp_dir.path(), true)?; + let mut storage = SqliteStorage::new(tmp_dir.path(), true)?; { let mut txn = storage.txn()?; assert_eq!(txn.base_version()?, DEFAULT_BASE_VERSION); @@ -603,7 +603,7 @@ mod test { #[test] fn test_base_version_setting() -> anyhow::Result<()> { let tmp_dir = TempDir::new()?; - let mut storage = SqliteStorage::new(&tmp_dir.path(), true)?; + let mut storage = SqliteStorage::new(tmp_dir.path(), true)?; let u = Uuid::new_v4(); { let mut txn = storage.txn()?; @@ -620,7 +620,7 @@ mod test { #[test] fn test_operations() -> anyhow::Result<()> { let tmp_dir = TempDir::new()?; - let mut storage = SqliteStorage::new(&tmp_dir.path(), true)?; + let mut storage = SqliteStorage::new(tmp_dir.path(), true)?; let uuid1 = Uuid::new_v4(); let uuid2 = Uuid::new_v4(); let uuid3 = Uuid::new_v4(); @@ -705,7 +705,7 @@ mod test { #[test] fn get_working_set_empty() -> anyhow::Result<()> { let tmp_dir = TempDir::new()?; - let mut storage = SqliteStorage::new(&tmp_dir.path(), true)?; + let mut storage = SqliteStorage::new(tmp_dir.path(), true)?; { let mut txn = storage.txn()?; @@ -719,7 +719,7 @@ mod test { #[test] fn add_to_working_set() -> anyhow::Result<()> { let tmp_dir = TempDir::new()?; - let mut storage = SqliteStorage::new(&tmp_dir.path(), true)?; + let mut storage = SqliteStorage::new(tmp_dir.path(), true)?; let uuid1 = Uuid::new_v4(); let uuid2 = Uuid::new_v4(); @@ -742,7 +742,7 @@ mod test { #[test] fn clear_working_set() -> anyhow::Result<()> { let tmp_dir = TempDir::new()?; - let mut storage = SqliteStorage::new(&tmp_dir.path(), true)?; + let mut storage = SqliteStorage::new(tmp_dir.path(), true)?; let uuid1 = Uuid::new_v4(); let uuid2 = Uuid::new_v4(); @@ -773,7 +773,7 @@ mod test { #[test] fn set_working_set_item() -> anyhow::Result<()> { let tmp_dir = TempDir::new()?; - let mut storage = SqliteStorage::new(&tmp_dir.path(), true)?; + let mut storage = SqliteStorage::new(tmp_dir.path(), true)?; let uuid1 = Uuid::new_v4(); let uuid2 = Uuid::new_v4();