From 548b425a1348a8fc4e920bacd565d1ffc838d5b0 Mon Sep 17 00:00:00 2001 From: cwlittle Date: Wed, 8 Feb 2023 02:26:14 -0600 Subject: [PATCH] Bump bindgen 0.63.0 -> 0.64.0 (#734) --- librocksdb-sys/Cargo.toml | 2 +- librocksdb-sys/build.rs | 23 ++++++++----------- src/db.rs | 12 ++++------ src/ffi_util.rs | 3 +-- src/transactions/optimistic_transaction_db.rs | 3 +-- src/transactions/transaction_db.rs | 8 +++---- tests/test_checkpoint.rs | 10 ++++---- tests/test_column_family.rs | 15 +++++------- tests/test_db.rs | 14 +++++------ tests/test_iterator.rs | 3 ++- tests/test_merge_operator.rs | 2 +- 11 files changed, 41 insertions(+), 54 deletions(-) diff --git a/librocksdb-sys/Cargo.toml b/librocksdb-sys/Cargo.toml index efe4a58..acbd6c6 100644 --- a/librocksdb-sys/Cargo.toml +++ b/librocksdb-sys/Cargo.toml @@ -37,6 +37,6 @@ uuid = { version = "1.0", features = ["v4"] } [build-dependencies] cc = { version = "1.0", features = ["parallel"] } -bindgen = { version = "0.63", default-features = false, features = ["runtime"] } +bindgen = { version = "0.64", default-features = false, features = ["runtime"] } glob = "0.3" pkg-config = { version = "0.3", optional = true } diff --git a/librocksdb-sys/build.rs b/librocksdb-sys/build.rs index 077fbf0..c2f6f0a 100644 --- a/librocksdb-sys/build.rs +++ b/librocksdb-sys/build.rs @@ -6,7 +6,7 @@ fn link(name: &str, bundled: bool) { let target = var("TARGET").unwrap(); let target: Vec<_> = target.split('-').collect(); if target.get(2) == Some(&"windows") { - println!("cargo:rustc-link-lib=dylib={}", name); + println!("cargo:rustc-link-lib=dylib={name}"); if bundled && target.get(3) == Some(&"gnu") { let dir = var("CARGO_MANIFEST_DIR").unwrap(); println!("cargo:rustc-link-search=native={}/{}", dir, target[0]); @@ -16,10 +16,7 @@ fn link(name: &str, bundled: bool) { fn fail_on_empty_directory(name: &str) { if fs::read_dir(name).unwrap().count() == 0 { - println!( - "The `{}` directory is empty, did you forget to pull the submodules?", - name - ); + println!("The `{name}` directory is empty, did you forget to pull the submodules?"); println!("Try `git submodule update --init --recursive`"); panic!(); } @@ -288,19 +285,19 @@ fn build_snappy() { } fn try_to_find_and_link_lib(lib_name: &str) -> bool { - println!("cargo:rerun-if-env-changed={}_COMPILE", lib_name); - if let Ok(v) = env::var(format!("{}_COMPILE", lib_name)) { + println!("cargo:rerun-if-env-changed={lib_name}_COMPILE"); + if let Ok(v) = env::var(format!("{lib_name}_COMPILE")) { if v.to_lowercase() == "true" || v == "1" { return false; } } - println!("cargo:rerun-if-env-changed={}_LIB_DIR", lib_name); - println!("cargo:rerun-if-env-changed={}_STATIC", lib_name); + println!("cargo:rerun-if-env-changed={lib_name}_LIB_DIR"); + println!("cargo:rerun-if-env-changed={lib_name}_STATIC"); - if let Ok(lib_dir) = env::var(format!("{}_LIB_DIR", lib_name)) { - println!("cargo:rustc-link-search=native={}", lib_dir); - let mode = match env::var_os(format!("{}_STATIC", lib_name)) { + if let Ok(lib_dir) = env::var(format!("{lib_name}_LIB_DIR")) { + println!("cargo:rustc-link-search=native={lib_dir}"); + let mode = match env::var_os(format!("{lib_name}_STATIC")) { Some(_) => "static", None => "dylib", }; @@ -313,7 +310,7 @@ fn try_to_find_and_link_lib(lib_name: &str) -> bool { fn cxx_standard() -> String { env::var("ROCKSDB_CXX_STD").map_or("-std=c++17".to_owned(), |cxx_std| { if !cxx_std.starts_with("-std=") { - format!("-std={}", cxx_std) + format!("-std={cxx_std}") } else { cxx_std } diff --git a/src/db.rs b/src/db.rs index efdacbb..7542b7b 100644 --- a/src/db.rs +++ b/src/db.rs @@ -603,8 +603,7 @@ impl DBWithThreadMode { if let Err(e) = fs::create_dir_all(&path) { return Err(Error::new(format!( - "Failed to create RocksDB directory: `{:?}`.", - e + "Failed to create RocksDB directory: `{e:?}`." ))); } @@ -1733,8 +1732,7 @@ impl DBCommon { Ok(prop_name) => get_property(prop_name.as_ptr()), Err(e) => { return Err(Error::new(format!( - "Failed to convert property name to CString: {}", - e + "Failed to convert property name to CString: {e}" ))); } }; @@ -1744,8 +1742,7 @@ impl DBCommon { let result = match unsafe { CStr::from_ptr(value) }.to_str() { Ok(s) => parse(s).map(|value| Some(value)), Err(e) => Err(Error::new(format!( - "Failed to convert property value to string: {}", - e + "Failed to convert property value to string: {e}" ))), }; unsafe { @@ -1787,8 +1784,7 @@ impl DBCommon { fn parse_property_int_value(value: &str) -> Result { value.parse::().map_err(|err| { Error::new(format!( - "Failed to convert property value {} to int: {}", - value, err + "Failed to convert property value {value} to int: {err}" )) }) } diff --git a/src/ffi_util.rs b/src/ffi_util.rs index fc6b459..8753673 100644 --- a/src/ffi_util.rs +++ b/src/ffi_util.rs @@ -54,8 +54,7 @@ pub(crate) fn to_cpath>(path: P) -> Result { match CString::new(path.as_ref().to_string_lossy().as_bytes()) { Ok(c) => Ok(c), Err(e) => Err(Error::new(format!( - "Failed to convert path to CString: {}", - e, + "Failed to convert path to CString: {e}" ))), } } diff --git a/src/transactions/optimistic_transaction_db.rs b/src/transactions/optimistic_transaction_db.rs index 831b976..5642594 100644 --- a/src/transactions/optimistic_transaction_db.rs +++ b/src/transactions/optimistic_transaction_db.rs @@ -134,8 +134,7 @@ impl OptimisticTransactionDB { if let Err(e) = fs::create_dir_all(&path) { return Err(Error::new(format!( - "Failed to create RocksDB directory: `{:?}`.", - e + "Failed to create RocksDB directory: `{e:?}`." ))); } diff --git a/src/transactions/transaction_db.rs b/src/transactions/transaction_db.rs index 9fb969a..92454b4 100644 --- a/src/transactions/transaction_db.rs +++ b/src/transactions/transaction_db.rs @@ -234,8 +234,7 @@ impl TransactionDB { if let Err(e) = fs::create_dir_all(&path) { return Err(Error::new(format!( - "Failed to create RocksDB directory: `{:?}`.", - e + "Failed to create RocksDB directory: `{e:?}`." ))); } @@ -360,13 +359,12 @@ impl TransactionDB { name: &str, opts: &Options, ) -> Result<*mut ffi::rocksdb_column_family_handle_t, Error> { - let cf_name = if let Ok(c) = CString::new(name.as_bytes()) { - c - } else { + let Ok(cf_name) = CString::new(name.as_bytes()) else { return Err(Error::new( "Failed to convert path to CString when creating cf".to_owned(), )); }; + Ok(unsafe { ffi_try!(ffi::rocksdb_transactiondb_create_column_family( self.inner, diff --git a/tests/test_checkpoint.rs b/tests/test_checkpoint.rs index a7668bb..adacfcb 100644 --- a/tests/test_checkpoint.rs +++ b/tests/test_checkpoint.rs @@ -24,7 +24,7 @@ pub fn test_single_checkpoint() { const PATH_PREFIX: &str = "_rust_rocksdb_cp_single_"; // Create DB with some data - let db_path = DBPath::new(&format!("{}db1", PATH_PREFIX)); + let db_path = DBPath::new(&format!("{PATH_PREFIX}db1")); let mut opts = Options::default(); opts.create_if_missing(true); @@ -37,7 +37,7 @@ pub fn test_single_checkpoint() { // Create checkpoint let cp1 = Checkpoint::new(&db).unwrap(); - let cp1_path = DBPath::new(&format!("{}cp1", PATH_PREFIX)); + let cp1_path = DBPath::new(&format!("{PATH_PREFIX}cp1")); cp1.create_checkpoint(&cp1_path).unwrap(); // Verify checkpoint @@ -54,7 +54,7 @@ pub fn test_multi_checkpoints() { const PATH_PREFIX: &str = "_rust_rocksdb_cp_multi_"; // Create DB with some data - let db_path = DBPath::new(&format!("{}db1", PATH_PREFIX)); + let db_path = DBPath::new(&format!("{PATH_PREFIX}db1")); let mut opts = Options::default(); opts.create_if_missing(true); @@ -67,7 +67,7 @@ pub fn test_multi_checkpoints() { // Create first checkpoint let cp1 = Checkpoint::new(&db).unwrap(); - let cp1_path = DBPath::new(&format!("{}cp1", PATH_PREFIX)); + let cp1_path = DBPath::new(&format!("{PATH_PREFIX}cp1")); cp1.create_checkpoint(&cp1_path).unwrap(); // Verify checkpoint @@ -88,7 +88,7 @@ pub fn test_multi_checkpoints() { // Create another checkpoint let cp2 = Checkpoint::new(&db).unwrap(); - let cp2_path = DBPath::new(&format!("{}cp2", PATH_PREFIX)); + let cp2_path = DBPath::new(&format!("{PATH_PREFIX}cp2")); cp2.create_checkpoint(&cp2_path).unwrap(); // Verify second checkpoint diff --git a/tests/test_column_family.rs b/tests/test_column_family.rs index 8010843..db9f666 100644 --- a/tests/test_column_family.rs +++ b/tests/test_column_family.rs @@ -334,11 +334,11 @@ fn test_merge_operator() { db.merge_cf(&cf1, b"k1", b"d").unwrap(); db.merge_cf(&cf1, b"k1", b"efg").unwrap(); let m = db.merge_cf(&cf1, b"k1", b"h"); - println!("m is {:?}", m); + println!("m is {m:?}"); // TODO assert!(m.is_ok()); match db.get(b"k1") { Ok(Some(value)) => match std::str::from_utf8(&value) { - Ok(v) => println!("retrieved utf8 value: {}", v), + Ok(v) => println!("retrieved utf8 value: {v}"), Err(_) => println!("did not read valid utf-8 out of the db"), }, Err(_) => println!("error reading value"), @@ -458,13 +458,13 @@ fn test_no_leaked_column_family() { // repeat creating and dropping cfs many time to indirectly detect // possible leak via large dir. for cf_index in 0..20 { - let cf_name = format!("cf{}", cf_index); + let cf_name = format!("cf{cf_index}"); db.create_cf(&cf_name, &Options::default()).unwrap(); let cf = db.cf_handle(&cf_name).unwrap(); let mut batch = rocksdb::WriteBatch::default(); for key_index in 0..100 { - batch.put_cf(&cf, format!("k{}", key_index), &large_blob); + batch.put_cf(&cf, format!("k{key_index}"), &large_blob); } db.write_opt(batch, &write_options).unwrap(); @@ -480,11 +480,8 @@ fn test_no_leaked_column_family() { // if we're not leaking, the dir bytes should be well under 10M bytes in total let dir_bytes = dir_size(&n).unwrap(); - assert!( - dir_bytes < 10_000_000, - "{} is too large (maybe leaking...)", - dir_bytes - ); + let leak_msg = format!("{dir_bytes} is too large (maybe leaking...)"); + assert!(dir_bytes < 10_000_000, "{}", leak_msg); // only if MultiThreaded, cf can outlive db.drop_cf() and shouldn't cause SEGV... #[cfg(feature = "multi-threaded-cf")] diff --git a/tests/test_db.rs b/tests/test_db.rs index e6bf6d8..1ac85b8 100644 --- a/tests/test_db.rs +++ b/tests/test_db.rs @@ -710,7 +710,7 @@ fn fifo_compaction_test() { let block_cache_hit_count = ctx.metric(PerfMetric::BlockCacheHitCount); if block_cache_hit_count > 0 { - let expect = format!("block_cache_hit_count = {}", block_cache_hit_count); + let expect = format!("block_cache_hit_count = {block_cache_hit_count}"); assert!(ctx.report(true).contains(&expect)); } @@ -829,7 +829,7 @@ fn get_with_cache_and_bulkload_test() { // write a lot let mut batch = WriteBatch::default(); for i in 0..10_000 { - batch.put(format!("{:0>4}", i).as_bytes(), b"v"); + batch.put(format!("{i:0>4}").as_bytes(), b"v"); } assert!(db.write(batch).is_ok()); @@ -858,7 +858,7 @@ fn get_with_cache_and_bulkload_test() { // try to get key let iter = db.iterator(IteratorMode::Start); for (expected, (k, _)) in iter.map(Result::unwrap).enumerate() { - assert_eq!(k.as_ref(), format!("{:0>4}", expected).as_bytes()); + assert_eq!(k.as_ref(), format!("{expected:0>4}").as_bytes()); } // check live files (sst files meta) @@ -919,7 +919,7 @@ fn get_with_cache_and_bulkload_test() { // try to get key let iter = db.iterator(IteratorMode::Start); for (expected, (k, _)) in iter.map(Result::unwrap).enumerate() { - assert_eq!(k.as_ref(), format!("{:0>4}", expected).as_bytes()); + assert_eq!(k.as_ref(), format!("{expected:0>4}").as_bytes()); } } } @@ -964,7 +964,7 @@ fn get_with_cache_and_bulkload_and_blobs_test() { // write a lot let mut batch = WriteBatch::default(); for i in 0..10_000 { - batch.put(format!("{:0>4}", i).as_bytes(), b"v"); + batch.put(format!("{i:0>4}").as_bytes(), b"v"); } assert!(db.write(batch).is_ok()); @@ -993,7 +993,7 @@ fn get_with_cache_and_bulkload_and_blobs_test() { // try to get key let iter = db.iterator(IteratorMode::Start); for (expected, (k, _)) in iter.map(Result::unwrap).enumerate() { - assert_eq!(k.as_ref(), format!("{:0>4}", expected).as_bytes()); + assert_eq!(k.as_ref(), format!("{expected:0>4}").as_bytes()); } // check live files (sst files meta) @@ -1054,7 +1054,7 @@ fn get_with_cache_and_bulkload_and_blobs_test() { // try to get key let iter = db.iterator(IteratorMode::Start); for (expected, (k, _)) in iter.map(Result::unwrap).enumerate() { - assert_eq!(k.as_ref(), format!("{:0>4}", expected).as_bytes()); + assert_eq!(k.as_ref(), format!("{expected:0>4}").as_bytes()); } } } diff --git a/tests/test_iterator.rs b/tests/test_iterator.rs index d681bcc..72a40ad 100644 --- a/tests/test_iterator.rs +++ b/tests/test_iterator.rs @@ -77,7 +77,8 @@ fn test_iterator() { let mut it = db.iterator(IteratorMode::From(key, dir)); let value = it.next(); if valid { - assert!(matches!(value, Some(Ok(_))), "{:?}", value); + let expect = format!("{value:?}"); + assert!(matches!(value, Some(Ok(_))), "{:?}", &expect); } else { assert_eq!(None, value); assert_eq!(None, it.next()); // Iterator is fused diff --git a/tests/test_merge_operator.rs b/tests/test_merge_operator.rs index 12137f0..c5010d6 100644 --- a/tests/test_merge_operator.rs +++ b/tests/test_merge_operator.rs @@ -60,7 +60,7 @@ fn merge_test() { match db.get(b"k1") { Ok(Some(value)) => { if let Ok(v) = std::str::from_utf8(&value) { - println!("retrieved utf8 value: {}", v) + println!("retrieved utf8 value: {v}") } else { println!("did not read valid utf-8 out of the db") }