Skip to content

Commit 3318ab2

Browse files
niklasfzaidoon1
authored andcommitted
Fix future clippy warnings
1 parent 5da8d6b commit 3318ab2

11 files changed

+55
-50
lines changed

Diff for: librocksdb-sys/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ fn build_rocksdb() {
284284
config.flag("-EHsc");
285285
config.flag("-std:c++17");
286286
} else {
287-
config.flag(&cxx_standard());
287+
config.flag(cxx_standard());
288288
// matches the flags in CMakeLists.txt from rocksdb
289289
config.flag("-Wsign-compare");
290290
config.flag("-Wshadow");

Diff for: src/backup.rs

-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ impl BackupEngine {
134134
/// return Err(e.to_string());
135135
/// }
136136
/// ```
137-
138137
pub fn restore_from_latest_backup<D: AsRef<Path>, W: AsRef<Path>>(
139138
&mut self,
140139
db_dir: D,

Diff for: src/checkpoint.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl<'db> Checkpoint<'db> {
6666
}
6767
}
6868

69-
impl<'db> Drop for Checkpoint<'db> {
69+
impl Drop for Checkpoint<'_> {
7070
fn drop(&mut self) {
7171
unsafe {
7272
ffi::rocksdb_checkpoint_object_destroy(self.inner);

Diff for: src/column_family.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl Drop for ColumnFamily {
138138

139139
// these behaviors must be identical between BoundColumnFamily and UnboundColumnFamily
140140
// due to the unsafe transmute() in bound_column_family()!
141-
impl<'a> Drop for BoundColumnFamily<'a> {
141+
impl Drop for BoundColumnFamily<'_> {
142142
fn drop(&mut self) {
143143
destroy_handle(self.inner);
144144
}
@@ -170,7 +170,7 @@ impl AsColumnFamilyRef for ColumnFamily {
170170
}
171171
}
172172

173-
impl<'a> AsColumnFamilyRef for &'a ColumnFamily {
173+
impl AsColumnFamilyRef for &'_ ColumnFamily {
174174
fn inner(&self) -> *mut ffi::rocksdb_column_family_handle_t {
175175
self.inner
176176
}
@@ -181,7 +181,7 @@ impl<'a> AsColumnFamilyRef for &'a ColumnFamily {
181181
// isn't expected to be used as naked.
182182
// Also, ColumnFamilyRef might not be Arc<BoundColumnFamily<'a>> depending crate
183183
// feature flags so, we can't use the type alias here.
184-
impl<'a> AsColumnFamilyRef for Arc<BoundColumnFamily<'a>> {
184+
impl AsColumnFamilyRef for Arc<BoundColumnFamily<'_>> {
185185
fn inner(&self) -> *mut ffi::rocksdb_column_family_handle_t {
186186
self.inner
187187
}
@@ -191,5 +191,5 @@ unsafe impl Send for ColumnFamily {}
191191
unsafe impl Sync for ColumnFamily {}
192192
unsafe impl Send for UnboundColumnFamily {}
193193
unsafe impl Sync for UnboundColumnFamily {}
194-
unsafe impl<'a> Send for BoundColumnFamily<'a> {}
195-
unsafe impl<'a> Sync for BoundColumnFamily<'a> {}
194+
unsafe impl Send for BoundColumnFamily<'_> {}
195+
unsafe impl Sync for BoundColumnFamily<'_> {}

Diff for: src/db_iterator.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -377,16 +377,16 @@ impl<'a, D: DBAccess> DBRawIteratorWithThreadMode<'a, D> {
377377
}
378378
}
379379

380-
impl<'a, D: DBAccess> Drop for DBRawIteratorWithThreadMode<'a, D> {
380+
impl<D: DBAccess> Drop for DBRawIteratorWithThreadMode<'_, D> {
381381
fn drop(&mut self) {
382382
unsafe {
383383
ffi::rocksdb_iter_destroy(self.inner.as_ptr());
384384
}
385385
}
386386
}
387387

388-
unsafe impl<'a, D: DBAccess> Send for DBRawIteratorWithThreadMode<'a, D> {}
389-
unsafe impl<'a, D: DBAccess> Sync for DBRawIteratorWithThreadMode<'a, D> {}
388+
unsafe impl<D: DBAccess> Send for DBRawIteratorWithThreadMode<'_, D> {}
389+
unsafe impl<D: DBAccess> Sync for DBRawIteratorWithThreadMode<'_, D> {}
390390

391391
/// A type alias to keep compatibility. See [`DBIteratorWithThreadMode`] for details
392392
pub type DBIterator<'a> = DBIteratorWithThreadMode<'a, DB>;
@@ -501,7 +501,7 @@ impl<'a, D: DBAccess> DBIteratorWithThreadMode<'a, D> {
501501
}
502502
}
503503

504-
impl<'a, D: DBAccess> Iterator for DBIteratorWithThreadMode<'a, D> {
504+
impl<D: DBAccess> Iterator for DBIteratorWithThreadMode<'_, D> {
505505
type Item = Result<KVBytes, Error>;
506506

507507
fn next(&mut self) -> Option<Result<KVBytes, Error>> {
@@ -521,7 +521,7 @@ impl<'a, D: DBAccess> Iterator for DBIteratorWithThreadMode<'a, D> {
521521
}
522522
}
523523

524-
impl<'a, D: DBAccess> std::iter::FusedIterator for DBIteratorWithThreadMode<'a, D> {}
524+
impl<D: DBAccess> std::iter::FusedIterator for DBIteratorWithThreadMode<'_, D> {}
525525

526526
impl<'a, D: DBAccess> Into<DBRawIteratorWithThreadMode<'a, D>> for DBIteratorWithThreadMode<'a, D> {
527527
fn into(self) -> DBRawIteratorWithThreadMode<'a, D> {

Diff for: src/db_options.rs

+13-8
Original file line numberDiff line numberDiff line change
@@ -1580,9 +1580,10 @@ impl Options {
15801580
/// UniversalCompactionBuilder::PickPeriodicCompaction().
15811581
/// For backward compatibility, the effective value of this option takes
15821582
/// into account the value of option `ttl`. The logic is as follows:
1583-
/// - both options are set to 30 days if they have the default value.
1584-
/// - if both options are zero, zero is picked. Otherwise, we take the min
1585-
/// value among non-zero options values (i.e. takes the stricter limit).
1583+
///
1584+
/// - both options are set to 30 days if they have the default value.
1585+
/// - if both options are zero, zero is picked. Otherwise, we take the min
1586+
/// value among non-zero options values (i.e. takes the stricter limit).
15861587
///
15871588
/// One main use of the feature is to make sure a file goes through compaction
15881589
/// filters periodically. Users can also use the feature to clear up SST
@@ -2148,8 +2149,8 @@ impl Options {
21482149
/// The exact behavior of this parameter is platform dependent.
21492150
///
21502151
/// On POSIX systems, after RocksDB reads data from disk it will
2151-
/// mark the pages as "unneeded". The operating system may - or may not
2152-
/// - evict these pages from memory, reducing pressure on the system
2152+
/// mark the pages as "unneeded". The operating system may or may not
2153+
/// evict these pages from memory, reducing pressure on the system
21532154
/// cache. If the disk block is requested again this can result in
21542155
/// additional disk I/O.
21552156
///
@@ -3705,9 +3706,11 @@ impl Options {
37053706
/// to be able to ingest behind (call IngestExternalFile() skipping keys
37063707
/// that already exist, rather than overwriting matching keys).
37073708
/// Setting this option to true has the following effects:
3708-
/// 1) Disable some internal optimizations around SST file compression.
3709-
/// 2) Reserve the last level for ingested files only.
3710-
/// 3) Compaction will not include any file from the last level.
3709+
///
3710+
/// 1. Disable some internal optimizations around SST file compression.
3711+
/// 2. Reserve the last level for ingested files only.
3712+
/// 3. Compaction will not include any file from the last level.
3713+
///
37113714
/// Note that only Universal Compaction supports allow_ingest_behind.
37123715
/// `num_levels` should be >= 3 if this option is turned on.
37133716
///
@@ -3830,10 +3833,12 @@ impl Options {
38303833
/// or an IDENTITY file (historical, deprecated), or both. If this option is
38313834
/// set to false (old behavior), then `write_identity_file` must be set to true.
38323835
/// The manifest is preferred because
3836+
///
38333837
/// 1. The IDENTITY file is not checksummed, so it is not as safe against
38343838
/// corruption.
38353839
/// 2. The IDENTITY file may or may not be copied with the DB (e.g. not
38363840
/// copied by BackupEngine), so is not reliable for the provenance of a DB.
3841+
///
38373842
/// This option might eventually be obsolete and removed as Identity files
38383843
/// are phased out.
38393844
///

Diff for: src/db_pinnable_slice.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ pub struct DBPinnableSlice<'a> {
2828
db: PhantomData<&'a DB>,
2929
}
3030

31-
unsafe impl<'a> Send for DBPinnableSlice<'a> {}
32-
unsafe impl<'a> Sync for DBPinnableSlice<'a> {}
31+
unsafe impl Send for DBPinnableSlice<'_> {}
32+
unsafe impl Sync for DBPinnableSlice<'_> {}
3333

34-
impl<'a> AsRef<[u8]> for DBPinnableSlice<'a> {
34+
impl AsRef<[u8]> for DBPinnableSlice<'_> {
3535
fn as_ref(&self) -> &[u8] {
3636
// Implement this via Deref so as not to repeat ourselves
3737
self
3838
}
3939
}
4040

41-
impl<'a> Deref for DBPinnableSlice<'a> {
41+
impl Deref for DBPinnableSlice<'_> {
4242
type Target = [u8];
4343

4444
fn deref(&self) -> &[u8] {
@@ -50,15 +50,15 @@ impl<'a> Deref for DBPinnableSlice<'a> {
5050
}
5151
}
5252

53-
impl<'a> Drop for DBPinnableSlice<'a> {
53+
impl Drop for DBPinnableSlice<'_> {
5454
fn drop(&mut self) {
5555
unsafe {
5656
ffi::rocksdb_pinnableslice_destroy(self.ptr);
5757
}
5858
}
5959
}
6060

61-
impl<'a> DBPinnableSlice<'a> {
61+
impl DBPinnableSlice<'_> {
6262
/// Used to wrap a PinnableSlice from rocksdb to avoid unnecessary memcpy
6363
///
6464
/// # Unsafe

Diff for: src/snapshot.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ impl<'a, D: DBAccess> SnapshotWithThreadMode<'a, D> {
259259
}
260260
}
261261

262-
impl<'a, D: DBAccess> Drop for SnapshotWithThreadMode<'a, D> {
262+
impl<D: DBAccess> Drop for SnapshotWithThreadMode<'_, D> {
263263
fn drop(&mut self) {
264264
unsafe {
265265
self.db.release_snapshot(self.inner);
@@ -269,5 +269,5 @@ impl<'a, D: DBAccess> Drop for SnapshotWithThreadMode<'a, D> {
269269

270270
/// `Send` and `Sync` implementations for `SnapshotWithThreadMode` are safe, because `SnapshotWithThreadMode` is
271271
/// immutable and can be safely shared between threads.
272-
unsafe impl<'a, D: DBAccess> Send for SnapshotWithThreadMode<'a, D> {}
273-
unsafe impl<'a, D: DBAccess> Sync for SnapshotWithThreadMode<'a, D> {}
272+
unsafe impl<D: DBAccess> Send for SnapshotWithThreadMode<'_, D> {}
273+
unsafe impl<D: DBAccess> Sync for SnapshotWithThreadMode<'_, D> {}

Diff for: src/sst_file_writer.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ pub struct SstFileWriter<'a> {
2727
phantom: PhantomData<&'a Options>,
2828
}
2929

30-
unsafe impl<'a> Send for SstFileWriter<'a> {}
31-
unsafe impl<'a> Sync for SstFileWriter<'a> {}
30+
unsafe impl Send for SstFileWriter<'_> {}
31+
unsafe impl Sync for SstFileWriter<'_> {}
3232

3333
struct EnvOptions {
3434
inner: *mut ffi::rocksdb_envoptions_t,
@@ -205,7 +205,7 @@ impl<'a> SstFileWriter<'a> {
205205
}
206206
}
207207

208-
impl<'a> Drop for SstFileWriter<'a> {
208+
impl Drop for SstFileWriter<'_> {
209209
fn drop(&mut self) {
210210
unsafe {
211211
ffi::rocksdb_sstfilewriter_destroy(self.inner);

Diff for: src/transactions/transaction.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ pub struct Transaction<'db, DB> {
3333
pub(crate) _marker: PhantomData<&'db DB>,
3434
}
3535

36-
unsafe impl<'db, DB> Send for Transaction<'db, DB> {}
36+
unsafe impl<DB> Send for Transaction<'_, DB> {}
3737

38-
impl<'db, DB> DBAccess for Transaction<'db, DB> {
38+
impl<DB> DBAccess for Transaction<'_, DB> {
3939
unsafe fn create_snapshot(&self) -> *const ffi::rocksdb_snapshot_t {
4040
ffi::rocksdb_transaction_get_snapshot(self.inner)
4141
}
@@ -116,7 +116,7 @@ impl<'db, DB> DBAccess for Transaction<'db, DB> {
116116
}
117117
}
118118

119-
impl<'db, DB> Transaction<'db, DB> {
119+
impl<DB> Transaction<'_, DB> {
120120
/// Write all batched keys to the DB atomically.
121121
///
122122
/// May return any error that could be returned by `DB::write`.
@@ -892,7 +892,7 @@ impl<'db, DB> Transaction<'db, DB> {
892892
}
893893
}
894894

895-
impl<'db, DB> Drop for Transaction<'db, DB> {
895+
impl<DB> Drop for Transaction<'_, DB> {
896896
fn drop(&mut self) {
897897
unsafe {
898898
ffi::rocksdb_transaction_destroy(self.inner);

Diff for: tests/test_db.rs

+14-13
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ mod util;
1616

1717
use std::convert::TryInto;
1818
use std::sync::atomic::{AtomicUsize, Ordering};
19-
use std::{mem, sync::Arc, thread, time::Duration};
19+
use std::{sync::Arc, thread, time::Duration};
2020

2121
use pretty_assertions::assert_eq;
2222

@@ -264,14 +264,14 @@ fn snapshot_test() {
264264
}
265265

266266
#[derive(Clone)]
267-
struct SnapshotWrapper {
268-
snapshot: Arc<Snapshot<'static>>,
267+
struct SnapshotWrapper<'db> {
268+
snapshot: Arc<Snapshot<'db>>,
269269
}
270270

271-
impl SnapshotWrapper {
272-
fn new(db: &DB) -> Self {
271+
impl<'db> SnapshotWrapper<'db> {
272+
fn new(db: &'db DB) -> Self {
273273
Self {
274-
snapshot: Arc::new(unsafe { mem::transmute(db.snapshot()) }),
274+
snapshot: Arc::new(db.snapshot()),
275275
}
276276
}
277277

@@ -291,13 +291,14 @@ fn sync_snapshot_test() {
291291
assert!(db.put(b"k1", b"v1").is_ok());
292292
assert!(db.put(b"k2", b"v2").is_ok());
293293

294-
let wrapper = SnapshotWrapper::new(&db);
295-
let wrapper_1 = wrapper.clone();
296-
let handler_1 = thread::spawn(move || wrapper_1.check("k1", b"v1"));
297-
let handler_2 = thread::spawn(move || wrapper.check("k2", b"v2"));
298-
299-
assert!(handler_1.join().unwrap());
300-
assert!(handler_2.join().unwrap());
294+
let wrapper_1 = SnapshotWrapper::new(&db);
295+
let wrapper_2 = wrapper_1.clone();
296+
thread::scope(|s| {
297+
let handler_1 = s.spawn(move || wrapper_1.check("k1", b"v1"));
298+
let handler_2 = s.spawn(move || wrapper_2.check("k2", b"v2"));
299+
assert!(handler_1.join().unwrap());
300+
assert!(handler_2.join().unwrap());
301+
});
301302
}
302303

303304
#[test]

0 commit comments

Comments
 (0)