apply clippy fixes

This commit is contained in:
Dustin J. Mitchell 2022-12-23 18:56:58 +00:00 committed by Dustin J. Mitchell
parent 88333ac785
commit f1e1095c0a
6 changed files with 32 additions and 32 deletions

View file

@ -36,7 +36,7 @@ fn make_suite_file(suites: &[&'static str]) {
for suite in suites { for suite in suites {
content.push_str(format!("suite!({}_tests);\n", suite).as_ref()); content.push_str(format!("suite!({}_tests);\n", suite).as_ref());
} }
fs::write(&dest_path, content).unwrap(); fs::write(dest_path, content).unwrap();
} }
fn main() { fn main() {

View file

@ -23,7 +23,7 @@ impl PassByValue for libc::time_t {
if self == 0 { if self == 0 {
None None
} else { } else {
Some(Utc.timestamp(self as i64, 0)) Some(Utc.timestamp(self, 0))
} }
} }

View file

@ -349,7 +349,7 @@ pub unsafe extern "C" fn tc_replica_undo(rep: *mut TCReplica, undone_out: *mut i
wrap( wrap(
rep, rep,
|rep| { |rep| {
let undone = if rep.undo()? { 1 } else { 0 }; let undone = i32::from(rep.undo()?);
if !undone_out.is_null() { if !undone_out.is_null() {
// SAFETY: // SAFETY:
// - undone_out is not NULL (just checked) // - undone_out is not NULL (just checked)

View file

@ -310,7 +310,7 @@ mod test {
fn test_emtpy_dir() -> anyhow::Result<()> { fn test_emtpy_dir() -> anyhow::Result<()> {
let tmp_dir = TempDir::new()?; let tmp_dir = TempDir::new()?;
let non_existant = tmp_dir.path().join("subdir"); 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 mut txn = storage.txn()?;
let maybe_client = txn.get_client(Uuid::new_v4())?; let maybe_client = txn.get_client(Uuid::new_v4())?;
assert!(maybe_client.is_none()); assert!(maybe_client.is_none());
@ -320,7 +320,7 @@ mod test {
#[test] #[test]
fn test_get_client_empty() -> anyhow::Result<()> { fn test_get_client_empty() -> anyhow::Result<()> {
let tmp_dir = TempDir::new()?; 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 mut txn = storage.txn()?;
let maybe_client = txn.get_client(Uuid::new_v4())?; let maybe_client = txn.get_client(Uuid::new_v4())?;
assert!(maybe_client.is_none()); assert!(maybe_client.is_none());
@ -330,7 +330,7 @@ mod test {
#[test] #[test]
fn test_client_storage() -> anyhow::Result<()> { fn test_client_storage() -> anyhow::Result<()> {
let tmp_dir = TempDir::new()?; 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 mut txn = storage.txn()?;
let client_key = Uuid::new_v4(); let client_key = Uuid::new_v4();
@ -365,7 +365,7 @@ mod test {
#[test] #[test]
fn test_gvbp_empty() -> anyhow::Result<()> { fn test_gvbp_empty() -> anyhow::Result<()> {
let tmp_dir = TempDir::new()?; 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 mut txn = storage.txn()?;
let maybe_version = txn.get_version_by_parent(Uuid::new_v4(), Uuid::new_v4())?; let maybe_version = txn.get_version_by_parent(Uuid::new_v4(), Uuid::new_v4())?;
assert!(maybe_version.is_none()); assert!(maybe_version.is_none());
@ -375,7 +375,7 @@ mod test {
#[test] #[test]
fn test_add_version_and_get_version() -> anyhow::Result<()> { fn test_add_version_and_get_version() -> anyhow::Result<()> {
let tmp_dir = TempDir::new()?; 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 mut txn = storage.txn()?;
let client_key = Uuid::new_v4(); let client_key = Uuid::new_v4();
@ -409,7 +409,7 @@ mod test {
#[test] #[test]
fn test_snapshots() -> anyhow::Result<()> { fn test_snapshots() -> anyhow::Result<()> {
let tmp_dir = TempDir::new()?; 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 mut txn = storage.txn()?;
let client_key = Uuid::new_v4(); let client_key = Uuid::new_v4();

View file

@ -32,7 +32,7 @@ impl LocalServer {
let db_file = directory let db_file = directory
.as_ref() .as_ref()
.join("taskchampion-local-sync-server.sqlite3"); .join("taskchampion-local-sync-server.sqlite3");
let con = rusqlite::Connection::open(&db_file)?; let con = rusqlite::Connection::open(db_file)?;
let queries = vec![ let queries = vec![
"CREATE TABLE IF NOT EXISTS data (key STRING PRIMARY KEY, value STRING);", "CREATE TABLE IF NOT EXISTS data (key STRING PRIMARY KEY, value STRING);",
@ -175,7 +175,7 @@ mod test {
#[test] #[test]
fn test_empty() -> anyhow::Result<()> { fn test_empty() -> anyhow::Result<()> {
let tmp_dir = TempDir::new()?; 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)?; let child_version = server.get_child_version(NIL_VERSION_ID)?;
assert_eq!(child_version, GetVersionResult::NoSuchVersion); assert_eq!(child_version, GetVersionResult::NoSuchVersion);
Ok(()) Ok(())
@ -184,7 +184,7 @@ mod test {
#[test] #[test]
fn test_add_zero_base() -> anyhow::Result<()> { fn test_add_zero_base() -> anyhow::Result<()> {
let tmp_dir = TempDir::new()?; 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 history = b"1234".to_vec();
match server.add_version(NIL_VERSION_ID, history.clone())?.0 { match server.add_version(NIL_VERSION_ID, history.clone())?.0 {
AddVersionResult::ExpectedParentVersion(_) => { AddVersionResult::ExpectedParentVersion(_) => {
@ -209,7 +209,7 @@ mod test {
#[test] #[test]
fn test_add_nonzero_base() -> anyhow::Result<()> { fn test_add_nonzero_base() -> anyhow::Result<()> {
let tmp_dir = TempDir::new()?; 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 history = b"1234".to_vec();
let parent_version_id = Uuid::new_v4() as VersionId; let parent_version_id = Uuid::new_v4() as VersionId;
@ -237,7 +237,7 @@ mod test {
#[test] #[test]
fn test_add_nonzero_base_forbidden() -> anyhow::Result<()> { fn test_add_nonzero_base_forbidden() -> anyhow::Result<()> {
let tmp_dir = TempDir::new()?; 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 history = b"1234".to_vec();
let parent_version_id = Uuid::new_v4() as VersionId; let parent_version_id = Uuid::new_v4() as VersionId;

View file

@ -317,7 +317,7 @@ impl<'t> StorageTxn for Txn<'t> {
} }
for r in rows { for r in rows {
let (id, uuid) = r?; let (id, uuid) = r?;
res[id as usize] = Some(uuid); res[id] = Some(uuid);
} }
Ok(res) Ok(res)
@ -380,7 +380,7 @@ mod test {
fn test_empty_dir() -> anyhow::Result<()> { fn test_empty_dir() -> anyhow::Result<()> {
let tmp_dir = TempDir::new()?; let tmp_dir = TempDir::new()?;
let non_existant = tmp_dir.path().join("subdir"); 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 uuid = Uuid::new_v4();
{ {
let mut txn = storage.txn()?; let mut txn = storage.txn()?;
@ -398,7 +398,7 @@ mod test {
#[test] #[test]
fn drop_transaction() -> anyhow::Result<()> { fn drop_transaction() -> anyhow::Result<()> {
let tmp_dir = TempDir::new()?; 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 uuid1 = Uuid::new_v4();
let uuid2 = Uuid::new_v4(); let uuid2 = Uuid::new_v4();
@ -427,7 +427,7 @@ mod test {
#[test] #[test]
fn test_create() -> anyhow::Result<()> { fn test_create() -> anyhow::Result<()> {
let tmp_dir = TempDir::new()?; 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 uuid = Uuid::new_v4();
{ {
let mut txn = storage.txn()?; let mut txn = storage.txn()?;
@ -445,7 +445,7 @@ mod test {
#[test] #[test]
fn test_create_exists() -> anyhow::Result<()> { fn test_create_exists() -> anyhow::Result<()> {
let tmp_dir = TempDir::new()?; 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 uuid = Uuid::new_v4();
{ {
let mut txn = storage.txn()?; let mut txn = storage.txn()?;
@ -463,7 +463,7 @@ mod test {
#[test] #[test]
fn test_get_missing() -> anyhow::Result<()> { fn test_get_missing() -> anyhow::Result<()> {
let tmp_dir = TempDir::new()?; 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 uuid = Uuid::new_v4();
{ {
let mut txn = storage.txn()?; let mut txn = storage.txn()?;
@ -476,7 +476,7 @@ mod test {
#[test] #[test]
fn test_set_task() -> anyhow::Result<()> { fn test_set_task() -> anyhow::Result<()> {
let tmp_dir = TempDir::new()?; 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 uuid = Uuid::new_v4();
{ {
let mut txn = storage.txn()?; let mut txn = storage.txn()?;
@ -497,7 +497,7 @@ mod test {
#[test] #[test]
fn test_delete_task_missing() -> anyhow::Result<()> { fn test_delete_task_missing() -> anyhow::Result<()> {
let tmp_dir = TempDir::new()?; 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 uuid = Uuid::new_v4();
{ {
let mut txn = storage.txn()?; let mut txn = storage.txn()?;
@ -509,7 +509,7 @@ mod test {
#[test] #[test]
fn test_delete_task_exists() -> anyhow::Result<()> { fn test_delete_task_exists() -> anyhow::Result<()> {
let tmp_dir = TempDir::new()?; 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 uuid = Uuid::new_v4();
{ {
let mut txn = storage.txn()?; let mut txn = storage.txn()?;
@ -526,7 +526,7 @@ mod test {
#[test] #[test]
fn test_all_tasks_empty() -> anyhow::Result<()> { fn test_all_tasks_empty() -> anyhow::Result<()> {
let tmp_dir = TempDir::new()?; 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 mut txn = storage.txn()?;
let tasks = txn.all_tasks()?; let tasks = txn.all_tasks()?;
@ -538,7 +538,7 @@ mod test {
#[test] #[test]
fn test_all_tasks_and_uuids() -> anyhow::Result<()> { fn test_all_tasks_and_uuids() -> anyhow::Result<()> {
let tmp_dir = TempDir::new()?; 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 uuid1 = Uuid::new_v4();
let uuid2 = Uuid::new_v4(); let uuid2 = Uuid::new_v4();
{ {
@ -592,7 +592,7 @@ mod test {
#[test] #[test]
fn test_base_version_default() -> anyhow::Result<()> { fn test_base_version_default() -> anyhow::Result<()> {
let tmp_dir = TempDir::new()?; 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 mut txn = storage.txn()?;
assert_eq!(txn.base_version()?, DEFAULT_BASE_VERSION); assert_eq!(txn.base_version()?, DEFAULT_BASE_VERSION);
@ -603,7 +603,7 @@ mod test {
#[test] #[test]
fn test_base_version_setting() -> anyhow::Result<()> { fn test_base_version_setting() -> anyhow::Result<()> {
let tmp_dir = TempDir::new()?; 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 u = Uuid::new_v4();
{ {
let mut txn = storage.txn()?; let mut txn = storage.txn()?;
@ -620,7 +620,7 @@ mod test {
#[test] #[test]
fn test_operations() -> anyhow::Result<()> { fn test_operations() -> anyhow::Result<()> {
let tmp_dir = TempDir::new()?; 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 uuid1 = Uuid::new_v4();
let uuid2 = Uuid::new_v4(); let uuid2 = Uuid::new_v4();
let uuid3 = Uuid::new_v4(); let uuid3 = Uuid::new_v4();
@ -705,7 +705,7 @@ mod test {
#[test] #[test]
fn get_working_set_empty() -> anyhow::Result<()> { fn get_working_set_empty() -> anyhow::Result<()> {
let tmp_dir = TempDir::new()?; 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 mut txn = storage.txn()?;
@ -719,7 +719,7 @@ mod test {
#[test] #[test]
fn add_to_working_set() -> anyhow::Result<()> { fn add_to_working_set() -> anyhow::Result<()> {
let tmp_dir = TempDir::new()?; 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 uuid1 = Uuid::new_v4();
let uuid2 = Uuid::new_v4(); let uuid2 = Uuid::new_v4();
@ -742,7 +742,7 @@ mod test {
#[test] #[test]
fn clear_working_set() -> anyhow::Result<()> { fn clear_working_set() -> anyhow::Result<()> {
let tmp_dir = TempDir::new()?; 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 uuid1 = Uuid::new_v4();
let uuid2 = Uuid::new_v4(); let uuid2 = Uuid::new_v4();
@ -773,7 +773,7 @@ mod test {
#[test] #[test]
fn set_working_set_item() -> anyhow::Result<()> { fn set_working_set_item() -> anyhow::Result<()> {
let tmp_dir = TempDir::new()?; 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 uuid1 = Uuid::new_v4();
let uuid2 = Uuid::new_v4(); let uuid2 = Uuid::new_v4();