Skip to content

Commit

Permalink
Fix Clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
udoprog committed Dec 19, 2024
1 parent 1d377bf commit 1a45e84
Show file tree
Hide file tree
Showing 45 changed files with 99 additions and 93 deletions.
10 changes: 5 additions & 5 deletions crates/rune-alloc/src/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1978,7 +1978,7 @@ impl<K, V> ExactSizeIterator for IterMut<'_, K, V> {

impl<K, V> FusedIterator for IterMut<'_, K, V> {}

impl<'a, K, V> IterMut<'a, K, V> {
impl<K, V> IterMut<'_, K, V> {
/// Returns an iterator of references over the remaining items.
#[inline]
pub(super) fn iter(&self) -> Iter<'_, K, V> {
Expand Down Expand Up @@ -2017,7 +2017,7 @@ impl<K, V, A: Allocator> Drop for IntoIter<K, V, A> {
fn drop(&mut self) {
struct DropGuard<'a, K, V, A: Allocator>(&'a mut IntoIter<K, V, A>);

impl<'a, K, V, A: Allocator> Drop for DropGuard<'a, K, V, A> {
impl<K, V, A: Allocator> Drop for DropGuard<'_, K, V, A> {
fn drop(&mut self) {
// Continue the same loop we perform below. This only runs when unwinding, so we
// don't have to care about panics this time (they'll abort).
Expand Down Expand Up @@ -2272,7 +2272,7 @@ where
}
}

impl<'a, K, V> ExtractIfInner<'a, K, V> {
impl<K, V> ExtractIfInner<'_, K, V> {
/// Allow Debug implementations to predict the next element.
pub(super) fn peek(&self) -> Option<(&K, &V)> {
let edge = self.cur_leaf_edge.as_ref()?;
Expand Down Expand Up @@ -3270,7 +3270,7 @@ impl<'a, K, V> Cursor<'a, K, V> {
}
}

impl<'a, K, V, A> CursorMut<'a, K, V, A> {
impl<K, V, A> CursorMut<'_, K, V, A> {
/// Moves the cursor to the next element of the `BTreeMap`.
///
/// If the cursor is pointing to the "ghost" non-element then this will move it to
Expand Down Expand Up @@ -3409,7 +3409,7 @@ impl<'a, K, V, A> CursorMut<'a, K, V, A> {
}

// Now the tree editing operations
impl<'a, K: Ord, V, A: Allocator> CursorMut<'a, K, V, A> {
impl<K: Ord, V, A: Allocator> CursorMut<'_, K, V, A> {
/// Inserts a new element into the `BTreeMap` after the current one.
///
/// If the cursor is pointing at the "ghost" non-element then the new element is
Expand Down
2 changes: 1 addition & 1 deletion crates/rune-alloc/src/btree/map/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl<K: Debug + Ord, V: Debug, A: Allocator> Debug for OccupiedError<'_, K, V, A
}
}

impl<'a, K: Debug + Ord, V: Debug, A: Allocator> fmt::Display for OccupiedError<'a, K, V, A> {
impl<K: Debug + Ord, V: Debug, A: Allocator> fmt::Display for OccupiedError<'_, K, V, A> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
Expand Down
14 changes: 7 additions & 7 deletions crates/rune-alloc/src/btree/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ impl<BorrowType, K, V> NodeRef<BorrowType, K, V, marker::Internal> {
}
}

impl<'a, K, V> NodeRef<marker::Mut<'a>, K, V, marker::Internal> {
impl<K, V> NodeRef<marker::Mut<'_>, K, V, marker::Internal> {
/// Borrows exclusive access to the data of an internal node.
fn as_internal_mut(&mut self) -> &mut InternalNode<K, V> {
let ptr = Self::as_internal_ptr(self);
Expand Down Expand Up @@ -629,7 +629,7 @@ impl<'a, K: 'a, V: 'a, Type> NodeRef<marker::Mut<'a>, K, V, Type> {
}
}

impl<'a, K, V> NodeRef<marker::Mut<'a>, K, V, marker::Internal> {
impl<K, V> NodeRef<marker::Mut<'_>, K, V, marker::Internal> {
/// # Safety
/// Every item returned by `range` is a valid edge index for the node.
unsafe fn correct_childrens_parent_links<R: Iterator<Item = usize>>(&mut self, range: R) {
Expand Down Expand Up @@ -934,7 +934,7 @@ impl<BorrowType, K, V, NodeType, HandleType>
}
}

impl<'a, K, V, NodeType, HandleType> Handle<NodeRef<marker::Mut<'a>, K, V, NodeType>, HandleType> {
impl<K, V, NodeType, HandleType> Handle<NodeRef<marker::Mut<'_>, K, V, NodeType>, HandleType> {
/// Temporarily takes out another mutable handle on the same location. Beware, as
/// this method is very dangerous, doubly so since it might not immediately appear
/// dangerous.
Expand Down Expand Up @@ -1105,7 +1105,7 @@ impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, mark
}
}

impl<'a, K, V> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Internal>, marker::Edge> {
impl<K, V> Handle<NodeRef<marker::Mut<'_>, K, V, marker::Internal>, marker::Edge> {
/// Fixes the parent pointer and index in the child node that this edge
/// links to. This is useful when the ordering of edges has been changed,
fn correct_parent_link(self) {
Expand Down Expand Up @@ -1989,10 +1989,10 @@ pub(crate) mod marker {
const TRAVERSAL_PERMIT: bool = false;
}
impl BorrowType for Dying {}
impl<'a> BorrowType for Immut<'a> {}
impl BorrowType for Immut<'_> {}
impl BorrowType for Raw {}
impl<'a> BorrowType for Mut<'a> {}
impl<'a> BorrowType for ValMut<'a> {}
impl BorrowType for Mut<'_> {}
impl BorrowType for ValMut<'_> {}
impl BorrowType for DormantMut {}

pub(crate) enum KV {}
Expand Down
4 changes: 2 additions & 2 deletions crates/rune-alloc/src/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1365,9 +1365,9 @@ where
}
}

impl<'a, T, F, A: Allocator> Iterator for ExtractIf<'_, T, F, A>
impl<T, F, A: Allocator> Iterator for ExtractIf<'_, T, F, A>
where
F: 'a + FnMut(&T) -> bool,
F: FnMut(&T) -> bool,
{
type Item = T;

Expand Down
10 changes: 5 additions & 5 deletions crates/rune-alloc/src/hashbrown/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4707,7 +4707,7 @@ impl<'a, K, Q: ?Sized> KeyOrRef<'a, K, Q> {
}
}

impl<'a, K: Borrow<Q>, Q: ?Sized> AsRef<Q> for KeyOrRef<'a, K, Q> {
impl<K: Borrow<Q>, Q: ?Sized> AsRef<Q> for KeyOrRef<'_, K, Q> {
fn as_ref(&self) -> &Q {
match self {
Self::Borrowed(borrowed) => borrowed,
Expand Down Expand Up @@ -4771,7 +4771,7 @@ pub struct OccupiedEntryRef<'a, 'b, K, Q: ?Sized, V, S, A: Allocator = Global> {
table: &'a mut HashMap<K, V, S, A>,
}

unsafe impl<'a, 'b, K, Q, V, S, A> Send for OccupiedEntryRef<'a, 'b, K, Q, V, S, A>
unsafe impl<K, Q, V, S, A> Send for OccupiedEntryRef<'_, '_, K, Q, V, S, A>
where
K: Send,
Q: Sync + ?Sized,
Expand All @@ -4780,7 +4780,7 @@ where
A: Send + Allocator,
{
}
unsafe impl<'a, 'b, K, Q, V, S, A> Sync for OccupiedEntryRef<'a, 'b, K, Q, V, S, A>
unsafe impl<K, Q, V, S, A> Sync for OccupiedEntryRef<'_, '_, K, Q, V, S, A>
where
K: Sync,
Q: Sync + ?Sized,
Expand Down Expand Up @@ -4889,7 +4889,7 @@ impl<K: Debug, V: Debug, S, A: Allocator> Debug for OccupiedError<'_, K, V, S, A
}
}

impl<'a, K: Debug, V: Debug, S, A: Allocator> fmt::Display for OccupiedError<'a, K, V, S, A> {
impl<K: Debug, V: Debug, S, A: Allocator> fmt::Display for OccupiedError<'_, K, V, S, A> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
Expand Down Expand Up @@ -5174,7 +5174,7 @@ impl<K, V: Debug> fmt::Debug for ValuesMut<'_, K, V> {
}
}

impl<'a, K, V, A: Allocator> Iterator for Drain<'a, K, V, A> {
impl<K, V, A: Allocator> Iterator for Drain<'_, K, V, A> {
type Item = (K, V);

#[cfg_attr(feature = "inline-more", inline)]
Expand Down
1 change: 0 additions & 1 deletion crates/rune-alloc/src/hashbrown/raw/bitmask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ impl BitMaskIter {
/// Returns the bit's previous state.
#[inline]
#[allow(clippy::cast_ptr_alignment)]

pub(crate) unsafe fn flip(&mut self, index: usize) -> bool {
// NOTE: The + BITMASK_STRIDE - 1 is to set the high bit.
let mask = 1 << (index * BITMASK_STRIDE + BITMASK_STRIDE - 1);
Expand Down
2 changes: 1 addition & 1 deletion crates/rune-alloc/src/hashbrown/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ mod set {
where
A: Allocator;

impl<'a, 'de, T, S, A> Visitor<'de> for SeqInPlaceVisitor<'a, T, S, A>
impl<'de, T, S, A> Visitor<'de> for SeqInPlaceVisitor<'_, T, S, A>
where
T: Deserialize<'de> + Eq + Hash,
S: BuildHasher + Default,
Expand Down
2 changes: 1 addition & 1 deletion crates/rune-alloc/src/hashbrown/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1676,7 +1676,7 @@ impl<'a, K> Iterator for Iter<'a, K> {
self.iter.size_hint()
}
}
impl<'a, K> ExactSizeIterator for Iter<'a, K> {
impl<K> ExactSizeIterator for Iter<'_, K> {
#[cfg_attr(feature = "inline-more", inline)]
fn len(&self) -> usize {
self.iter.len()
Expand Down
4 changes: 2 additions & 2 deletions crates/rune-alloc/src/serde/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ mod seed {
/// Wraps a mutable reference and calls deserialize_in_place on it.
pub struct InPlaceSeed<'a, T: 'a>(pub &'a mut T);

impl<'a, 'de, T> DeserializeSeed<'de> for InPlaceSeed<'a, T>
impl<'de, T> DeserializeSeed<'de> for InPlaceSeed<'_, T>
where
T: Deserialize<'de>,
{
Expand Down Expand Up @@ -117,7 +117,7 @@ where
{
struct VecInPlaceVisitor<'a, T: 'a>(&'a mut Vec<T>);

impl<'a, 'de, T> Visitor<'de> for VecInPlaceVisitor<'a, T>
impl<'de, T> Visitor<'de> for VecInPlaceVisitor<'_, T>
where
T: Deserialize<'de>,
{
Expand Down
2 changes: 1 addition & 1 deletion crates/rune-alloc/src/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ pub(crate) mod hack {
num_init: usize,
}

impl<'a, T, A: Allocator> Drop for DropGuard<'a, T, A> {
impl<T, A: Allocator> Drop for DropGuard<'_, T, A> {
#[inline]
fn drop(&mut self) {
// SAFETY:
Expand Down
8 changes: 4 additions & 4 deletions crates/rune-alloc/src/string/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1216,7 +1216,7 @@ impl<A: Allocator> String<A> {
del_bytes: usize,
}

impl<'a, A: Allocator> Drop for SetLenOnDrop<'a, A> {
impl<A: Allocator> Drop for SetLenOnDrop<'_, A> {
fn drop(&mut self) {
let new_len = self.idx - self.del_bytes;
debug_assert!(new_len <= self.s.len());
Expand Down Expand Up @@ -2279,7 +2279,7 @@ impl<A: Allocator> Drop for Drain<'_, A> {
}
}

impl<'a, A: Allocator> Drain<'a, A> {
impl<A: Allocator> Drain<'_, A> {
/// Returns the remaining (sub)string of this iterator as a slice.
///
/// # Examples
Expand All @@ -2300,13 +2300,13 @@ impl<'a, A: Allocator> Drain<'a, A> {
}
}

impl<'a, A: Allocator> AsRef<str> for Drain<'a, A> {
impl<A: Allocator> AsRef<str> for Drain<'_, A> {
fn as_ref(&self) -> &str {
self.as_str()
}
}

impl<'a, A: Allocator> AsRef<[u8]> for Drain<'a, A> {
impl<A: Allocator> AsRef<[u8]> for Drain<'_, A> {
fn as_ref(&self) -> &[u8] {
self.as_str().as_bytes()
}
Expand Down
6 changes: 3 additions & 3 deletions crates/rune-alloc/src/string/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl<'de> de::Deserialize<'de> for Box<str> {
}
}

impl<'de, 'a, T: ?Sized> de::Deserialize<'de> for Cow<'a, T>
impl<'de, T: ?Sized> de::Deserialize<'de> for Cow<'_, T>
where
T: TryToOwned,
T::Owned: de::Deserialize<'de>,
Expand All @@ -58,7 +58,7 @@ where
struct StringVisitor;
struct StringInPlaceVisitor<'a>(&'a mut String);

impl<'de> de::Visitor<'de> for StringVisitor {
impl de::Visitor<'_> for StringVisitor {
type Value = String;

fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
Expand Down Expand Up @@ -105,7 +105,7 @@ impl<'de> de::Visitor<'de> for StringVisitor {
}
}

impl<'a, 'de> de::Visitor<'de> for StringInPlaceVisitor<'a> {
impl de::Visitor<'_> for StringInPlaceVisitor<'_> {
type Value = ();

fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
Expand Down
6 changes: 3 additions & 3 deletions crates/rune-alloc/src/vec/drain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl<T: fmt::Debug, A: Allocator> fmt::Debug for Drain<'_, T, A> {
}
}

impl<'a, T, A: Allocator> Drain<'a, T, A> {
impl<T, A: Allocator> Drain<'_, T, A> {
/// Returns the remaining items of this iterator as a slice.
///
/// # Examples
Expand Down Expand Up @@ -130,7 +130,7 @@ impl<'a, T, A: Allocator> Drain<'a, T, A> {
}
}

impl<'a, T, A: Allocator> AsRef<[T]> for Drain<'a, T, A> {
impl<T, A: Allocator> AsRef<[T]> for Drain<'_, T, A> {
fn as_ref(&self) -> &[T] {
self.as_slice()
}
Expand Down Expand Up @@ -168,7 +168,7 @@ impl<T, A: Allocator> Drop for Drain<'_, T, A> {
/// Moves back the un-`Drain`ed elements to restore the original `Vec`.
struct DropGuard<'r, 'a, T, A: Allocator>(&'r mut Drain<'a, T, A>);

impl<'r, 'a, T, A: Allocator> Drop for DropGuard<'r, 'a, T, A> {
impl<T, A: Allocator> Drop for DropGuard<'_, '_, T, A> {
fn drop(&mut self) {
if self.0.tail_len > 0 {
unsafe {
Expand Down
2 changes: 1 addition & 1 deletion crates/rune-alloc/src/vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1629,7 +1629,7 @@ impl<T, A: Allocator> Vec<T, A> {
vec: &'a mut Vec<T, A>,
}

impl<'a, T, A: Allocator> Drop for FillGapOnDrop<'a, T, A> {
impl<T, A: Allocator> Drop for FillGapOnDrop<'_, T, A> {
fn drop(&mut self) {
/* This code gets executed when `same_bucket` panics */

Expand Down
2 changes: 1 addition & 1 deletion crates/rune-alloc/src/vec_deque/drain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl<T, A: Allocator> Drop for Drain<'_, T, A> {
fn drop(&mut self) {
struct DropGuard<'r, 'a, T, A: Allocator>(&'r mut Drain<'a, T, A>);

impl<'r, 'a, T, A: Allocator> Drop for DropGuard<'r, 'a, T, A> {
impl<T, A: Allocator> Drop for DropGuard<'_, '_, T, A> {
fn drop(&mut self) {
if self.0.remaining != 0 {
unsafe {
Expand Down
4 changes: 2 additions & 2 deletions crates/rune-alloc/src/vec_deque/into_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl<T, A: Allocator> Iterator for IntoIter<T, A> {
consumed: usize,
}

impl<'a, T, A: Allocator> Drop for Guard<'a, T, A> {
impl<T, A: Allocator> Drop for Guard<'_, T, A> {
fn drop(&mut self) {
self.deque.len -= self.consumed;
self.deque.head = self.deque.to_physical_idx(self.consumed);
Expand Down Expand Up @@ -134,7 +134,7 @@ impl<T, A: Allocator> DoubleEndedIterator for IntoIter<T, A> {
consumed: usize,
}

impl<'a, T, A: Allocator> Drop for Guard<'a, T, A> {
impl<T, A: Allocator> Drop for Guard<'_, T, A> {
fn drop(&mut self) {
self.deque.len -= self.consumed;
}
Expand Down
4 changes: 2 additions & 2 deletions crates/rune-alloc/src/vec_deque/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl<T, A: Allocator> Drop for VecDeque<T, A> {
/// during unwinding).
struct Dropper<'a, T>(&'a mut [T]);

impl<'a, T> Drop for Dropper<'a, T> {
impl<T> Drop for Dropper<'_, T> {
fn drop(&mut self) {
unsafe {
ptr::drop_in_place(self.0);
Expand Down Expand Up @@ -923,7 +923,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
/// during unwinding).
struct Dropper<'a, T>(&'a mut [T]);

impl<'a, T> Drop for Dropper<'a, T> {
impl<T> Drop for Dropper<'_, T> {
fn drop(&mut self) {
unsafe {
ptr::drop_in_place(self.0);
Expand Down
2 changes: 1 addition & 1 deletion crates/rune-core/src/item/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl<'a> Iterator for Iter<'a> {
}
}

impl<'a> DoubleEndedIterator for Iter<'a> {
impl DoubleEndedIterator for Iter<'_> {
fn next_back(&mut self) -> Option<Self::Item> {
if self.content.is_empty() {
return None;
Expand Down
2 changes: 1 addition & 1 deletion crates/rune/src/ast/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl IntoExpectation for &Path {
}

/// Resolve implementation for path which "stringifies" it.
impl<'a> Resolve<'a> for Path {
impl Resolve<'_> for Path {
type Output = Box<str>;

fn resolve(&self, cx: ResolveContext<'_>) -> Result<Self::Output> {
Expand Down
2 changes: 1 addition & 1 deletion crates/rune/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ struct CompileVisitorGroup<'a> {
visitors: Vec<&'a mut dyn compile::CompileVisitor>,
}

impl<'a> compile::CompileVisitor for CompileVisitorGroup<'a> {
impl compile::CompileVisitor for CompileVisitorGroup<'_> {
fn register_meta(&mut self, meta: compile::MetaRef<'_>) -> Result<(), MetaError> {
for v in self.visitors.iter_mut() {
v.register_meta(meta)?;
Expand Down
2 changes: 1 addition & 1 deletion crates/rune/src/compile/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ pub(crate) struct ParseAll<'this, 'a, T> {
_marker: PhantomData<T>,
}

impl<'this, 'a, T> Iterator for ParseAll<'this, 'a, T>
impl<'a, T> Iterator for ParseAll<'_, 'a, T>
where
T: Attribute + Parse,
{
Expand Down
Loading

0 comments on commit 1a45e84

Please sign in to comment.