Skip to content

Commit e95ec05

Browse files
authored
Merge pull request #1400 from spacejam/tyler_clippy
clippy feedback
2 parents 31d681f + 70d440e commit e95ec05

32 files changed

+268
-296
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
## Breaking Changes
2525

26-
* #1399 Bump MSRV to 1.51.
26+
* #1400 Bump MSRV to 1.57.
2727
* #1399 Thread support is now required on all platforms.
2828
* #1135 The "no_metrics" anti-feature has been replaced with
2929
the "metrics" positive feature.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ extreme::run(async move {
161161

162162
# minimum supported Rust version (MSRV)
163163

164-
We support Rust 1.51.0 and up.
164+
We support Rust 1.57.0 and up.
165165

166166
# architecture
167167

scripts/cross_compile.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ rustup update --no-self-update
1212

1313
RUSTFLAGS="--cfg miri" cargo check
1414

15-
rustup toolchain install 1.51.0 --no-self-update
15+
rustup toolchain install 1.57.0 --no-self-update
1616
cargo clean
1717
rm Cargo.lock
18-
cargo +1.51.0 check
18+
cargo +1.57.0 check
1919

2020
for target in $targets; do
2121
echo "setting up $target..."

src/atomic_shim.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ mod shim {
116116
*lock = prev ^ val;
117117
prev
118118
}
119+
120+
#[allow(dead_code)]
121+
pub fn fetch_max(&self, val: u64, _: Ordering) -> u64 {
122+
let mut lock = self.value.write();
123+
let prev = *lock;
124+
*lock = prev.max(val);
125+
prev
126+
}
119127
}
120128

121129
impl From<u64> for AtomicU64 {
@@ -229,6 +237,14 @@ mod shim {
229237
*lock = prev ^ val;
230238
prev
231239
}
240+
241+
#[allow(dead_code)]
242+
pub fn fetch_max(&self, val: i64, _: Ordering) -> i64 {
243+
let mut lock = self.value.write();
244+
let prev = *lock;
245+
*lock = prev.max(val);
246+
prev
247+
}
232248
}
233249

234250
impl From<i64> for AtomicI64 {

src/config.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,6 @@ impl Config {
705705
let guard = pin();
706706
let old = self.global_error.swap(Shared::default(), SeqCst, &guard);
707707
if !old.is_null() {
708-
let guard = pin();
709708
#[allow(unsafe_code)]
710709
unsafe {
711710
guard.defer_destroy(old);
@@ -781,12 +780,12 @@ impl RunningConfig {
781780
// returns the snapshot file paths for this system
782781
#[doc(hidden)]
783782
pub fn get_snapshot_files(&self) -> io::Result<Vec<PathBuf>> {
784-
let path = self.get_path().join("snap.");
783+
let conf_path = self.get_path().join("snap.");
785784

786-
let absolute_path: PathBuf = if Path::new(&path).is_absolute() {
787-
path
785+
let absolute_path: PathBuf = if Path::new(&conf_path).is_absolute() {
786+
conf_path
788787
} else {
789-
std::env::current_dir()?.join(path)
788+
std::env::current_dir()?.join(conf_path)
790789
};
791790

792791
let filter = |dir_entry: io::Result<fs::DirEntry>| {

src/db.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,14 @@ impl Db {
107107
/// accessible from the `Db` via the provided identifier.
108108
pub fn open_tree<V: AsRef<[u8]>>(&self, name: V) -> Result<Tree> {
109109
let name_ref = name.as_ref();
110-
let tenants = self.tenants.read();
111-
if let Some(tree) = tenants.get(name_ref) {
112-
return Ok(tree.clone());
110+
111+
{
112+
let tenants = self.tenants.read();
113+
if let Some(tree) = tenants.get(name_ref) {
114+
return Ok(tree.clone());
115+
}
116+
drop(tenants);
113117
}
114-
drop(tenants);
115118

116119
let guard = pin();
117120

src/debug_delay.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ pub fn debug_delay() {
4545

4646
let global_delays = GLOBAL_DELAYS.fetch_add(1, Relaxed);
4747
let local_delays = LOCAL_DELAYS.with(|ld| {
48-
let mut ld = ld.borrow_mut();
49-
let old = *ld;
50-
*ld = std::cmp::max(global_delays + 1, *ld + 1);
48+
let old = *ld.borrow();
49+
let new = (global_delays + 1).max(old + 1);
50+
*ld.borrow_mut() = new;
5151
old
5252
});
5353

src/ebr/atomic.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,9 +361,9 @@ impl<T: ?Sized + Pointable> Atomic<T> {
361361
ord.failure(),
362362
)
363363
.map(|_| unsafe { Shared::from_usize(new) })
364-
.map_err(|current| unsafe {
364+
.map_err(|cur| unsafe {
365365
CompareAndSetError {
366-
current: Shared::from_usize(current),
366+
current: Shared::from_usize(cur),
367367
new: P::from_usize(new),
368368
}
369369
})
@@ -402,9 +402,9 @@ impl<T: ?Sized + Pointable> Atomic<T> {
402402
ord.failure(),
403403
)
404404
.map(|_| unsafe { Shared::from_usize(new) })
405-
.map_err(|current| unsafe {
405+
.map_err(|cur| unsafe {
406406
CompareAndSetError {
407-
current: Shared::from_usize(current),
407+
current: Shared::from_usize(cur),
408408
new: P::from_usize(new),
409409
}
410410
})

src/ebr/internal.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ impl Bag {
102102

103103
/// Seals the bag with the given epoch.
104104
fn seal(self, epoch: Epoch) -> SealedBag {
105-
SealedBag { epoch, bag: self }
105+
SealedBag { epoch, _bag: self }
106106
}
107107
}
108108

@@ -217,7 +217,8 @@ const fn no_op_func() {}
217217
#[derive(Debug)]
218218
struct SealedBag {
219219
epoch: Epoch,
220-
bag: Bag,
220+
// exists solely to be dropped
221+
_bag: Bag,
221222
}
222223

223224
/// It is safe to share `SealedBag` because `is_expired` only inspects the epoch.

src/event_log.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,18 +109,16 @@ impl EventLog {
109109
.get(&pid)
110110
.unwrap()
111111
.iter()
112-
.map(|ptr| {
113-
let mut ptr = *ptr;
112+
.map(|ptr_ref| {
113+
let mut ptr = *ptr_ref;
114114
ptr.forget_heap_log_coordinates();
115115
ptr
116116
})
117117
.collect();
118118
let locations_after_restart: Vec<_> = par
119119
.get(&pid)
120120
.unwrap_or_else(|| panic!("pid {} no longer present after restart", pid))
121-
.iter()
122-
.copied()
123-
.collect();
121+
.to_vec();
124122
assert_eq!(
125123
locations_before_restart,
126124
locations_after_restart,

0 commit comments

Comments
 (0)