Skip to content

Commit

Permalink
Merge pull request #1 from zaidoon1/zaidoon/bump-dependencies
Browse files Browse the repository at this point in the history
bump dependencies & upgrade to latest rust version
  • Loading branch information
zaidoon1 authored Feb 10, 2024
2 parents 4336985 + e2adfb1 commit 8526d0c
Show file tree
Hide file tree
Showing 21 changed files with 83 additions and 68 deletions.
16 changes: 14 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,24 @@ name: RocksDB CI

on: [push, pull_request]
env:
RUST_VERSION: 1.66.0
RUST_VERSION: 1.75.0

jobs:
fmt:
style:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_VERSION }}
components: rustfmt
profile: minimal
override: true

- name: Run rustfmt
uses: actions-rs/cargo@v1
with:
Expand All @@ -30,13 +32,15 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_VERSION }}
components: rust-docs
profile: minimal
override: true

- name: Run cargo rustdoc
uses: actions-rs/cargo@v1
with:
Expand All @@ -49,13 +53,15 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_VERSION }}
components: clippy
profile: minimal
override: true

- name: Run clippy
uses: actions-rs/clippy-check@v1
with:
Expand Down Expand Up @@ -87,25 +93,31 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_VERSION }}
target: ${{ matrix.target }}
profile: minimal
override: true

- name: Remove msys64 # Workaround to resolve link error with C:\msys64\mingw64\bin\libclang.dll
if: runner.os == 'Windows'
run: Remove-Item -LiteralPath "C:\msys64\" -Force -Recurse

- name: Install dependencies
if: runner.os == 'Windows'
run: choco install llvm -y

- name: Run rocksdb tests
run: |
cargo test --all
cargo test --all --features multi-threaded-cf
- name: Free disk space
run: cargo clean

