From: Joshua Simmons Date: Thu, 9 Oct 2025 17:40:48 +0000 (+0200) Subject: misc: Fix clippy lints X-Git-Url: https://git.nega.tv//gitweb.cgi?a=commitdiff_plain;h=6d8c2574b0bfdfdc1b9a880aed693df3ff19065c;p=josh%2Fnarcissus misc: Fix clippy lints --- diff --git a/engine/narcissus-core/src/arena.rs b/engine/narcissus-core/src/arena.rs index 3703efa..d33b91d 100644 --- a/engine/narcissus-core/src/arena.rs +++ b/engine/narcissus-core/src/arena.rs @@ -505,7 +505,8 @@ impl HybridArena { 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::() == 0); + debug_assert!(STACK_CAP.is_multiple_of(std::mem::align_of::())); + Self { data: MaybeUninit::uninit(), footer: Cell::new(PageFooter { diff --git a/engine/narcissus-core/src/obj.rs b/engine/narcissus-core/src/obj.rs index 49734d1..715914d 100644 --- a/engine/narcissus-core/src/obj.rs +++ b/engine/narcissus-core/src/obj.rs @@ -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 { diff --git a/engine/narcissus-core/src/pool.rs b/engine/narcissus-core/src/pool.rs index 4a9fa7a..a13d54e 100644 --- a/engine/narcissus-core/src/pool.rs +++ b/engine/narcissus-core/src/pool.rs @@ -602,13 +602,13 @@ impl Pool { pub fn remove(&mut self, handle: Handle) -> Option { 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 Pool { 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 Pool { 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 diff --git a/engine/narcissus-core/src/svg.rs b/engine/narcissus-core/src/svg.rs index 1367cab..532dc71 100644 --- a/engine/narcissus-core/src/svg.rs +++ b/engine/narcissus-core/src/svg.rs @@ -48,7 +48,7 @@ pub fn svg_end() -> SvgEnd { SvgEnd } -pub fn text(x: f32, y: f32, size: f32, style: Style, text: &T) -> Text +pub fn text(x: f32, y: f32, size: f32, style: Style, text: &T) -> Text<'_, T> where T: fmt::Display, { diff --git a/engine/narcissus-gpu/src/frame_counter.rs b/engine/narcissus-gpu/src/frame_counter.rs index 983a097..4f4ec42 100644 --- a/engine/narcissus-gpu/src/frame_counter.rs +++ b/engine/narcissus-gpu/src/frame_counter.rs @@ -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, diff --git a/engine/narcissus-gpu/src/lib.rs b/engine/narcissus-gpu/src/lib.rs index 31c824b..477a284 100644 --- a/engine/narcissus-gpu/src/lib.rs +++ b/engine/narcissus-gpu/src/lib.rs @@ -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>); } diff --git a/engine/narcissus-gpu/src/mapped_buffer.rs b/engine/narcissus-gpu/src/mapped_buffer.rs index 9bb24c1..d309b83 100644 --- a/engine/narcissus-gpu/src/mapped_buffer.rs +++ b/engine/narcissus-gpu/src/mapped_buffer.rs @@ -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) } diff --git a/engine/narcissus-sqlite/src/lib.rs b/engine/narcissus-sqlite/src/lib.rs index 99d541c..babecc3 100644 --- a/engine/narcissus-sqlite/src/lib.rs +++ b/engine/narcissus-sqlite/src/lib.rs @@ -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 } } } diff --git a/title/shark/src/draw.rs b/title/shark/src/draw.rs index 0ad89a2..bc77c01 100644 --- a/title/shark/src/draw.rs +++ b/title/shark/src/draw.rs @@ -50,7 +50,7 @@ impl<'a> Index for Models<'a> { impl<'a> Models<'a> { pub fn load(gpu: &'a Gpu) -> Models<'a> { - fn load_model

(gpu: &Gpu, path: P) -> Model + fn load_model

(gpu: &Gpu, path: P) -> Model<'_> where P: AsRef, {