From 1972c83fc9d007e3d0f9bdc2aeb9bf6d67cc2157 Mon Sep 17 00:00:00 2001 From: Gwilym Inzani Date: Sat, 5 Oct 2024 21:48:32 +0100 Subject: [PATCH 1/5] cargo clippy --fix --- agb/src/display/blend.rs | 2 +- agb/src/display/font.rs | 4 ++-- agb/src/display/object/font/preprocess.rs | 2 +- agb/src/display/object/unmanaged/object.rs | 2 +- agb/src/display/tiled/map.rs | 6 +++--- agb/src/display/window.rs | 2 +- agb/src/dma.rs | 6 +++--- agb/src/panics_render/text.rs | 2 +- agb/src/save/mod.rs | 2 +- agb/src/sync.rs | 8 ++++---- 10 files changed, 18 insertions(+), 18 deletions(-) diff --git a/agb/src/display/blend.rs b/agb/src/display/blend.rs index 01443e632..35bbd70c9 100644 --- a/agb/src/display/blend.rs +++ b/agb/src/display/blend.rs @@ -60,7 +60,7 @@ pub struct BlendLayer<'blend, 'gba> { layer: Layer, } -impl<'gba> BlendLayer<'_, 'gba> { +impl BlendLayer<'_, '_> { /// Set whether a background is enabled for blending on this layer. pub fn set_background_enable(&mut self, background: BackgroundID, enable: bool) -> &mut Self { self.blend diff --git a/agb/src/display/font.rs b/agb/src/display/font.rs index ae3bde95d..389abe206 100644 --- a/agb/src/display/font.rs +++ b/agb/src/display/font.rs @@ -135,7 +135,7 @@ pub struct TextWriter<'a, 'b> { bg: &'a mut RegularMap, } -impl<'a, 'b> Write for TextWriter<'a, 'b> { +impl Write for TextWriter<'_, '_> { fn write_str(&mut self, text: &str) -> Result<(), Error> { for c in text.chars() { self.text_renderer.write_char( @@ -150,7 +150,7 @@ impl<'a, 'b> Write for TextWriter<'a, 'b> { } } -impl<'a, 'b> TextWriter<'a, 'b> { +impl TextWriter<'_, '_> { pub fn commit(self) { self.text_renderer.commit(self.bg, self.vram_manager); } diff --git a/agb/src/display/object/font/preprocess.rs b/agb/src/display/object/font/preprocess.rs index 714350741..f91359c71 100644 --- a/agb/src/display/object/font/preprocess.rs +++ b/agb/src/display/object/font/preprocess.rs @@ -134,7 +134,7 @@ impl Line { } } -impl<'pre> Iterator for Lines<'pre> { +impl Iterator for Lines<'_> { type Item = Line; fn next(&mut self) -> Option { diff --git a/agb/src/display/object/unmanaged/object.rs b/agb/src/display/object/unmanaged/object.rs index f8ebcedd9..d4497c3bc 100644 --- a/agb/src/display/object/unmanaged/object.rs +++ b/agb/src/display/object/unmanaged/object.rs @@ -70,7 +70,7 @@ pub struct OamIterator<'oam> { frame_data: &'oam UnsafeCell, } -impl<'oam> OamIterator<'oam> { +impl OamIterator<'_> { /// Sets the next oam slot with the provided `object`. /// /// Is equivalent to the following: diff --git a/agb/src/display/tiled/map.rs b/agb/src/display/tiled/map.rs index 5cd342952..248e5693b 100644 --- a/agb/src/display/tiled/map.rs +++ b/agb/src/display/tiled/map.rs @@ -487,7 +487,7 @@ pub struct MapLoan<'a, T> { screenblock_list: &'a RefCell>, } -impl<'a, T> Deref for MapLoan<'a, T> { +impl Deref for MapLoan<'_, T> { type Target = T; fn deref(&self) -> &Self::Target { @@ -495,7 +495,7 @@ impl<'a, T> Deref for MapLoan<'a, T> { } } -impl<'a, T> DerefMut for MapLoan<'a, T> { +impl DerefMut for MapLoan<'_, T> { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.map } @@ -526,7 +526,7 @@ impl<'a, T> MapLoan<'a, T> { } } -impl<'a, T> Drop for MapLoan<'a, T> { +impl Drop for MapLoan<'_, T> { fn drop(&mut self) { self.map_list .borrow_mut() diff --git a/agb/src/display/window.rs b/agb/src/display/window.rs index f9accbd1c..e248d1f22 100644 --- a/agb/src/display/window.rs +++ b/agb/src/display/window.rs @@ -31,7 +31,7 @@ pub enum WinIn { Win1, } -impl<'gba> Windows<'gba> { +impl Windows<'_> { pub(crate) fn new() -> Self { let s = Self { wins: [MovableWindow::new(0), MovableWindow::new(1)], diff --git a/agb/src/dma.rs b/agb/src/dma.rs index a16fc0216..4f17e2cda 100644 --- a/agb/src/dma.rs +++ b/agb/src/dma.rs @@ -24,7 +24,7 @@ pub struct Dmas<'gba> { pub dma3: Dma, } -impl<'gba> Dmas<'gba> { +impl Dmas<'_> { unsafe fn new() -> Self { Self { phantom: PhantomData, @@ -137,7 +137,7 @@ where phantom: PhantomData<&'a ()>, } -impl<'a, T> DmaTransferHandle<'a, T> +impl DmaTransferHandle<'_, T> where T: Copy, { @@ -150,7 +150,7 @@ where } } -impl<'a, T> Drop for DmaTransferHandle<'a, T> +impl Drop for DmaTransferHandle<'_, T> where T: Copy, { diff --git a/agb/src/panics_render/text.rs b/agb/src/panics_render/text.rs index c0d09aec9..0438da14b 100644 --- a/agb/src/panics_render/text.rs +++ b/agb/src/panics_render/text.rs @@ -88,7 +88,7 @@ impl<'bitmap, 'gba> BitmapTextRender<'bitmap, 'gba> { } } -impl<'bitmap, 'gba> Write for BitmapTextRender<'bitmap, 'gba> { +impl Write for BitmapTextRender<'_, '_> { fn write_str(&mut self, s: &str) -> core::fmt::Result { for c in s.chars() { self.render_char(c); diff --git a/agb/src/save/mod.rs b/agb/src/save/mod.rs index 7adb1d718..e3c05d544 100644 --- a/agb/src/save/mod.rs +++ b/agb/src/save/mod.rs @@ -305,7 +305,7 @@ pub struct SavePreparedBlock<'a> { parent: &'a mut SaveData, range: Range, } -impl<'a> SavePreparedBlock<'a> { +impl SavePreparedBlock<'_> { /// Writes a given buffer into the save media. /// /// Multiple overlapping writes to the same memory range without a separate diff --git a/agb/src/sync.rs b/agb/src/sync.rs index d614662f5..2ee996bc7 100644 --- a/agb/src/sync.rs +++ b/agb/src/sync.rs @@ -53,7 +53,7 @@ unsafe impl Sync for RawLock {} /// A guard representing an active lock on an [`RawLock`]. pub struct RawLockGuard<'a>(&'a RawLock); -impl<'a> Drop for RawLockGuard<'a> { +impl Drop for RawLockGuard<'_> { fn drop(&mut self) { self.0.raw_unlock(); } @@ -103,18 +103,18 @@ pub struct LockGuard<'a, T> { underlying: &'a Lock, ptr: *mut T, } -impl<'a, T> Drop for LockGuard<'a, T> { +impl Drop for LockGuard<'_, T> { fn drop(&mut self) { self.underlying.raw.raw_unlock(); } } -impl<'a, T> Deref for LockGuard<'a, T> { +impl Deref for LockGuard<'_, T> { type Target = T; fn deref(&self) -> &Self::Target { unsafe { &*self.ptr } } } -impl<'a, T> DerefMut for LockGuard<'a, T> { +impl DerefMut for LockGuard<'_, T> { fn deref_mut(&mut self) -> &mut Self::Target { unsafe { &mut *self.ptr } } From 828339779b775ae2f0e47f06959d168409022dc9 Mon Sep 17 00:00:00 2001 From: Gwilym Inzani Date: Sat, 5 Oct 2024 21:50:46 +0100 Subject: [PATCH 2/5] More clippy fixes --- tracker/agb-tracker/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tracker/agb-tracker/src/lib.rs b/tracker/agb-tracker/src/lib.rs index c957f21d4..dbcd7270f 100644 --- a/tracker/agb-tracker/src/lib.rs +++ b/tracker/agb-tracker/src/lib.rs @@ -719,7 +719,7 @@ impl SoundChannel for agb::sound::mixer::SoundChannel { } #[cfg(feature = "agb")] -impl<'gba> Mixer for agb::sound::mixer::Mixer<'gba> { +impl Mixer for agb::sound::mixer::Mixer<'_> { type ChannelId = agb::sound::mixer::ChannelId; type SoundChannel = agb::sound::mixer::SoundChannel; From 9648d3e22a8d0c3a45da38db36713308986c2ed7 Mon Sep 17 00:00:00 2001 From: Gwilym Inzani Date: Sat, 5 Oct 2024 22:02:10 +0100 Subject: [PATCH 3/5] Fix clippy lints in games too --- examples/the-dungeon-puzzlers-lament/src/game.rs | 2 +- examples/the-hat-chooses-the-wizard/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/the-dungeon-puzzlers-lament/src/game.rs b/examples/the-dungeon-puzzlers-lament/src/game.rs index caa8a4c32..211d688d6 100644 --- a/examples/the-dungeon-puzzlers-lament/src/game.rs +++ b/examples/the-dungeon-puzzlers-lament/src/game.rs @@ -100,7 +100,7 @@ struct Construction<'a, 'b> { background: &'a mut MapLoan<'b, RegularMap>, } -impl<'a, 'b> Drop for Construction<'a, 'b> { +impl Drop for Construction<'_, '_> { fn drop(&mut self) { self.background.set_visible(false); } diff --git a/examples/the-hat-chooses-the-wizard/src/lib.rs b/examples/the-hat-chooses-the-wizard/src/lib.rs index 359620515..e1e6bd980 100644 --- a/examples/the-hat-chooses-the-wizard/src/lib.rs +++ b/examples/the-hat-chooses-the-wizard/src/lib.rs @@ -273,7 +273,7 @@ struct Map<'a, 'b> { level: &'a Level, } -impl<'a, 'b> Map<'a, 'b> { +impl Map<'_, '_> { pub fn commit_position(&mut self, vram: &mut VRamManager) { self.background.set_pos(vram, self.position.floor()); self.foreground.set_pos(vram, self.position.floor()); From 33c19c18fe28fe529e31e5272572071f08550d1a Mon Sep 17 00:00:00 2001 From: Gwilym Inzani Date: Sat, 5 Oct 2024 22:07:24 +0100 Subject: [PATCH 4/5] For some reason cargo clippy --fix couldn't fix this one --- agb-debug/src/gwilym_encoding.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agb-debug/src/gwilym_encoding.rs b/agb-debug/src/gwilym_encoding.rs index f192c28a4..3b19a814f 100644 --- a/agb-debug/src/gwilym_encoding.rs +++ b/agb-debug/src/gwilym_encoding.rs @@ -46,7 +46,7 @@ impl<'a> GwilymDecodeIter<'a> { } } -impl<'a> Iterator for GwilymDecodeIter<'a> { +impl Iterator for GwilymDecodeIter<'_> { type Item = u32; fn next(&mut self) -> Option { From d109f019ebb20cf856dbb6d33fdef304d7cc6fdc Mon Sep 17 00:00:00 2001 From: Gwilym Inzani Date: Sat, 5 Oct 2024 22:13:38 +0100 Subject: [PATCH 5/5] More lifetimes elided --- agb-hashmap/src/hash_set.rs | 2 +- agb-hashmap/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/agb-hashmap/src/hash_set.rs b/agb-hashmap/src/hash_set.rs index b0cd44e18..afab5f479 100644 --- a/agb-hashmap/src/hash_set.rs +++ b/agb-hashmap/src/hash_set.rs @@ -387,7 +387,7 @@ impl<'a, K, ALLOCATOR: ClonableAllocator> Iterator for Iter<'a, K, ALLOCATOR> { } } -impl<'a, K, ALLOCATOR: ClonableAllocator> ExactSizeIterator for Iter<'a, K, ALLOCATOR> {} +impl ExactSizeIterator for Iter<'_, K, ALLOCATOR> {} impl FromIterator for HashSet where diff --git a/agb-hashmap/src/lib.rs b/agb-hashmap/src/lib.rs index 715df511b..940df370a 100644 --- a/agb-hashmap/src/lib.rs +++ b/agb-hashmap/src/lib.rs @@ -528,7 +528,7 @@ impl<'a, K, V, ALLOCATOR: ClonableAllocator> Iterator for Iter<'a, K, V, ALLOCAT } } -impl<'a, K, V, ALLOCATOR: ClonableAllocator> ExactSizeIterator for Iter<'a, K, V, ALLOCATOR> {} +impl ExactSizeIterator for Iter<'_, K, V, ALLOCATOR> {} impl<'a, K, V, ALLOCATOR: ClonableAllocator> IntoIterator for &'a HashMap { type Item = (&'a K, &'a V);