- name: Run rocksdb tests (jemalloc)
if: runner.os != 'Windows'
run: cargo test --all --features jemalloc
16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
name = "rocksdb"
description = "Rust wrapper for Facebook's RocksDB embeddable database"
version = "0.21.0"
edition = "2018"
rust-version = "1.66.0"
edition = "2021"
rust-version = "1.75.0"
authors = ["Tyler Neely <t@jujit.su>", "David Greenberg <dsg123456789@gmail.com>"]
repository = "https://github.com/rust-rocksdb/rust-rocksdb"
repository = "https://github.com/zaidoon1/rust-rocksdb"
license = "Apache-2.0"
categories = [ "database" ]
keywords = ["database", "embedded", "LSM-tree", "persistence"]
homepage = "https://github.com/rust-rocksdb/rust-rocksdb"
homepage = "https://github.com/zaidoon1/rust-rocksdb"
exclude = [
".gitignore",
".travis.yml",
Expand Down Expand Up @@ -40,8 +40,8 @@ librocksdb-sys = { path = "librocksdb-sys", version = "0.16.0" }
serde = { version = "1", features = [ "derive" ], optional = true }

[dev-dependencies]
trybuild = "1.0"
tempfile = "3.1"
pretty_assertions = "1.0"
bincode = "1.3"
trybuild = "1"
tempfile = "3"
pretty_assertions = "1"
bincode = "1"
serde = { version = "1", features = [ "derive" ] }
6 changes: 3 additions & 3 deletions librocksdb-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "librocksdb-sys"
version = "0.16.0+8.10.0"
edition = "2018"
rust-version = "1.66.0"
edition = "2021"
rust-version = "1.75.0"
authors = ["Karl Hobley <karlhobley10@gmail.com>", "Arkadiy Paronyan <arkadiy@ethcore.io>"]
license = "MIT/Apache-2.0/BSD-3-Clause"
description = "Native bindings to librocksdb"
Expand Down Expand Up @@ -34,7 +34,7 @@ bzip2-sys = { version = "0.1", default-features = false, optional = true }

[dev-dependencies]
const-cstr = "0.3"
uuid = { version = "1.0", features = ["v4"] }
uuid = { version = "1", features = ["v4"] }

[build-dependencies]
cc = { version = "1.0", features = ["parallel"] }
Expand Down
2 changes: 1 addition & 1 deletion src/compaction_filter_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub unsafe extern "C" fn name_callback<F>(raw_self: *mut c_void) -> *const c_cha
where
F: CompactionFilterFactory,
{
let self_ = &*(raw_self as *const c_void as *const F);
let self_ = &*(raw_self.cast_const() as *const F);
self_.name().as_ptr()
}

Expand Down
14 changes: 7 additions & 7 deletions src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ impl<T: ThreadMode> DBWithThreadMode<T> {

let cfopts: Vec<_> = cfs_v
.iter()
.map(|cf| cf.options.inner as *const _)
.map(|cf| cf.options.inner.cast_const())
.collect();

db = Self::open_cf_raw(
Expand Down Expand Up @@ -1147,7 +1147,7 @@ impl<T: ThreadMode, D: DBInner> DBCommon<T, D> {
.collect();
let ptr_cfs: Vec<_> = cfs_and_keys
.iter()
.map(|(c, _)| c.inner() as *const _)
.map(|(c, _)| c.inner().cast_const())
.collect();

let mut values = vec![ptr::null_mut(); ptr_keys.len()];
Expand Down Expand Up @@ -1225,7 +1225,7 @@ impl<T: ThreadMode, D: DBInner> DBCommon<T, D> {
);
pinned_values
.into_iter()
.zip(errors.into_iter())
.zip(errors)
.map(|(v, e)| {
if e.is_null() {
if v.is_null() {
Expand Down Expand Up @@ -2000,7 +2000,7 @@ impl<T: ThreadMode, D: DBInner> DBCommon<T, D> {
self.inner.inner(),
cpaths.as_ptr(),
paths_v.len(),
opts.inner as *const _
opts.inner.cast_const()
));
Ok(())
}
Expand All @@ -2019,7 +2019,7 @@ impl<T: ThreadMode, D: DBInner> DBCommon<T, D> {
cf.inner(),
cpaths.as_ptr(),
paths_v.len(),
opts.inner as *const _
opts.inner.cast_const()
));
Ok(())
}
Expand Down Expand Up @@ -2312,8 +2312,8 @@ pub(crate) fn convert_values(
) -> Vec<Result<Option<Vec<u8>>, Error>> {
values
.into_iter()
.zip(values_sizes.into_iter())
.zip(errors.into_iter())
.zip(values_sizes)
.zip(errors)
.map(|((v, s), e)| {
if e.is_null() {
let value = unsafe { crate::ffi_util::raw_data(v, s) };
Expand Down
7 changes: 2 additions & 5 deletions src/db_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1108,10 +1108,7 @@ impl Options {
///
/// Default: empty
pub fn set_db_paths(&mut self, paths: &[DBPath]) {
let mut paths: Vec<_> = paths
.iter()
.map(|path| path.inner as *const ffi::rocksdb_dbpath_t)
.collect();
let mut paths: Vec<_> = paths.iter().map(|path| path.inner.cast_const()).collect();
let num_paths = paths.len();
unsafe {
ffi::rocksdb_options_set_db_paths(self.inner, paths.as_mut_ptr(), num_paths);
Expand Down Expand Up @@ -2495,7 +2492,7 @@ impl Options {
unsafe {
ffi::rocksdb_options_set_max_bytes_for_level_multiplier_additional(
self.inner,
level_values.as_ptr() as *mut c_int,
level_values.as_ptr().cast_mut(),
count,
);
}
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
// '... may panic' lints.
// Too much work to fix.
clippy::missing_errors_doc,
clippy::should_panic_without_expect,
// False positive: WebSocket
clippy::doc_markdown,
clippy::missing_safety_doc,
Expand Down
5 changes: 1 addition & 4 deletions src/merge_operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,7 @@ impl MergeOperands {
let len_ptr = (base_len + (spacing_len * index)) as *const size_t;
let len = *len_ptr;
let ptr = base + (spacing * index);
Some(slice::from_raw_parts(
*(ptr as *const *const u8) as *const u8,
len,
))
Some(slice::from_raw_parts(*(ptr as *const *const u8), len))
}
}
}
Expand Down
30 changes: 14 additions & 16 deletions src/prop_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,22 @@ impl PropName {
/// Panics if the `value` isn’t terminated by a nul byte or contains
/// interior nul bytes.
pub(crate) const fn new_unwrap(value: &str) -> &Self {
let bytes = if let Some((&0, bytes)) = value.as_bytes().split_last() {
bytes
if let Some((&0, bytes)) = value.as_bytes().split_last() {
let mut idx = 0;
while idx < bytes.len() {
assert!(bytes[idx] != 0, "input contained interior nul byte");
idx += 1;
}

// SAFETY: 1. We’ve just verified `value` is a nul-terminated with no
// interior nul bytes and since its `str` it’s also valid UTF-8.
// 2. Self and CStr have the same representation so casting is sound.
unsafe {
let value = CStr::from_bytes_with_nul_unchecked(value.as_bytes());
&*(value as *const CStr as *const Self)
}
} else {
panic!("input was not nul-terminated");
};

let mut idx = 0;
while idx < bytes.len() {
assert!(bytes[idx] != 0, "input contained interior nul byte");
idx += 1;
}

// SAFETY: 1. We’ve just verified `value` is a nul-terminated with no
// interior nul bytes and since its `str` it’s also valid UTF-8.
// 2. Self and CStr have the same representation so casting is sound.
unsafe {
let value = CStr::from_bytes_with_nul_unchecked(value.as_bytes());
&*(value as *const CStr as *const Self)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/transactions/optimistic_transaction_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ impl<T: ThreadMode> OptimisticTransactionDB<T> {

let cfopts: Vec<_> = cfs_v
.iter()
.map(|cf| cf.options.inner as *const _)
.map(|cf| cf.options.inner.cast_const())
.collect();

db = Self::open_cf_raw(opts, &cpath, &cfs_v, &cfnames, &cfopts, &mut cfhandles)?;
Expand Down Expand Up @@ -262,7 +262,7 @@ impl<T: ThreadMode> OptimisticTransactionDB<T> {
std::ptr::null_mut(),
)
},
_marker: PhantomData::default(),
_marker: PhantomData,
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/transactions/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ impl<'db, DB> Transaction<'db, DB> {
.collect();
let ptr_cfs: Vec<_> = cfs_and_keys
.iter()
.map(|(c, _)| c.inner() as *const _)
.map(|(c, _)| c.inner().cast_const())
.collect();

let mut values = vec![ptr::null_mut(); ptr_keys.len()];
Expand Down
8 changes: 4 additions & 4 deletions src/transactions/transaction_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ impl<T: ThreadMode> TransactionDB<T> {

let cfopts: Vec<_> = cfs_v
.iter()
.map(|cf| cf.options.inner as *const _)
.map(|cf| cf.options.inner.cast_const())
.collect();

db = Self::open_cf_raw(
Expand Down Expand Up @@ -408,7 +408,7 @@ impl<T: ThreadMode> TransactionDB<T> {
std::ptr::null_mut(),
)
},
_marker: PhantomData::default(),
_marker: PhantomData,
}
}

Expand All @@ -423,7 +423,7 @@ impl<T: ThreadMode> TransactionDB<T> {
.drain(0..)
.map(|inner| Transaction {
inner,
_marker: PhantomData::default(),
_marker: PhantomData,
})
.collect()
}
Expand Down Expand Up @@ -600,7 +600,7 @@ impl<T: ThreadMode> TransactionDB<T> {
.collect();
let ptr_cfs: Vec<_> = cfs_and_keys
.iter()
.map(|(c, _)| c.inner() as *const _)
.map(|(c, _)| c.inner().cast_const())
.collect();

let mut values = vec![ptr::null_mut(); ptr_keys.len()];
Expand Down
1 change: 1 addition & 0 deletions tests/fail/checkpoint_outlive_db.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ error[E0597]: `db` does not live long enough
4 | let _checkpoint = {
| ----------- borrow later stored here
5 | let db = DB::open_default("foo").unwrap();
| -- binding `db` declared here
6 | Checkpoint::new(&db)
| ^^^ borrowed value does not live long enough
7 | };
Expand Down
3 changes: 2 additions & 1 deletion tests/fail/iterator_outlive_db.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ error[E0597]: `db` does not live long enough
4 | let _iter = {
| ----- borrow later stored here
5 | let db = DB::open_default("foo").unwrap();
| -- binding `db` declared here
6 | db.iterator(IteratorMode::Start)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough
| ^^ borrowed value does not live long enough
7 | };
| - `db` dropped here while still borrowed
20 changes: 12 additions & 8 deletions tests/fail/open_with_multiple_refs_as_single_threaded.stderr
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
error[E0596]: cannot borrow `*db_ref1` as mutable, as it is behind a `&` reference
--> tests/fail/open_with_multiple_refs_as_single_threaded.rs:8:5
|
5 | let db_ref1 = &db;
| --- help: consider changing this to be a mutable reference: `&mut db`
...
8 | db_ref1.create_cf("cf1", &opts).unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `db_ref1` is a `&` reference, so the data it refers to cannot be borrowed as mutable
| ^^^^^^^ `db_ref1` is a `&` reference, so the data it refers to cannot be borrowed as mutable
|
help: consider changing this to be a mutable reference
|
5 | let db_ref1 = &mut db;
| +++

error[E0596]: cannot borrow `*db_ref2` as mutable, as it is behind a `&` reference
--> tests/fail/open_with_multiple_refs_as_single_threaded.rs:9:5
|
6 | let db_ref2 = &db;
| --- help: consider changing this to be a mutable reference: `&mut db`
...
9 | db_ref2.create_cf("cf2", &opts).unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `db_ref2` is a `&` reference, so the data it refers to cannot be borrowed as mutable
| ^^^^^^^ `db_ref2` is a `&` reference, so the data it refers to cannot be borrowed as mutable
|
help: consider changing this to be a mutable reference
|
6 | let db_ref2 = &mut db;
| +++
Loading

0 comments on commit 8526d0c

Please sign in to comment.