Skip to content

Commit 658181f

Browse files
ojedaintel-lab-lkp
authored andcommitted
rust: kernel: clean explicit lifetimes that can be elided
In nightly Clippy (i.e. Rust 1.83.0), the `needless_lifetimes` lint has been extended [1] to suggest eliding `impl` lifetimes, e.g. error: the following explicit lifetimes could be elided: 'a --> rust/kernel/list.rs:647:6 | 647 | impl<'a, T: ?Sized + ListItem<ID>, const ID: u64> FusedIterator for Iter<'a, T, ID> {} | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes = note: `-D clippy::needless-lifetimes` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::needless_lifetimes)]` help: elide the lifetimes | 647 - impl<'a, T: ?Sized + ListItem<ID>, const ID: u64> FusedIterator for Iter<'a, T, ID> {} 647 + impl<T: ?Sized + ListItem<ID>, const ID: u64> FusedIterator for Iter<'_, T, ID> {} Thus clean them. Link: rust-lang/rust-clippy#13286 [1] Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent 8cf0b93 commit 658181f

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

rust/kernel/list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ impl<'a, T: ?Sized + ListItem<ID>, const ID: u64> Cursor<'a, T, ID> {
644644
}
645645
}
646646

647-
impl<'a, T: ?Sized + ListItem<ID>, const ID: u64> FusedIterator for Iter<'a, T, ID> {}
647+
impl<T: ?Sized + ListItem<ID>, const ID: u64> FusedIterator for Iter<'_, T, ID> {}
648648

649649
impl<'a, T: ?Sized + ListItem<ID>, const ID: u64> IntoIterator for &'a List<T, ID> {
650650
type IntoIter = Iter<'a, T, ID>;

rust/kernel/rbtree.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -729,13 +729,13 @@ pub struct Cursor<'a, K, V> {
729729
// SAFETY: The [`Cursor`] has exclusive access to both `K` and `V`, so it is sufficient to require them to be `Send`.
730730
// The cursor only gives out immutable references to the keys, but since it has excusive access to those same
731731
// keys, `Send` is sufficient. `Sync` would be okay, but it is more restrictive to the user.
732-
unsafe impl<'a, K: Send, V: Send> Send for Cursor<'a, K, V> {}
732+
unsafe impl<K: Send, V: Send> Send for Cursor<'_, K, V> {}
733733

734734
// SAFETY: The [`Cursor`] gives out immutable references to K and mutable references to V,
735735
// so it has the same thread safety requirements as mutable references.
736-
unsafe impl<'a, K: Sync, V: Sync> Sync for Cursor<'a, K, V> {}
736+
unsafe impl<K: Sync, V: Sync> Sync for Cursor<'_, K, V> {}
737737

738-
impl<'a, K, V> Cursor<'a, K, V> {
738+
impl<K, V> Cursor<'_, K, V> {
739739
/// The current node
740740
pub fn current(&self) -> (&K, &V) {
741741
// SAFETY:
@@ -948,11 +948,11 @@ pub struct Iter<'a, K, V> {
948948

949949
// SAFETY: The [`Iter`] gives out immutable references to K and V, so it has the same
950950
// thread safety requirements as immutable references.
951-
unsafe impl<'a, K: Sync, V: Sync> Send for Iter<'a, K, V> {}
951+
unsafe impl<K: Sync, V: Sync> Send for Iter<'_, K, V> {}
952952

953953
// SAFETY: The [`Iter`] gives out immutable references to K and V, so it has the same
954954
// thread safety requirements as immutable references.
955-
unsafe impl<'a, K: Sync, V: Sync> Sync for Iter<'a, K, V> {}
955+
unsafe impl<K: Sync, V: Sync> Sync for Iter<'_, K, V> {}
956956

957957
impl<'a, K, V> Iterator for Iter<'a, K, V> {
958958
type Item = (&'a K, &'a V);
@@ -983,11 +983,11 @@ pub struct IterMut<'a, K, V> {
983983
// SAFETY: The [`IterMut`] has exclusive access to both `K` and `V`, so it is sufficient to require them to be `Send`.
984984
// The iterator only gives out immutable references to the keys, but since the iterator has excusive access to those same
985985
// keys, `Send` is sufficient. `Sync` would be okay, but it is more restrictive to the user.
986-
unsafe impl<'a, K: Send, V: Send> Send for IterMut<'a, K, V> {}
986+
unsafe impl<K: Send, V: Send> Send for IterMut<'_, K, V> {}
987987

988988
// SAFETY: The [`IterMut`] gives out immutable references to K and mutable references to V, so it has the same
989989
// thread safety requirements as mutable references.
990-
unsafe impl<'a, K: Sync, V: Sync> Sync for IterMut<'a, K, V> {}
990+
unsafe impl<K: Sync, V: Sync> Sync for IterMut<'_, K, V> {}
991991

992992
impl<'a, K, V> Iterator for IterMut<'a, K, V> {
993993
type Item = (&'a K, &'a mut V);

0 commit comments

Comments
 (0)