From 30042a073d0c012c26664b2d3b8630334b266384 Mon Sep 17 00:00:00 2001 From: Xiangpeng Hao Date: Mon, 18 Nov 2024 21:49:01 -0600 Subject: [PATCH] clippy --- src/lock.rs | 18 +++++++++--------- src/node_16.rs | 2 +- src/node_256.rs | 2 +- src/node_48.rs | 2 +- src/node_ptr.rs | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/lock.rs b/src/lock.rs index 8a71a5a..be890f5 100644 --- a/src/lock.rs +++ b/src/lock.rs @@ -16,7 +16,7 @@ impl<'a, T: Node> TypedReadGuard<'a, T> { unsafe { &*self.node } } - pub(crate) fn upgrade(self) -> Result, (Self, ArtError)> { + pub(crate) fn upgrade(self) -> Result, (Self, ArtError)> { let new_version = self.version + 0b10; match self .as_ref() @@ -28,20 +28,20 @@ impl<'a, T: Node> TypedReadGuard<'a, T> { Ordering::Release, Ordering::Relaxed, ) { - Ok(_) => Ok(ConcreteWriteGuard { + Ok(_) => Ok(TypedWriteGuard { // SAFETY: this is seems to be unsound, but we (1) acquired write lock, (2) has the right memory ordering. - node: unsafe { &mut *(self.node as *const T as *mut T) }, + node: unsafe { &mut *(self.node as *mut T) }, }), Err(_v) => Err((self, ArtError::VersionNotMatch)), } } } -pub(crate) struct ConcreteWriteGuard<'a, T: Node> { +pub(crate) struct TypedWriteGuard<'a, T: Node> { node: &'a mut T, } -impl<'a, T: Node> ConcreteWriteGuard<'a, T> { +impl TypedWriteGuard<'_, T> { pub(crate) fn as_ref(&self) -> &T { self.node } @@ -58,7 +58,7 @@ impl<'a, T: Node> ConcreteWriteGuard<'a, T> { } } -impl<'a, T: Node> Drop for ConcreteWriteGuard<'a, T> { +impl Drop for TypedWriteGuard<'_, T> { fn drop(&mut self) { self.node .base() @@ -105,7 +105,7 @@ impl<'a> ReadGuard<'a> { TypedReadGuard { version: self.version, - node: unsafe { &*(self.node as *const BaseNode as *const T) }, + node: unsafe { &*(self.node as *const T) }, _pt_node: PhantomData, } } @@ -144,7 +144,7 @@ pub(crate) struct WriteGuard<'a> { node: &'a mut BaseNode, } -impl<'a> WriteGuard<'a> { +impl WriteGuard<'_> { pub(crate) fn as_ref(&self) -> &BaseNode { self.node } @@ -160,7 +160,7 @@ impl<'a> WriteGuard<'a> { } } -impl<'a> Drop for WriteGuard<'a> { +impl Drop for WriteGuard<'_> { fn drop(&mut self) { self.node .type_version_lock_obsolete diff --git a/src/node_16.rs b/src/node_16.rs index 64ab5a7..5b7102a 100644 --- a/src/node_16.rs +++ b/src/node_16.rs @@ -80,7 +80,7 @@ pub(crate) struct Node16Iter<'a> { end_pos: usize, } -impl<'a> Iterator for Node16Iter<'a> { +impl Iterator for Node16Iter<'_> { type Item = (u8, NodePtr); fn next(&mut self) -> Option { diff --git a/src/node_256.rs b/src/node_256.rs index 47720e5..9c929b6 100644 --- a/src/node_256.rs +++ b/src/node_256.rs @@ -47,7 +47,7 @@ pub(crate) struct Node256Iter<'a> { node: &'a Node256, } -impl<'a> Iterator for Node256Iter<'a> { +impl Iterator for Node256Iter<'_> { type Item = (u8, NodePtr); fn next(&mut self) -> Option { diff --git a/src/node_48.rs b/src/node_48.rs index 8820901..ed30c84 100644 --- a/src/node_48.rs +++ b/src/node_48.rs @@ -38,7 +38,7 @@ pub(crate) struct Node48Iter<'a> { node: &'a Node48, } -impl<'a> Iterator for Node48Iter<'a> { +impl Iterator for Node48Iter<'_> { type Item = (u8, NodePtr); fn next(&mut self) -> Option { diff --git a/src/node_ptr.rs b/src/node_ptr.rs index e25f13c..af0bcec 100644 --- a/src/node_ptr.rs +++ b/src/node_ptr.rs @@ -60,7 +60,7 @@ impl AllocatedNode { pub(crate) fn into_note_ptr(self) -> NodePtr { let ptr = self.ptr; std::mem::forget(self); - unsafe { NodePtr::from_node_new(std::mem::transmute(ptr)) } + unsafe { NodePtr::from_node_new(std::mem::transmute::, NonNull>(ptr)) } } }