Skip to content

Commit 897f85d

Browse files
committed
Clippy feedback
1 parent 140bed4 commit 897f85d

File tree

9 files changed

+20
-26
lines changed

9 files changed

+20
-26
lines changed

src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ impl Config {
696696
} else {
697697
#[allow(unsafe_code)]
698698
unsafe {
699-
Err(ge.deref().clone())
699+
Err(*ge.deref())
700700
}
701701
}
702702
}

src/db.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,7 @@ impl Db {
146146
pub fn drop_tree<V: AsRef<[u8]>>(&self, name: V) -> Result<bool> {
147147
let name_ref = name.as_ref();
148148
if name_ref == DEFAULT_TREE_ID {
149-
return Err(Error::Unsupported(
150-
"cannot remove the core structures".into(),
151-
));
149+
return Err(Error::Unsupported("cannot remove the default tree"));
152150
}
153151
trace!("dropping tree {:?}", name_ref,);
154152

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@
162162
// clippy::wildcard_enum_match_arm,
163163
)
164164
)]
165+
#![allow(clippy::comparison_chain)]
165166

166167
macro_rules! io_fail {
167168
($config:expr, $e:expr) => {

src/pagecache/iobuf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1200,7 +1200,7 @@ pub(in crate::pagecache) fn maybe_seal_and_write_iobuf(
12001200
match iobufs.with_sa(|sa| sa.next(next_lsn)) {
12011201
Ok(ret) => ret,
12021202
Err(e) => {
1203-
iobufs.set_global_error(e.clone());
1203+
iobufs.set_global_error(e);
12041204
return Err(e);
12051205
}
12061206
}

src/pagecache/logger.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl Log {
118118
);
119119

120120
if let Err(e) = &ret {
121-
self.iobufs.set_global_error(e.clone());
121+
self.iobufs.set_global_error(*e);
122122
}
123123

124124
ret
@@ -169,7 +169,7 @@ impl Log {
169169
let ret = self.reserve_inner(log_kind, pid, item, None, guard);
170170

171171
if let Err(e) = &ret {
172-
self.iobufs.set_global_error(e.clone());
172+
self.iobufs.set_global_error(*e);
173173
}
174174

175175
ret

src/pagecache/mod.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ impl PageCache {
840840
// changing.
841841
let ts = old.ts() + 1;
842842

843-
let cache_info = CacheInfo { lsn, pointer, ts };
843+
let cache_info = CacheInfo { ts, lsn, pointer };
844844

845845
let mut new_cache_infos =
846846
Vec::with_capacity(old.cache_infos.len() + 1);
@@ -944,13 +944,13 @@ impl PageCache {
944944
'inner: loop {
945945
let pg_view = self.inner.get(pid, &guard);
946946

947-
match &*pg_view.cache_infos {
948-
&[_single_cache_info] => {
947+
match *pg_view.cache_infos {
948+
[_single_cache_info] => {
949949
let page_state = pg_view.to_page_state();
950950
page_states.push(page_state);
951951
break 'inner;
952952
}
953-
&[_first_of_several, ..] => {
953+
[_first_of_several, ..] => {
954954
// If a page has multiple disk locations,
955955
// rewrite it to a single one before storing
956956
// a single 8-byte pointer to its cold location.
@@ -965,7 +965,7 @@ impl PageCache {
965965
}
966966
continue 'inner;
967967
}
968-
&[] => {
968+
[] => {
969969
// there is a benign race with the thread
970970
// that is allocating this page. the allocating
971971
// thread has not yet written the new page to disk,
@@ -1661,8 +1661,7 @@ impl PageCacheInner {
16611661
"{:?}",
16621662
Error::ReportableBug(
16631663
"failed to retrieve META page \
1664-
which should always be present"
1665-
.into(),
1664+
which should always be present"
16661665
)
16671666
)
16681667
}
@@ -1684,8 +1683,7 @@ impl PageCacheInner {
16841683
"{:?}",
16851684
Error::ReportableBug(
16861685
"failed to retrieve counter page \
1687-
which should always be present"
1688-
.into(),
1686+
which should always be present"
16891687
)
16901688
)
16911689
}
@@ -1948,8 +1946,7 @@ impl PageCacheInner {
19481946
Err(None) => {
19491947
return Err(Error::ReportableBug(
19501948
"replacing the META page has failed because \
1951-
the pagecache does not think it currently exists."
1952-
.into(),
1949+
the pagecache does not think it currently exists.",
19531950
));
19541951
}
19551952
}

src/pagecache/snapshot.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -310,19 +310,17 @@ fn advance_snapshot(
310310
#[cfg(feature = "testing")]
311311
let mut shred_point = None;
312312

313-
let snapshot = if db_is_empty {
313+
if db_is_empty {
314314
trace!("db is empty, returning default snapshot");
315315
if snapshot != Snapshot::default() {
316316
error!("expected snapshot to be Snapshot::default");
317317
return Err(Error::corruption(None));
318318
}
319-
snapshot
320319
} else if iter.cur_lsn.is_none() {
321320
trace!(
322321
"no recovery progress happened since the last snapshot \
323322
was generated, returning the previous one"
324323
);
325-
snapshot
326324
} else {
327325
let iterated_lsn = iter.cur_lsn.unwrap();
328326

@@ -391,8 +389,6 @@ fn advance_snapshot(
391389
snapshot.stable_lsn = Some(stable_lsn);
392390
snapshot.active_segment = active_segment;
393391
snapshot.filter_inner_heap_ids();
394-
395-
snapshot
396392
};
397393

398394
trace!("generated snapshot: {:?}", snapshot);

src/threadpool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ pub fn truncate(config: crate::RunningConfig, at: u64) -> OneShot<Result<()>> {
268268
.map_err(|e| e.into());
269269

270270
if let Err(e) = &ret {
271-
config.set_global_error(e.clone());
271+
config.set_global_error(*e);
272272
}
273273

274274
ret

src/transaction.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,8 @@ impl<E> Transactional<E> for [Tree] {
544544
});
545545
if !same_db {
546546
return Err(Error::Unsupported(
547-
"cannot use trees from multiple databases in the same transaction".into(),
547+
"cannot use trees from multiple \
548+
databases in the same transaction",
548549
));
549550
}
550551

@@ -572,7 +573,8 @@ impl<E> Transactional<E> for [&Tree] {
572573
});
573574
if !same_db {
574575
return Err(Error::Unsupported(
575-
"cannot use trees from multiple databases in the same transaction".into(),
576+
"cannot use trees from multiple \
577+
databases in the same transaction",
576578
));
577579
}
578580

0 commit comments

Comments
 (0)