Skip to content

Commit 981f813

Browse files
committed
fix clippy
Signed-off-by: Yang Zhang <yang.zhang@pingcap.com>
1 parent 7158644 commit 981f813

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

src/engine.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,7 +1422,7 @@ pub(crate) mod tests {
14221422
let empty_entry = Entry::new();
14231423
assert_eq!(empty_entry.compute_size(), 0);
14241424
log_batch
1425-
.add_entries::<Entry>(0, &[empty_entry.clone()])
1425+
.add_entries::<Entry>(0, std::slice::from_ref(&empty_entry))
14261426
.unwrap();
14271427
engine.write(&mut log_batch, false).unwrap();
14281428
let empty_state = RaftLocalState::new();
@@ -1432,7 +1432,7 @@ pub(crate) mod tests {
14321432
.unwrap();
14331433
engine.write(&mut log_batch, false).unwrap();
14341434
log_batch
1435-
.add_entries::<Entry>(2, &[empty_entry.clone()])
1435+
.add_entries::<Entry>(2, std::slice::from_ref(&empty_entry))
14361436
.unwrap();
14371437
log_batch
14381438
.put_message(2, b"key".to_vec(), &empty_state)

src/log_batch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1633,7 +1633,7 @@ mod tests {
16331633
#[cfg(feature = "nightly")]
16341634
#[bench]
16351635
fn bench_log_batch_add_entry_and_encode(b: &mut test::Bencher) {
1636-
use rand::{Rng, random};
1636+
use rand::random;
16371637
fn details(log_batch: &mut LogBatch, entries: &[Entry], regions: usize) {
16381638
for _ in 0..regions {
16391639
log_batch.add_entries::<Entry>(random(), entries).unwrap();

src/swappy_allocator.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ mod tests {
402402
}
403403
unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout) {
404404
self.dealloc.fetch_add(1, Ordering::Relaxed);
405-
std::alloc::Global.deallocate(ptr, layout)
405+
unsafe { std::alloc::Global.deallocate(ptr, layout) }
406406
}
407407
unsafe fn grow(
408408
&self,
@@ -414,7 +414,7 @@ mod tests {
414414
if self.err_mode.load(Ordering::Relaxed) {
415415
Err(AllocError)
416416
} else {
417-
std::alloc::Global.grow(ptr, old_layout, new_layout)
417+
unsafe { std::alloc::Global.grow(ptr, old_layout, new_layout) }
418418
}
419419
}
420420
unsafe fn shrink(
@@ -427,7 +427,7 @@ mod tests {
427427
if self.err_mode.load(Ordering::Relaxed) {
428428
Err(AllocError)
429429
} else {
430-
std::alloc::Global.shrink(ptr, old_layout, new_layout)
430+
unsafe { std::alloc::Global.shrink(ptr, old_layout, new_layout) }
431431
}
432432
}
433433
}

tests/benches/bench_recovery.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ fn dir_size(path: &str) -> ReadableSize {
118118

119119
fn bench_recovery(c: &mut Criterion) {
120120
// prepare input
121-
let cfgs = vec![
121+
let cfgs = [
122122
(
123123
"default".to_owned(),
124124
Config {

0 commit comments

Comments
 (0)