From 8214737f1de8b8ec3939023dd620288eddfc06c3 Mon Sep 17 00:00:00 2001 From: Christopher Berner Date: Tue, 5 Nov 2024 07:16:36 -0800 Subject: [PATCH] Fix Clippy errors --- benches/syscall_benchmark.rs | 3 +++ benches/userspace_cache_benchmark.rs | 2 ++ examples/special_values.rs | 1 + src/tree_store/page_store/header.rs | 5 ++++- tests/basic_tests.rs | 2 +- 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/benches/syscall_benchmark.rs b/benches/syscall_benchmark.rs index 18503b30..ae06837d 100644 --- a/benches/syscall_benchmark.rs +++ b/benches/syscall_benchmark.rs @@ -119,6 +119,7 @@ fn uring_bench(path: &Path) { let mut file = OpenOptions::new() .read(true) .write(true) + .truncate(true) .create(true) .open(path) .unwrap(); @@ -206,6 +207,7 @@ fn readwrite_bench(path: &Path) { let mut file = OpenOptions::new() .read(true) .write(true) + .truncate(true) .create(true) .open(path) .unwrap(); @@ -268,6 +270,7 @@ fn mmap_bench(path: &Path) { let file = OpenOptions::new() .read(true) .write(true) + .truncate(true) .create(true) .open(path) .unwrap(); diff --git a/benches/userspace_cache_benchmark.rs b/benches/userspace_cache_benchmark.rs index 95ebd1cb..a1335586 100644 --- a/benches/userspace_cache_benchmark.rs +++ b/benches/userspace_cache_benchmark.rs @@ -111,6 +111,7 @@ mod unix { let file = OpenOptions::new() .read(true) .write(true) + .truncate(true) .create(true) .open(path) .unwrap(); @@ -350,6 +351,7 @@ mod unix { let file = OpenOptions::new() .read(true) .write(true) + .truncate(true) .create(true) .open(path) .unwrap(); diff --git a/examples/special_values.rs b/examples/special_values.rs index 9b5a1092..b4191339 100644 --- a/examples/special_values.rs +++ b/examples/special_values.rs @@ -19,6 +19,7 @@ impl SpecialValuesDb { database: Database::create("index.redb").unwrap(), file: OpenOptions::new() .write(true) + .truncate(true) .create(true) .read(true) .open("values.dat") diff --git a/src/tree_store/page_store/header.rs b/src/tree_store/page_store/header.rs index cd4be9d5..40b67a88 100644 --- a/src/tree_store/page_store/header.rs +++ b/src/tree_store/page_store/header.rs @@ -654,7 +654,10 @@ mod test { // IETF Memo "Care and Feeding of Magic Numbers" // Test that magic number is not valid utf-8 - assert!(std::str::from_utf8(&MAGICNUMBER).is_err()); + #[allow(invalid_from_utf8)] + { + assert!(std::str::from_utf8(&MAGICNUMBER).is_err()); + } // Test there is a octet with high-bit set assert!(MAGICNUMBER.iter().any(|x| *x & 0x80 != 0)); // Test there is a non-printable ASCII character diff --git a/tests/basic_tests.rs b/tests/basic_tests.rs index 8a0c1d60..99f96788 100644 --- a/tests/basic_tests.rs +++ b/tests/basic_tests.rs @@ -190,7 +190,7 @@ fn extract_if() { let mut table = write_txn.open_table(U64_TABLE).unwrap(); assert_eq!(table.len().unwrap(), 10); for _ in table.extract_if(|x, _| x % 2 != 0).unwrap() {} - table.extract_if(|_, _| true).unwrap().rev().next(); + table.extract_if(|_, _| true).unwrap().next_back(); } write_txn.commit().unwrap();