]> git.nega.tv - josh/narcissus/commitdiff
misc: Fix clippy lints
authorJoshua Simmons <josh@nega.tv>
Thu, 9 Oct 2025 17:40:48 +0000 (19:40 +0200)
committerJoshua Simmons <josh@nega.tv>
Thu, 9 Oct 2025 17:45:22 +0000 (19:45 +0200)
engine/narcissus-core/src/arena.rs
engine/narcissus-core/src/obj.rs
engine/narcissus-core/src/pool.rs
engine/narcissus-core/src/svg.rs
engine/narcissus-gpu/src/frame_counter.rs
engine/narcissus-gpu/src/lib.rs
engine/narcissus-gpu/src/mapped_buffer.rs
engine/narcissus-sqlite/src/lib.rs
title/shark/src/draw.rs

index 3703efa60ba895d44591154a3cbc59217b6ac24d..d33b91d9e3d2d0a6db722d0187ab33130e933feb 100644 (file)
@@ -505,7 +505,8 @@ impl<const STACK_CAP: usize> HybridArena<STACK_CAP> {
     pub fn new() -> Self {
         // Ideally we'd pad `STACK_CAP` out to the alignment, avoiding wasting any
         // space, but we can't do maffs with constants just yet, so abort instead.
-        debug_assert!(STACK_CAP % std::mem::align_of::<PageFooter>() == 0);
+        debug_assert!(STACK_CAP.is_multiple_of(std::mem::align_of::<PageFooter>()));
+
         Self {
             data: MaybeUninit::uninit(),
             footer: Cell::new(PageFooter {
index 49734d1d309c8106c21cb3aab5274a454be77336..715914dc99d16d5fde791832ef4ef8f9695f9aa0 100644 (file)
@@ -245,10 +245,7 @@ where
             let remainder = self.cap - self.pos;
 
             if remainder == MAX_LINE_SIZE {
-                return Err(Error::Io(std::io::Error::new(
-                    std::io::ErrorKind::Other,
-                    "line too long",
-                )));
+                return Err(Error::Io(std::io::Error::other("line too long")));
             }
 
             if remainder != 0 {
index 4a9fa7ac4ef5c4b1b0978aaecebfe5550969cc14..a13d54e8cf2a6300f37aa323869653d8d03150b5 100644 (file)
@@ -602,13 +602,13 @@ impl<T> Pool<T> {
     pub fn remove(&mut self, handle: Handle) -> Option<T> {
         let (generation, slot_index) = handle.decode(self.decode_multiplier);
 
-        if let Some(slot) = self.slots.get_mut(slot_index) {
-            if slot.generation() == generation {
-                self.free_slots.push(slot_index);
-                let value_index = slot.value_index();
-                slot.set_value_index(ValueIndex::invalid());
-                return Some(self.values.swap_remove(value_index, &mut self.slots));
-            }
+        if let Some(slot) = self.slots.get_mut(slot_index)
+            && slot.generation() == generation
+        {
+            self.free_slots.push(slot_index);
+            let value_index = slot.value_index();
+            slot.set_value_index(ValueIndex::invalid());
+            return Some(self.values.swap_remove(value_index, &mut self.slots));
         }
 
         None
@@ -618,10 +618,10 @@ impl<T> Pool<T> {
     pub fn get_mut(&mut self, handle: Handle) -> Option<&mut T> {
         let (generation, slot_index) = handle.decode(self.decode_multiplier);
 
-        if let Some(slot) = self.slots.get(slot_index) {
-            if slot.generation() == generation {
-                return Some(self.values.get_mut(slot.value_index()));
-            }
+        if let Some(slot) = self.slots.get(slot_index)
+            && slot.generation() == generation
+        {
+            return Some(self.values.get_mut(slot.value_index()));
         }
 
         None
@@ -631,10 +631,10 @@ impl<T> Pool<T> {
     pub fn get(&self, handle: Handle) -> Option<&T> {
         let (generation, slot_index) = handle.decode(self.decode_multiplier);
 
-        if let Some(slot) = self.slots.get(slot_index) {
-            if slot.generation() == generation {
-                return Some(self.values.get(slot.value_index()));
-            }
+        if let Some(slot) = self.slots.get(slot_index)
+            && slot.generation() == generation
+        {
+            return Some(self.values.get(slot.value_index()));
         }
 
         None
index 1367cab28c1614f1df560bdbb088c60b70b08ed1..532dc71c4e1828c0d67a466aea744a1c364f0258 100644 (file)
@@ -48,7 +48,7 @@ pub fn svg_end() -> SvgEnd {
     SvgEnd
 }
 
-pub fn text<T>(x: f32, y: f32, size: f32, style: Style, text: &T) -> Text<T>
+pub fn text<T>(x: f32, y: f32, size: f32, style: Style, text: &T) -> Text<'_, T>
 where
     T: fmt::Display,
 {
index 983a097cb8b1276add153797721314d7ce206e62..4f4ec426812b0afe46d9423b02ef4c7b5403c395 100644 (file)
@@ -22,7 +22,7 @@ impl FrameCounter {
         self.value.load(Ordering::Relaxed)
     }
 
-    pub fn acquire(&self, device_addr: usize) -> Frame {
+    pub fn acquire(&self, device_addr: usize) -> Frame<'_> {
         let old_frame_counter = self.value.fetch_add(1, Ordering::SeqCst);
         assert!(
             old_frame_counter & 1 == 1,
index 31c824bde7488f6e1c6cbe8cf0e67d518d545a78..477a284f7e6914345452fb9a87595a81e18c59a6 100644 (file)
@@ -549,7 +549,7 @@ impl BindDesc<'_> {
     pub const fn with_immutable_samplers(
         stages: ShaderStageFlags,
         immutable_samplers: &[Sampler],
-    ) -> BindDesc {
+    ) -> BindDesc<'_> {
         BindDesc {
             slot: !0,
             stages,
@@ -1100,7 +1100,7 @@ pub trait Device {
 
     fn wait_idle(&self);
 
-    fn begin_frame(&self) -> Frame;
+    fn begin_frame(&self) -> Frame<'_>;
 
     fn end_frame<'device>(&'device self, frame: Frame<'device>);
 }
index 9bb24c1a3af3f292347f678c4abb6ab48a7771c6..d309b83a1dfe5ded7a1dfac8ee18fc7f8caa972b 100644 (file)
@@ -66,7 +66,7 @@ pub struct PersistentBuffer<'a> {
 }
 
 impl PersistentBuffer<'_> {
-    pub fn to_arg(&self) -> BufferArg {
+    pub fn to_arg(&self) -> BufferArg<'_> {
         BufferArg::Persistent(self)
     }
 
@@ -99,7 +99,7 @@ pub struct TransientBuffer<'a> {
 }
 
 impl TransientBuffer<'_> {
-    pub fn to_arg(&self) -> BufferArg {
+    pub fn to_arg(&self) -> BufferArg<'_> {
         BufferArg::Transient(self)
     }
 
index 99d541c5a1fff201532045736d91fb954a657c0e..babecc38854dfb5597005f56ea7c5db8a872e0c9 100644 (file)
@@ -345,7 +345,7 @@ impl<'a> Query<'a> {
         }
     }
 
-    pub fn fetch(&mut self) -> Rows {
+    pub fn fetch(&mut self) -> Rows<'_> {
         Rows {
             statement: Some(self.statement),
         }
@@ -364,7 +364,7 @@ impl Statement<'_> {
         NonZeroI32::new(index)
     }
 
-    pub fn query(&mut self) -> Query {
+    pub fn query(&mut self) -> Query<'_> {
         Query { statement: self }
     }
 }
index 0ad89a2565c47a56b91d5c0e3efb8070fe4f01ce..bc77c01df9a907af135faa2bdfcbd663df566274 100644 (file)
@@ -50,7 +50,7 @@ impl<'a> Index<ModelRes> for Models<'a> {
 
 impl<'a> Models<'a> {
     pub fn load(gpu: &'a Gpu) -> Models<'a> {
-        fn load_model<P>(gpu: &Gpu, path: P) -> Model
+        fn load_model<P>(gpu: &Gpu, path: P) -> Model<'_>
         where
             P: AsRef<Path>,
         {