From 42cd641d00bd6d90e17e2d08e4ce13e48872b37c Mon Sep 17 00:00:00 2001 From: vmarcella Date: Fri, 16 Jan 2026 15:26:14 -0800 Subject: [PATCH 1/8] [fix] warnings inside the platform crate. --- crates/lambda-rs-platform/Cargo.toml | 4 --- crates/lambda-rs-platform/src/shader/naga.rs | 14 ++++++-- crates/lambda-rs-platform/src/wgpu/bind.rs | 2 +- crates/lambda-rs-platform/src/wgpu/gpu.rs | 18 +++++------ .../lambda-rs-platform/src/wgpu/instance.rs | 6 ++++ .../lambda-rs-platform/src/wgpu/pipeline.rs | 26 ++++++++++++--- .../src/wgpu/render_pass.rs | 12 ++----- crates/lambda-rs-platform/src/wgpu/surface.rs | 32 +++++-------------- crates/lambda-rs-platform/src/wgpu/texture.rs | 22 +++++++++++++ crates/lambda-rs-platform/src/wgpu/vertex.rs | 7 ---- crates/lambda-rs-platform/src/winit/mod.rs | 14 +++++++- .../tests/wgpu_texture_build_and_upload.rs | 2 +- 12 files changed, 94 insertions(+), 65 deletions(-) diff --git a/crates/lambda-rs-platform/Cargo.toml b/crates/lambda-rs-platform/Cargo.toml index 62fc2155..dbea9ec3 100644 --- a/crates/lambda-rs-platform/Cargo.toml +++ b/crates/lambda-rs-platform/Cargo.toml @@ -54,7 +54,3 @@ wgpu-with-vulkan = ["wgpu"] wgpu-with-metal = ["wgpu", "wgpu/metal"] wgpu-with-dx12 = ["wgpu", "wgpu/dx12"] wgpu-with-gl = ["wgpu", "wgpu/webgl"] - -[profile.dev] -crate-type = ["cdylib", "rlib"] -incremental = true diff --git a/crates/lambda-rs-platform/src/shader/naga.rs b/crates/lambda-rs-platform/src/shader/naga.rs index e174da4c..ad02a269 100644 --- a/crates/lambda-rs-platform/src/shader/naga.rs +++ b/crates/lambda-rs-platform/src/shader/naga.rs @@ -29,6 +29,12 @@ impl ShaderCompilerBuilder { } } +impl Default for ShaderCompilerBuilder { + fn default() -> Self { + return Self::new(); + } +} + /// A shader compiler that uses naga to translate shader sources into SPIR-V. pub struct ShaderCompiler {} @@ -90,9 +96,11 @@ impl ShaderCompiler { .validate(&module) .expect("Failed to validate shader module."); - let mut options = spv::Options::default(); - options.lang_version = (1, 5); - options.flags = spv::WriterFlags::empty(); + let options = spv::Options { + lang_version: (1, 5), + flags: spv::WriterFlags::empty(), + ..Default::default() + }; let pipeline_options = spv::PipelineOptions { shader_stage: stage, diff --git a/crates/lambda-rs-platform/src/wgpu/bind.rs b/crates/lambda-rs-platform/src/wgpu/bind.rs index 128a7687..499d3374 100644 --- a/crates/lambda-rs-platform/src/wgpu/bind.rs +++ b/crates/lambda-rs-platform/src/wgpu/bind.rs @@ -111,7 +111,7 @@ mod tests { multisampled, } => { assert_eq!(view_dimension, wgpu::TextureViewDimension::D2); - assert_eq!(multisampled, false); + assert!(!multisampled); match sample_type { wgpu::TextureSampleType::Float { filterable } => assert!(filterable), _ => panic!("expected float sample type"), diff --git a/crates/lambda-rs-platform/src/wgpu/gpu.rs b/crates/lambda-rs-platform/src/wgpu/gpu.rs index 23cc6732..7262607a 100644 --- a/crates/lambda-rs-platform/src/wgpu/gpu.rs +++ b/crates/lambda-rs-platform/src/wgpu/gpu.rs @@ -124,7 +124,7 @@ impl GpuBuilder { /// /// Returns an error if no adapter is available, required features are /// missing, or device creation fails. - pub fn build<'surface, 'window>( + pub fn build<'surface>( self, instance: &Instance, surface: Option<&Surface<'surface>>, @@ -160,12 +160,17 @@ impl GpuBuilder { adapter, device, queue, - features: descriptor.required_features, limits: descriptor.required_limits, }); } } +impl Default for GpuBuilder { + fn default() -> Self { + return Self::new(); + } +} + /// Errors emitted while building a `Gpu`. #[derive(Debug)] pub enum GpuBuildError { @@ -187,13 +192,12 @@ impl From for GpuBuildError { } /// Holds the chosen adapter along with its logical device and submission queue -/// plus immutable copies of features and limits used to create the device. +/// plus an immutable copy of the limits used to create the device. #[derive(Debug)] pub struct Gpu { adapter: wgpu::Adapter, device: wgpu::Device, queue: wgpu::Queue, - features: wgpu::Features, limits: wgpu::Limits, } @@ -237,11 +241,6 @@ impl Gpu { &self.queue } - /// Features that were required and enabled during device creation. - pub(crate) fn features(&self) -> wgpu::Features { - self.features - } - /// Limits captured at device creation time. pub fn limits(&self) -> GpuLimits { return GpuLimits { @@ -307,7 +306,6 @@ mod tests { use super::*; use crate::wgpu::{ instance, - surface, texture, }; diff --git a/crates/lambda-rs-platform/src/wgpu/instance.rs b/crates/lambda-rs-platform/src/wgpu/instance.rs index 83ef3368..484dda90 100644 --- a/crates/lambda-rs-platform/src/wgpu/instance.rs +++ b/crates/lambda-rs-platform/src/wgpu/instance.rs @@ -176,6 +176,12 @@ impl InstanceBuilder { } } +impl Default for InstanceBuilder { + fn default() -> Self { + return Self::new(); + } +} + #[derive(Debug)] /// Thin wrapper over `wgpu::Instance` that preserves a user label and exposes /// a blocking `request_adapter` convenience. diff --git a/crates/lambda-rs-platform/src/wgpu/pipeline.rs b/crates/lambda-rs-platform/src/wgpu/pipeline.rs index dc3eb4c3..7c69f59e 100644 --- a/crates/lambda-rs-platform/src/wgpu/pipeline.rs +++ b/crates/lambda-rs-platform/src/wgpu/pipeline.rs @@ -206,6 +206,11 @@ impl ShaderModule { pub fn raw(&self) -> &wgpu::ShaderModule { &self.raw } + + /// Optional debug label used during creation. + pub fn label(&self) -> Option<&str> { + return self.label.as_deref(); + } } /// Wrapper around `wgpu::PipelineLayout`. @@ -220,6 +225,11 @@ impl PipelineLayout { pub fn raw(&self) -> &wgpu::PipelineLayout { return &self.raw; } + + /// Optional debug label used during creation. + pub fn label(&self) -> Option<&str> { + return self.label.as_deref(); + } } /// Builder for creating a `PipelineLayout`. @@ -229,6 +239,12 @@ pub struct PipelineLayoutBuilder<'a> { immediate_data_ranges: Vec, } +impl<'a> Default for PipelineLayoutBuilder<'a> { + fn default() -> Self { + return Self::new(); + } +} + /// Align a `u32` value up to the provided power-of-two alignment. fn align_up_u32(value: u32, alignment: u32) -> u32 { if alignment == 0 { @@ -459,10 +475,6 @@ impl RenderPipeline { pub(crate) fn raw(&self) -> &wgpu::RenderPipeline { return &self.raw; } - /// Consume and return the raw pipeline. - pub(crate) fn into_raw(self) -> wgpu::RenderPipeline { - return self.raw; - } /// Pipeline label if provided. pub fn label(&self) -> Option<&str> { return self.label.as_deref(); @@ -480,6 +492,12 @@ pub struct RenderPipelineBuilder<'a> { sample_count: u32, } +impl<'a> Default for RenderPipelineBuilder<'a> { + fn default() -> Self { + return Self::new(); + } +} + impl<'a> RenderPipelineBuilder<'a> { /// New builder with defaults. pub fn new() -> Self { diff --git a/crates/lambda-rs-platform/src/wgpu/render_pass.rs b/crates/lambda-rs-platform/src/wgpu/render_pass.rs index 8f2d2d38..df5cd5ce 100644 --- a/crates/lambda-rs-platform/src/wgpu/render_pass.rs +++ b/crates/lambda-rs-platform/src/wgpu/render_pass.rs @@ -115,12 +115,6 @@ pub struct RenderPass<'a> { pub(super) raw: wgpu::RenderPass<'a>, } -#[derive(Debug)] -struct RenderPassKeepAlive<'a> { - color_attachments: [Option>; 1], - label: Option, -} - impl<'a> RenderPass<'a> { /// Set the active render pipeline. pub fn set_pipeline(&mut self, pipeline: &pipeline::RenderPipeline) { @@ -254,10 +248,8 @@ impl<'a> RenderColorAttachments<'a> { &mut self, operations: wgpu::Operations, ) { - for attachment in &mut self.attachments { - if let Some(ref mut a) = attachment { - a.ops = operations; - } + for a in self.attachments.iter_mut().flatten() { + a.ops = operations; } } diff --git a/crates/lambda-rs-platform/src/wgpu/surface.rs b/crates/lambda-rs-platform/src/wgpu/surface.rs index eab21668..a97338f0 100644 --- a/crates/lambda-rs-platform/src/wgpu/surface.rs +++ b/crates/lambda-rs-platform/src/wgpu/surface.rs @@ -84,23 +84,6 @@ impl SurfaceConfig { .collect(), }; } - - pub(crate) fn to_wgpu(&self) -> wgpu::SurfaceConfiguration { - let mut view_formats: Vec = Vec::new(); - for vf in &self.view_formats { - view_formats.push(vf.to_wgpu()); - } - return wgpu::SurfaceConfiguration { - usage: self.usage.to_wgpu(), - format: self.format.to_wgpu(), - width: self.width, - height: self.height, - present_mode: self.present_mode.to_wgpu(), - desired_maximum_frame_latency: 2, - alpha_mode: wgpu::CompositeAlphaMode::Opaque, - view_formats, - }; - } } /// Error wrapper for surface acquisition and presentation errors. @@ -154,10 +137,10 @@ impl SurfaceBuilder { /// Safety: we use `create_surface_unsafe` by forwarding raw window/display /// handles from `winit`. Lambda guarantees the window outlives the surface /// for the duration of the runtime. - pub fn build<'window>( + pub fn build( self, instance: &Instance, - window: &'window WindowHandle, + window: &WindowHandle, ) -> Result, CreateSurfaceError> { // SAFETY: We ensure the raw window/display handles outlive the surface by // keeping the window alive for the duration of the application runtime. @@ -192,6 +175,12 @@ impl SurfaceBuilder { } } +impl Default for SurfaceBuilder { + fn default() -> Self { + return Self::new(); + } +} + /// Opaque error returned when surface creation fails. #[derive(Debug)] pub struct CreateSurfaceError; @@ -351,11 +340,6 @@ impl Frame { return TextureViewRef { raw: &self.view }; } - /// Consume and return the underlying parts. - pub(crate) fn into_parts(self) -> (wgpu::SurfaceTexture, wgpu::TextureView) { - return (self.texture, self.view); - } - /// Present the frame to the swapchain. pub fn present(self) { self.texture.present(); diff --git a/crates/lambda-rs-platform/src/wgpu/texture.rs b/crates/lambda-rs-platform/src/wgpu/texture.rs index de554375..cc9c37b9 100644 --- a/crates/lambda-rs-platform/src/wgpu/texture.rs +++ b/crates/lambda-rs-platform/src/wgpu/texture.rs @@ -253,6 +253,11 @@ impl DepthTexture { return self.format; } + /// Optional debug label used during creation. + pub fn label(&self) -> Option<&str> { + return self.label.as_deref(); + } + /// Convenience: return a `TextureViewRef` for use in render pass attachments. pub fn view_ref(&self) -> crate::wgpu::surface::TextureViewRef<'_> { return crate::wgpu::surface::TextureViewRef { raw: &self.view }; @@ -278,6 +283,11 @@ impl ColorAttachmentTexture { return &self.view; } + /// Optional debug label used during creation. + pub fn label(&self) -> Option<&str> { + return self.label.as_deref(); + } + /// Convenience: return a `TextureViewRef` for use in render pass attachments. pub fn view_ref(&self) -> crate::wgpu::surface::TextureViewRef<'_> { return crate::wgpu::surface::TextureViewRef { raw: &self.view }; @@ -371,6 +381,12 @@ pub struct DepthTextureBuilder { sample_count: u32, } +impl Default for DepthTextureBuilder { + fn default() -> Self { + return Self::new(); + } +} + impl DepthTextureBuilder { /// Create a builder with no size and `Depth32Float` format. pub fn new() -> Self { @@ -514,6 +530,12 @@ pub struct SamplerBuilder { lod_max: f32, } +impl Default for SamplerBuilder { + fn default() -> Self { + return Self::new(); + } +} + impl SamplerBuilder { /// Create a new builder with nearest filtering and clamp addressing. pub fn new() -> Self { diff --git a/crates/lambda-rs-platform/src/wgpu/vertex.rs b/crates/lambda-rs-platform/src/wgpu/vertex.rs index 19847b5c..0d420893 100644 --- a/crates/lambda-rs-platform/src/wgpu/vertex.rs +++ b/crates/lambda-rs-platform/src/wgpu/vertex.rs @@ -12,13 +12,6 @@ pub enum ColorFormat { } impl ColorFormat { - pub(crate) fn to_texture_format(self) -> wgpu::TextureFormat { - return match self { - ColorFormat::Rgb32Sfloat => wgpu::TextureFormat::Rgba32Float, - ColorFormat::Rgba8Srgb => wgpu::TextureFormat::Rgba8UnormSrgb, - }; - } - pub(crate) fn to_vertex_format(self) -> wgpu::VertexFormat { return match self { ColorFormat::Rgb32Sfloat => wgpu::VertexFormat::Float32x3, diff --git a/crates/lambda-rs-platform/src/winit/mod.rs b/crates/lambda-rs-platform/src/winit/mod.rs index 5e7d7dc9..f4219252 100644 --- a/crates/lambda-rs-platform/src/winit/mod.rs +++ b/crates/lambda-rs-platform/src/winit/mod.rs @@ -60,6 +60,12 @@ impl LoopBuilder { } } +impl Default for LoopBuilder { + fn default() -> Self { + return Self::new(); + } +} + /// Loop wrapping for the winit event loop. pub struct Loop { event_loop: EventLoop, @@ -171,6 +177,12 @@ impl WindowHandleBuilder { } } +impl Default for WindowHandleBuilder { + fn default() -> Self { + return Self::new(); + } +} + /// Event loop publisher wrapper for pushing events into a winit event loop. pub struct LoopPublisher { winit_proxy: EventLoopProxy, @@ -197,7 +209,7 @@ impl LoopPublisher { impl Loop { /// Create an event publisher for this Loop. pub fn create_event_publisher(&mut self) -> LoopPublisher { - return LoopPublisher::new(&self); + return LoopPublisher::new(self); } /// Returns the primary monitor for the current OS if detectable. diff --git a/crates/lambda-rs-platform/tests/wgpu_texture_build_and_upload.rs b/crates/lambda-rs-platform/tests/wgpu_texture_build_and_upload.rs index a96de812..c344bcc6 100644 --- a/crates/lambda-rs-platform/tests/wgpu_texture_build_and_upload.rs +++ b/crates/lambda-rs-platform/tests/wgpu_texture_build_and_upload.rs @@ -22,7 +22,7 @@ fn wgpu_texture_build_and_upload_succeeds() { for x in 0..w { let idx = ((y * w + x) * 4) as usize; let c = if ((x + y) % 2) == 0 { 255 } else { 0 }; - pixels[idx + 0] = c; + pixels[idx] = c; pixels[idx + 1] = c; pixels[idx + 2] = c; pixels[idx + 3] = 255; From 9e98be4160086b05ac023a689f0b1df5cf387dad Mon Sep 17 00:00:00 2001 From: vmarcella Date: Fri, 16 Jan 2026 15:26:33 -0800 Subject: [PATCH 2/8] [fix] warnings inside of the arg parser. --- crates/lambda-rs-args/src/lib.rs | 60 +++++++++++++++++--------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/crates/lambda-rs-args/src/lib.rs b/crates/lambda-rs-args/src/lib.rs index 2dde60e4..15181862 100644 --- a/crates/lambda-rs-args/src/lib.rs +++ b/crates/lambda-rs-args/src/lib.rs @@ -1,4 +1,5 @@ #![allow(clippy::needless_return)] +#![allow(clippy::items_after_test_module)] //! # Lambda Args //! Lambda Args is a simple argument parser for Rust. It is designed to be //! simple to use and primarily for use in lambda command line applications. @@ -72,42 +73,42 @@ pub enum ArgumentValue { String(String), } -impl Into for ArgumentValue { - fn into(self) -> String { - return match self { +impl From for String { + fn from(value: ArgumentValue) -> Self { + return match value { ArgumentValue::String(val) => val, - _ => panic!("Cannot convert {:?} into a String.", self), + other => panic!("Cannot convert {:?} into a String.", other), }; } } -impl Into for ArgumentValue { - fn into(self) -> i64 { - return match self { +impl From for i64 { + fn from(value: ArgumentValue) -> Self { + return match value { ArgumentValue::Integer(val) => val, ArgumentValue::Float(val) => val as i64, ArgumentValue::Double(val) => val as i64, - _ => panic!("Cannot convert {:?} into an i64", self), + other => panic!("Cannot convert {:?} into an i64", other), }; } } -impl Into for ArgumentValue { - fn into(self) -> f32 { - return match self { +impl From for f32 { + fn from(value: ArgumentValue) -> Self { + return match value { ArgumentValue::Float(val) => val, - _ => panic!("Cannot convert {:?} into a f32", self), + other => panic!("Cannot convert {:?} into a f32", other), }; } } -impl Into for ArgumentValue { - fn into(self) -> f64 { - return match self { +impl From for f64 { + fn from(value: ArgumentValue) -> Self { + return match value { ArgumentValue::Double(val) => val, ArgumentValue::Float(val) => val as f64, ArgumentValue::Integer(val) => val as f64, - _ => panic!("Cannot convert {:?} into a f64", self), + other => panic!("Cannot convert {:?} into a f64", other), }; } } @@ -194,7 +195,7 @@ impl Argument { } pub fn arg_type(&self) -> ArgumentType { - return self.arg_type.clone(); + return self.arg_type; } /// Canonical name used for matching and display (e.g., `--output`). @@ -406,11 +407,12 @@ impl ArgumentParser { format!(" (aliases: {})", arg.aliases().join(", ")) }; out.push_str(&format!( - " {}{}\n {}{}{}\n", + " {}{}\n {}{}{}{}\n", arg.name(), sep, desc, - format!("{}{}", req, def), + req, + def, aliases )); } @@ -583,13 +585,13 @@ impl ArgumentParser { if matches!(pre.0.arg_type(), ArgumentType::Count) { let index = pre.2; let current = match &parsed_arguments[index].value { - ArgumentValue::Integer(v) => *v as i64, + ArgumentValue::Integer(v) => *v, _ => 0, }; let found = self.args.get_mut(&canon).unwrap(); parsed_arguments[index] = ParsedArgument::new( found.0.name.as_str(), - ArgumentValue::Integer((current + 1) as i64), + ArgumentValue::Integer(current + 1), ); found.1 = true; } else if matches!(pre.0.arg_type(), ArgumentType::Boolean) { @@ -619,7 +621,7 @@ impl ArgumentParser { return Err(ArgsError::UnknownArgument(msg)); }; let pre = self.args.get(&canon_name).unwrap(); - if pre.1 == true { + if pre.1 { return Err(ArgsError::DuplicateArgument(pre.0.name.clone())); } // Boolean flags can be set by presence alone @@ -636,12 +638,12 @@ impl ArgumentParser { let index = pre.2; let found = self.args.get_mut(&canon_name).unwrap(); let current = match &parsed_arguments[index].value { - ArgumentValue::Integer(v) => *v as i64, + ArgumentValue::Integer(v) => *v, _ => 0, }; parsed_arguments[index] = ParsedArgument::new( found.0.name.as_str(), - ArgumentValue::Integer((current + 1) as i64), + ArgumentValue::Integer(current + 1), ); found.1 = true; continue; @@ -1022,12 +1024,12 @@ mod tests { Argument::new("--verbose").with_type(ArgumentType::Boolean), ); let p = parser.parse(&argv(&["--verbose"])).unwrap(); - assert_eq!(p.get_bool("--verbose").unwrap(), true); + assert!(p.get_bool("--verbose").unwrap()); let parser2 = ArgumentParser::new("app").with_argument( Argument::new("--verbose").with_type(ArgumentType::Boolean), ); let p2 = parser2.parse(&argv(&["--no-verbose"])).unwrap(); - assert_eq!(p2.get_bool("--verbose").unwrap(), false); + assert!(!p2.get_bool("--verbose").unwrap()); } #[test] @@ -1279,12 +1281,12 @@ impl ArgumentParser { fn assign_next_positional( &mut self, - out: &mut Vec, + out: &mut [ParsedArgument], value: &str, ) -> Result<(), ArgsError> { for pname in self.positionals.clone() { if let Some(entry) = self.args.get_mut(&pname) { - if entry.1 == false { + if !entry.1 { let parsed = parse_value(&entry.0, value)?; let idx = entry.2; out[idx] = ParsedArgument::new(entry.0.name.as_str(), parsed); @@ -1300,7 +1302,7 @@ impl ArgumentParser { }) } - fn get_present(&self, out: &Vec, name: &str) -> bool { + fn get_present(&self, out: &[ParsedArgument], name: &str) -> bool { let canon = if self.args.contains_key(name) { name.to_string() } else if let Some(n) = self.aliases.get(name) { From 51ee208536b48e2aebc1b4d547101ece5359b10d Mon Sep 17 00:00:00 2001 From: vmarcella Date: Fri, 16 Jan 2026 15:26:55 -0800 Subject: [PATCH 3/8] [fix] warnings inside of lambda-rs. --- crates/lambda-rs/examples/reflective_room.rs | 39 +++++++------------- crates/lambda-rs/src/render/mod.rs | 3 +- crates/lambda-rs/src/render/validation.rs | 7 ++-- crates/lambda-rs/src/runtimes/application.rs | 26 ++++++++----- 4 files changed, 36 insertions(+), 39 deletions(-) diff --git a/crates/lambda-rs/examples/reflective_room.rs b/crates/lambda-rs/examples/reflective_room.rs index 7e33c907..83208a9f 100644 --- a/crates/lambda-rs/examples/reflective_room.rs +++ b/crates/lambda-rs/examples/reflective_room.rs @@ -214,22 +214,20 @@ impl Component for ReflectiveRoomExample { } fn on_window_event(&mut self, event: &WindowEvent) -> Result<(), String> { - match event { - WindowEvent::Resize { width, height } => { - self.width = *width; - self.height = *height; - } - _ => {} + if let WindowEvent::Resize { width, height } = event { + self.width = *width; + self.height = *height; } return Ok(()); } fn on_keyboard_event(&mut self, event: &Key) -> Result<(), String> { - match event { - Key::Pressed { - scan_code: _, - virtual_key, - } => match virtual_key { + if let Key::Pressed { + scan_code: _, + virtual_key, + } = event + { + match virtual_key { Some(VirtualKey::KeyM) => { self.msaa_samples = if self.msaa_samples > 1 { 1 } else { 4 }; self.needs_rebuild = true; @@ -272,8 +270,7 @@ impl Component for ReflectiveRoomExample { ); } _ => {} - }, - _ => {} + } } return Ok(()); } @@ -625,9 +622,7 @@ impl ReflectiveRoomExample { .with_immediate_data(immediate_data_size) .with_buffer( BufferBuilder::new() - .with_length( - floor_mesh.vertices().len() * std::mem::size_of::(), - ) + .with_length(std::mem::size_of_val(floor_mesh.vertices())) .with_usage(Usage::VERTEX) .with_properties(Properties::DEVICE_LOCAL) .with_buffer_type(BufferType::Vertex) @@ -677,9 +672,7 @@ impl ReflectiveRoomExample { .with_immediate_data(immediate_data_size) .with_buffer( BufferBuilder::new() - .with_length( - cube_mesh.vertices().len() * std::mem::size_of::(), - ) + .with_length(std::mem::size_of_val(cube_mesh.vertices())) .with_usage(Usage::VERTEX) .with_properties(Properties::DEVICE_LOCAL) .with_buffer_type(BufferType::Vertex) @@ -730,9 +723,7 @@ impl ReflectiveRoomExample { .with_immediate_data(immediate_data_size) .with_buffer( BufferBuilder::new() - .with_length( - floor_mesh.vertices().len() * std::mem::size_of::(), - ) + .with_length(std::mem::size_of_val(floor_mesh.vertices())) .with_usage(Usage::VERTEX) .with_properties(Properties::DEVICE_LOCAL) .with_buffer_type(BufferType::Vertex) @@ -768,9 +759,7 @@ impl ReflectiveRoomExample { .with_immediate_data(immediate_data_size) .with_buffer( BufferBuilder::new() - .with_length( - cube_mesh.vertices().len() * std::mem::size_of::(), - ) + .with_length(std::mem::size_of_val(cube_mesh.vertices())) .with_usage(Usage::VERTEX) .with_properties(Properties::DEVICE_LOCAL) .with_buffer_type(BufferType::Vertex) diff --git a/crates/lambda-rs/src/render/mod.rs b/crates/lambda-rs/src/render/mod.rs index 939f6f92..4a377603 100644 --- a/crates/lambda-rs/src/render/mod.rs +++ b/crates/lambda-rs/src/render/mod.rs @@ -1057,8 +1057,7 @@ mod tests { fn immediates_validate_pipeline_exists_rejects_unknown_pipeline() { let pipelines: Vec = vec![]; let err = RenderContext::validate_pipeline_exists(&pipelines, 7) - .err() - .expect("must error"); + .expect_err("must error"); assert!(err.to_string().contains("Unknown pipeline 7")); } } diff --git a/crates/lambda-rs/src/render/validation.rs b/crates/lambda-rs/src/render/validation.rs index 0a34f069..21a5be8e 100644 --- a/crates/lambda-rs/src/render/validation.rs +++ b/crates/lambda-rs/src/render/validation.rs @@ -144,9 +144,10 @@ mod tests { #[test] fn validate_instance_range_rejects_negative_length() { - let err = validate_instance_range("Draw", &(5..1)) - .err() - .expect("must error"); + let start = 5_u32; + let end = 1_u32; + let err = + validate_instance_range("Draw", &(start..end)).expect_err("must error"); assert!(err.contains("Draw instance range start 5 is greater than end 1")); } diff --git a/crates/lambda-rs/src/runtimes/application.rs b/crates/lambda-rs/src/runtimes/application.rs index 63e80c66..f2f58392 100644 --- a/crates/lambda-rs/src/runtimes/application.rs +++ b/crates/lambda-rs/src/runtimes/application.rs @@ -553,8 +553,10 @@ mod tests { #[test] fn dispatch_skips_component_when_mask_is_none() { - let mut component = RecordingComponent::default(); - component.mask = EventMask::NONE; + let mut component = RecordingComponent { + mask: EventMask::NONE, + ..Default::default() + }; let event = Events::Window { event: WindowEvent::Close, @@ -569,8 +571,10 @@ mod tests { #[test] fn dispatch_skips_component_when_mask_does_not_contain_event() { - let mut component = RecordingComponent::default(); - component.mask = EventMask::KEYBOARD; + let mut component = RecordingComponent { + mask: EventMask::KEYBOARD, + ..Default::default() + }; let event = Events::Window { event: WindowEvent::Close, @@ -586,8 +590,10 @@ mod tests { #[test] fn dispatch_calls_exact_handler_when_mask_contains_event() { - let mut component = RecordingComponent::default(); - component.mask = EventMask::WINDOW | EventMask::KEYBOARD; + let mut component = RecordingComponent { + mask: EventMask::WINDOW | EventMask::KEYBOARD, + ..Default::default() + }; let window_event = Events::Window { event: WindowEvent::Resize { @@ -630,9 +636,11 @@ mod tests { #[test] fn dispatch_returns_fatal_error_message_on_handler_failure() { - let mut component = RecordingComponent::default(); - component.mask = EventMask::WINDOW; - component.fail_window = true; + let mut component = RecordingComponent { + mask: EventMask::WINDOW, + fail_window: true, + ..Default::default() + }; let event = Events::Window { event: WindowEvent::Close, From c840f0f9cdb535db95351f0d95a9c527c2fa1729 Mon Sep 17 00:00:00 2001 From: vmarcella Date: Sat, 17 Jan 2026 16:05:41 -0800 Subject: [PATCH 4/8] [fix] warnings inside math. --- crates/lambda-rs/src/math/matrix.rs | 14 ++++++-------- crates/lambda-rs/src/math/vector.rs | 4 ++-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/crates/lambda-rs/src/math/matrix.rs b/crates/lambda-rs/src/math/matrix.rs index 0a5e6453..f8550d19 100644 --- a/crates/lambda-rs/src/math/matrix.rs +++ b/crates/lambda-rs/src/math/matrix.rs @@ -150,9 +150,9 @@ pub fn rotate_matrix< } }; - for i in 0..rows { - for j in 0..columns { - rotation_matrix.update(i, j, rotation[i][j]); + for (i, row) in rotation.iter().enumerate().take(rows) { + for (j, value) in row.iter().enumerate().take(columns) { + rotation_matrix.update(i, j, *value); } } @@ -355,9 +355,8 @@ where } submatrix.push(row); } - result += self.at(0, i) - * submatrix.determinant() - * (-1.0 as f32).powi(i as i32); + result += + self.at(0, i) * submatrix.determinant() * (-1.0_f32).powi(i as i32); } result } @@ -374,7 +373,6 @@ where return &self.as_ref()[row]; } - /// fn at(&self, row: usize, column: usize) -> ::Scalar { return self.as_ref()[row].as_ref()[column]; } @@ -450,7 +448,7 @@ mod tests { fn non_square_matrix_determinant() { let m = [[3.0, 8.0], [4.0, 6.0], [0.0, 1.0]]; let result = std::panic::catch_unwind(|| m.determinant()); - assert_eq!(false, result.is_ok()); + assert!(result.is_err()); } #[test] diff --git a/crates/lambda-rs/src/math/vector.rs b/crates/lambda-rs/src/math/vector.rs index d4993a2d..3d235b51 100644 --- a/crates/lambda-rs/src/math/vector.rs +++ b/crates/lambda-rs/src/math/vector.rs @@ -200,13 +200,13 @@ mod tests { #[test] fn length() { let a = [1.0, 2.0, 3.0]; - let b = 3.7416573867739413; + let b = 3.741_657_5; let result = a.length(); assert_eq!(result, b); let c = [1.0, 2.0, 3.0, 4.0]; - let d = 5.477225575051661; + let d = 5.477_226; let result = c.length(); assert_eq!(result, d); } From d434c3ea851e15f6b16abd495e6d90e55a0f23d4 Mon Sep 17 00:00:00 2001 From: vmarcella Date: Sat, 17 Jan 2026 16:05:57 -0800 Subject: [PATCH 5/8] [fix] render warnings. --- crates/lambda-rs/src/render/bind.rs | 12 ++++++ crates/lambda-rs/src/render/buffer.rs | 9 ++++- crates/lambda-rs/src/render/encoder.rs | 11 +---- crates/lambda-rs/src/render/mesh.rs | 6 +++ crates/lambda-rs/src/render/mod.rs | 40 ++++++------------- crates/lambda-rs/src/render/pipeline.rs | 6 +++ crates/lambda-rs/src/render/render_pass.rs | 12 +++--- crates/lambda-rs/src/render/scene_math.rs | 21 ++++------ crates/lambda-rs/src/render/shader.rs | 11 +++++ .../lambda-rs/src/render/targets/offscreen.rs | 14 ++++--- .../lambda-rs/src/render/targets/surface.rs | 27 ++++--------- crates/lambda-rs/src/render/texture.rs | 23 ++++++----- crates/lambda-rs/src/render/validation.rs | 3 +- crates/lambda-rs/src/render/vertex.rs | 6 +++ crates/lambda-rs/src/render/viewport.rs | 6 +++ crates/lambda-rs/src/render/window.rs | 6 +++ 16 files changed, 117 insertions(+), 96 deletions(-) diff --git a/crates/lambda-rs/src/render/bind.rs b/crates/lambda-rs/src/render/bind.rs index 78e9db20..f5aa7cc4 100644 --- a/crates/lambda-rs/src/render/bind.rs +++ b/crates/lambda-rs/src/render/bind.rs @@ -135,6 +135,12 @@ pub struct BindGroupLayoutBuilder { samplers: Vec<(u32, BindingVisibility)>, } +impl Default for BindGroupLayoutBuilder { + fn default() -> Self { + return Self::new(); + } +} + impl BindGroupLayoutBuilder { /// Create a new builder with no bindings. pub fn new() -> Self { @@ -300,6 +306,12 @@ pub struct BindGroupBuilder<'a> { samplers: Vec<(u32, Rc)>, } +impl<'a> Default for BindGroupBuilder<'a> { + fn default() -> Self { + return Self::new(); + } +} + impl<'a> BindGroupBuilder<'a> { /// Create a new builder with no layout. pub fn new() -> Self { diff --git a/crates/lambda-rs/src/render/buffer.rs b/crates/lambda-rs/src/render/buffer.rs index 770a8b6b..2294469e 100644 --- a/crates/lambda-rs/src/render/buffer.rs +++ b/crates/lambda-rs/src/render/buffer.rs @@ -25,7 +25,6 @@ use lambda_platform::wgpu::buffer as platform_buffer; use super::{ gpu::Gpu, mesh::Mesh, - vertex::Vertex, RenderContext, }; @@ -237,6 +236,12 @@ pub struct BufferBuilder { label: Option, } +impl Default for BufferBuilder { + fn default() -> Self { + return Self::new(); + } +} + impl BufferBuilder { /// Creates a new buffer builder of type vertex. pub fn new() -> Self { @@ -324,7 +329,7 @@ impl BufferBuilder { ) -> Result { let builder = Self::new(); return builder - .with_length(mesh.vertices().len() * std::mem::size_of::()) + .with_length(std::mem::size_of_val(mesh.vertices())) .with_usage(Usage::VERTEX) .with_properties(Properties::CPU_VISIBLE) .with_buffer_type(BufferType::Vertex) diff --git a/crates/lambda-rs/src/render/encoder.rs b/crates/lambda-rs/src/render/encoder.rs index 469d947a..0707e1ca 100644 --- a/crates/lambda-rs/src/render/encoder.rs +++ b/crates/lambda-rs/src/render/encoder.rs @@ -44,7 +44,6 @@ use super::{ }, color_attachments::RenderColorAttachments, command::IndexFormat, - pipeline, pipeline::RenderPipeline, render_pass::RenderPass, texture::{ @@ -211,9 +210,6 @@ pub struct RenderPassEncoder<'pass> { #[derive(Clone)] struct CurrentPipeline { label: String, - has_color_targets: bool, - expects_depth_stencil: bool, - uses_stencil: bool, per_instance_slots: Vec, } @@ -374,10 +370,7 @@ impl<'pass> RenderPassEncoder<'pass> { { let label = pipeline.pipeline().label().unwrap_or("unnamed").to_string(); self.current_pipeline = Some(CurrentPipeline { - label: label.clone(), - has_color_targets: pipeline.has_color_targets(), - expects_depth_stencil: pipeline.expects_depth_stencil(), - uses_stencil: pipeline.uses_stencil(), + label, per_instance_slots: pipeline.per_instance_slots().clone(), }); } @@ -517,7 +510,7 @@ impl<'pass> RenderPassEncoder<'pass> { } let buffer_size = buffer.raw().size(); - if buffer_size % element_size != 0 { + if !buffer_size.is_multiple_of(element_size) { return Err(RenderPassError::Validation(format!( "Index buffer size {} bytes is not a multiple of element size {} \ for format {:?}", diff --git a/crates/lambda-rs/src/render/mesh.rs b/crates/lambda-rs/src/render/mesh.rs index 1fb56e40..9015a750 100644 --- a/crates/lambda-rs/src/render/mesh.rs +++ b/crates/lambda-rs/src/render/mesh.rs @@ -47,6 +47,12 @@ pub struct MeshBuilder { attributes: Vec, } +impl Default for MeshBuilder { + fn default() -> Self { + return Self::new(); + } +} + impl MeshBuilder { /// Creates a new mesh builder. pub fn new() -> Self { diff --git a/crates/lambda-rs/src/render/mod.rs b/crates/lambda-rs/src/render/mod.rs index 4a377603..a4d9fc54 100644 --- a/crates/lambda-rs/src/render/mod.rs +++ b/crates/lambda-rs/src/render/mod.rs @@ -219,6 +219,7 @@ impl RenderContextBuilder { /// reconfiguration with preserved present mode and usage. pub struct RenderContext { label: String, + #[allow(dead_code)] instance: instance::Instance, surface: targets::surface::WindowSurface, gpu: gpu::Gpu, @@ -243,6 +244,11 @@ pub struct RenderContext { pub type ResourceId = usize; impl RenderContext { + /// Optional label assigned when constructing the context. + pub fn label(&self) -> &str { + return self.label.as_str(); + } + /// Current surface size in pixels. /// /// This reflects the most recent configured surface dimensions and is used @@ -428,25 +434,6 @@ impl RenderContext { return self.depth_format; } - pub(crate) fn supports_surface_sample_count( - &self, - sample_count: u32, - ) -> bool { - return self - .gpu - .supports_sample_count_for_format(self.config.format, sample_count); - } - - pub(crate) fn supports_depth_sample_count( - &self, - format: texture::DepthFormat, - sample_count: u32, - ) -> bool { - return self - .gpu - .supports_sample_count_for_depth(format, sample_count); - } - /// Device limit: maximum bytes that can be bound for a single uniform buffer binding. pub fn limit_max_uniform_buffer_binding_size(&self) -> u64 { return self.gpu.limit_max_uniform_buffer_binding_size(); @@ -519,10 +506,7 @@ impl RenderContext { targets::surface::SurfaceError::Lost | targets::surface::SurfaceError::Outdated => { self.reconfigure_surface(self.size)?; - self - .surface - .acquire_frame() - .map_err(|e| RenderError::Surface(e))? + self.surface.acquire_frame().map_err(RenderError::Surface)? } _ => return Err(RenderError::Surface(err)), }, @@ -836,14 +820,14 @@ impl RenderContext { command_iter: &mut std::vec::IntoIter, rp_encoder: &mut encoder::RenderPassEncoder<'_>, initial_viewport: &viewport::Viewport, - render_pipelines: &Vec, - bind_groups: &Vec, - buffers: &Vec>, + render_pipelines: &[RenderPipeline], + bind_groups: &[bind::BindGroup], + buffers: &[Rc], min_uniform_buffer_offset_alignment: u32, ) -> Result<(), RenderPassError> { rp_encoder.set_viewport(initial_viewport); - while let Some(cmd) = command_iter.next() { + for cmd in command_iter.by_ref() { match cmd { RenderCommand::EndRenderPass => return Ok(()), RenderCommand::SetStencilReference { reference } => { @@ -896,7 +880,7 @@ impl RenderContext { "Vertex buffer index {buffer} not found for pipeline {pipeline}" )) })?; - rp_encoder.set_vertex_buffer(buffer as u32, buffer_ref); + rp_encoder.set_vertex_buffer(buffer, buffer_ref); } RenderCommand::BindIndexBuffer { buffer, format } => { let buffer_ref = buffers.get(buffer).ok_or_else(|| { diff --git a/crates/lambda-rs/src/render/pipeline.rs b/crates/lambda-rs/src/render/pipeline.rs index 108b5b2b..28cbf15f 100644 --- a/crates/lambda-rs/src/render/pipeline.rs +++ b/crates/lambda-rs/src/render/pipeline.rs @@ -270,6 +270,12 @@ pub struct RenderPipelineBuilder { depth_write_enabled: Option, } +impl Default for RenderPipelineBuilder { + fn default() -> Self { + return Self::new(); + } +} + impl RenderPipelineBuilder { /// Creates a new render pipeline builder. pub fn new() -> Self { diff --git a/crates/lambda-rs/src/render/render_pass.rs b/crates/lambda-rs/src/render/render_pass.rs index d3ff7815..c5a25966 100644 --- a/crates/lambda-rs/src/render/render_pass.rs +++ b/crates/lambda-rs/src/render/render_pass.rs @@ -135,7 +135,6 @@ impl DepthOperations { /// The pass defines the initial clear for the color attachment and an optional /// label. Depth/stencil may be added in a future iteration. pub struct RenderPass { - clear_color: [f64; 4], label: Option, color_operations: ColorOperations, depth_operations: Option, @@ -148,10 +147,6 @@ impl RenderPass { /// Destroy the pass. Kept for symmetry with other resources. pub fn destroy(self, _gpu: &Gpu) {} - pub(crate) fn clear_color(&self) -> [f64; 4] { - return self.clear_color; - } - pub(crate) fn label(&self) -> Option<&str> { self.label.as_deref() } @@ -193,6 +188,12 @@ pub struct RenderPassBuilder { use_color: bool, } +impl Default for RenderPassBuilder { + fn default() -> Self { + return Self::new(); + } +} + impl RenderPassBuilder { /// Creates a new render pass builder. pub fn new() -> Self { @@ -356,7 +357,6 @@ impl RenderPassBuilder { ); return RenderPass { - clear_color: self.clear_color, label: self.label, color_operations: self.color_operations, depth_operations: self.depth_operations, diff --git a/crates/lambda-rs/src/render/scene_math.rs b/crates/lambda-rs/src/render/scene_math.rs index 08d70254..54c994c0 100644 --- a/crates/lambda-rs/src/render/scene_math.rs +++ b/crates/lambda-rs/src/render/scene_math.rs @@ -192,6 +192,7 @@ pub fn compute_model_view_projection_matrix( /// Compute a full model-view-projection matrix for a rotation around a specific /// local-space pivot point. +#[allow(clippy::too_many_arguments)] pub fn compute_model_view_projection_matrix_about_pivot( camera: &SimpleCamera, viewport_width: u32, @@ -246,20 +247,12 @@ mod tests { let mut expected: [[f32; 4]; 4] = m::identity_matrix(4, 4); expected = m::rotate_matrix(expected, axis, angle_in_turns); - let mut s: [[f32; 4]; 4] = [[0.0; 4]; 4]; - for i in 0..4 { - for j in 0..4 { - s[i][j] = if i == j { - if i == 3 { - 1.0 - } else { - scale - } - } else { - 0.0 - }; - } - } + let s: [[f32; 4]; 4] = [ + [scale, 0.0, 0.0, 0.0], + [0.0, scale, 0.0, 0.0], + [0.0, 0.0, scale, 0.0], + [0.0, 0.0, 0.0, 1.0], + ]; expected = expected.multiply(&s); let t: [[f32; 4]; 4] = m::translation_matrix(translation); diff --git a/crates/lambda-rs/src/render/shader.rs b/crates/lambda-rs/src/render/shader.rs index 57e1e63b..9bf84e50 100644 --- a/crates/lambda-rs/src/render/shader.rs +++ b/crates/lambda-rs/src/render/shader.rs @@ -35,6 +35,12 @@ pub struct ShaderBuilder { compiler: ShaderCompiler, } +impl Default for ShaderBuilder { + fn default() -> Self { + return Self::new(); + } +} + impl ShaderBuilder { /// Creates a new shader builder that can be reused for compiling shaders. pub fn new() -> Self { @@ -78,4 +84,9 @@ impl Shader { pub fn as_binary(&self) -> Vec { return self.binary.clone(); } + + /// Borrow the `VirtualShader` used to compile this shader. + pub fn virtual_shader(&self) -> &VirtualShader { + return &self.virtual_shader; + } } diff --git a/crates/lambda-rs/src/render/targets/offscreen.rs b/crates/lambda-rs/src/render/targets/offscreen.rs index 501f03b8..ee46fa48 100644 --- a/crates/lambda-rs/src/render/targets/offscreen.rs +++ b/crates/lambda-rs/src/render/targets/offscreen.rs @@ -60,9 +60,7 @@ impl OffscreenTarget { } /// Access the multi-sampled color attachment used for rendering. - pub(crate) fn msaa_color_texture( - &self, - ) -> Option<&texture::ColorAttachmentTexture> { + pub fn msaa_color_texture(&self) -> Option<&texture::ColorAttachmentTexture> { return self.msaa_color.as_ref(); } @@ -75,7 +73,7 @@ impl OffscreenTarget { } /// Optional debug label assigned at creation time. - pub(crate) fn label(&self) -> Option<&str> { + pub fn label(&self) -> Option<&str> { return self.label.as_deref(); } @@ -141,6 +139,12 @@ pub struct OffscreenTargetBuilder { sample_count: u32, } +impl Default for OffscreenTargetBuilder { + fn default() -> Self { + return Self::new(); + } +} + impl OffscreenTargetBuilder { /// Create a new builder with no attachments configured. pub fn new() -> Self { @@ -198,7 +202,7 @@ impl OffscreenTargetBuilder { let (width, height) = self.resolve_size()?; let sample_count = self.sample_count.max(1); - if let Err(_) = validation::validate_sample_count(sample_count) { + if validation::validate_sample_count(sample_count).is_err() { return Err(OffscreenTargetError::UnsupportedSampleCount { requested: sample_count, }); diff --git a/crates/lambda-rs/src/render/targets/surface.rs b/crates/lambda-rs/src/render/targets/surface.rs index 99eb084b..84b13fe2 100644 --- a/crates/lambda-rs/src/render/targets/surface.rs +++ b/crates/lambda-rs/src/render/targets/surface.rs @@ -40,7 +40,7 @@ impl<'a> TextureView<'a> { /// Convert to the platform texture view reference for internal use. #[inline] - pub(crate) fn to_platform(&self) -> platform::surface::TextureViewRef<'a> { + pub(crate) fn to_platform(self) -> platform::surface::TextureViewRef<'a> { return self.inner; } } @@ -115,7 +115,7 @@ pub enum PresentMode { impl PresentMode { #[inline] - pub(crate) fn to_platform(&self) -> platform::surface::PresentMode { + pub(crate) fn to_platform(self) -> platform::surface::PresentMode { return match self { PresentMode::Fifo => platform::surface::PresentMode::Fifo, PresentMode::FifoRelaxed => platform::surface::PresentMode::FifoRelaxed, @@ -284,15 +284,12 @@ impl WindowSurface { present_mode: PresentMode, usage: TextureUsages, ) -> Result<(), String> { - self - .inner - .configure_with_defaults( - gpu.platform(), - size, - present_mode.to_platform(), - usage.to_platform(), - ) - .map_err(|e| e)?; + self.inner.configure_with_defaults( + gpu.platform(), + size, + present_mode.to_platform(), + usage.to_platform(), + )?; if let Some(platform_config) = self.inner.configuration() { self.config = Some(SurfaceConfig::from_platform(platform_config)); @@ -307,14 +304,6 @@ impl WindowSurface { pub(crate) fn platform(&self) -> &platform::surface::Surface<'static> { return &self.inner; } - - /// Mutably borrow the underlying platform surface for internal use. - #[inline] - pub(crate) fn platform_mut( - &mut self, - ) -> &mut platform::surface::Surface<'static> { - return &mut self.inner; - } } impl RenderTarget for WindowSurface { diff --git a/crates/lambda-rs/src/render/texture.rs b/crates/lambda-rs/src/render/texture.rs index 20c04286..a33f6799 100644 --- a/crates/lambda-rs/src/render/texture.rs +++ b/crates/lambda-rs/src/render/texture.rs @@ -309,15 +309,6 @@ impl DepthTexture { }; } - /// Borrow a texture view reference for use in render pass attachments. - pub(crate) fn view_ref( - &self, - ) -> crate::render::targets::surface::TextureView<'_> { - return crate::render::targets::surface::TextureView::from_platform( - self.inner.view_ref(), - ); - } - /// Access the underlying platform texture view reference directly. /// /// This is needed for the render pass builder which expects the platform @@ -447,8 +438,6 @@ impl TextureBuilder { return self; } - /// Create the texture and upload initial data if provided. - /// Create the texture and upload initial data if provided. pub fn build(self, gpu: &Gpu) -> Result { let mut builder = @@ -506,6 +495,12 @@ pub struct DepthTextureBuilder { sample_count: u32, } +impl Default for DepthTextureBuilder { + fn default() -> Self { + return Self::new(); + } +} + impl DepthTextureBuilder { /// Create a new depth texture builder with no size and `Depth32Float` format. pub fn new() -> Self { @@ -564,6 +559,12 @@ pub struct SamplerBuilder { inner: platform::SamplerBuilder, } +impl Default for SamplerBuilder { + fn default() -> Self { + return Self::new(); + } +} + impl SamplerBuilder { /// Create a new sampler builder with nearest/clamp defaults. pub fn new() -> Self { diff --git a/crates/lambda-rs/src/render/validation.rs b/crates/lambda-rs/src/render/validation.rs index 21a5be8e..82d72090 100644 --- a/crates/lambda-rs/src/render/validation.rs +++ b/crates/lambda-rs/src/render/validation.rs @@ -174,8 +174,7 @@ mod tests { let err = validate_instance_bindings("instanced", &per_instance_slots, &bound) - .err() - .expect("must error"); + .expect_err("must error"); assert!(err.contains("instanced")); assert!(err.contains("slot 2")); } diff --git a/crates/lambda-rs/src/render/vertex.rs b/crates/lambda-rs/src/render/vertex.rs index fea22693..4ce9b214 100644 --- a/crates/lambda-rs/src/render/vertex.rs +++ b/crates/lambda-rs/src/render/vertex.rs @@ -86,6 +86,12 @@ pub struct VertexBuilder { pub color: [f32; 3], } +impl Default for VertexBuilder { + fn default() -> Self { + return Self::new(); + } +} + impl VertexBuilder { /// Creates a new vertex builder. pub fn new() -> Self { diff --git a/crates/lambda-rs/src/render/viewport.rs b/crates/lambda-rs/src/render/viewport.rs index 1c94e9ed..2a1eea43 100644 --- a/crates/lambda-rs/src/render/viewport.rs +++ b/crates/lambda-rs/src/render/viewport.rs @@ -40,6 +40,12 @@ pub struct ViewportBuilder { max_depth: f32, } +impl Default for ViewportBuilder { + fn default() -> Self { + return Self::new(); + } +} + impl ViewportBuilder { /// Creates a new viewport builder. pub fn new() -> Self { diff --git a/crates/lambda-rs/src/render/window.rs b/crates/lambda-rs/src/render/window.rs index b0aba324..6e963c41 100644 --- a/crates/lambda-rs/src/render/window.rs +++ b/crates/lambda-rs/src/render/window.rs @@ -21,6 +21,12 @@ pub struct WindowBuilder { vsync: bool, } +impl Default for WindowBuilder { + fn default() -> Self { + return Self::new(); + } +} + impl WindowBuilder { /// A new window builder will be 480x360 by default and have the name /// "Window". After customizing the window with whatever properties your From 6d39a5065daf040afb048058618d8394f87a8acd Mon Sep 17 00:00:00 2001 From: vmarcella Date: Sat, 17 Jan 2026 16:06:17 -0800 Subject: [PATCH 6/8] [fix] warnings with tests. --- ...u_bind_layout_and_group_texture_sampler.rs | 19 +++++++++++---- .../tests/wgpu_bind_layout_dim3_and_group.rs | 23 +++++++++++++++---- .../tests/wgpu_texture3d_build_and_upload.rs | 23 +++++++++++++++---- .../tests/wgpu_texture_build_and_upload.rs | 23 ++++++++++++++----- 4 files changed, 67 insertions(+), 21 deletions(-) diff --git a/crates/lambda-rs-platform/tests/wgpu_bind_layout_and_group_texture_sampler.rs b/crates/lambda-rs-platform/tests/wgpu_bind_layout_and_group_texture_sampler.rs index 9bf4ba73..246eeae7 100644 --- a/crates/lambda-rs-platform/tests/wgpu_bind_layout_and_group_texture_sampler.rs +++ b/crates/lambda-rs-platform/tests/wgpu_bind_layout_and_group_texture_sampler.rs @@ -2,19 +2,28 @@ // Integration tests for `lambda-rs-platform::wgpu::bind` with textures/samplers -fn create_test_device() -> lambda_platform::wgpu::gpu::Gpu { +fn create_test_device() -> Option { let instance = lambda_platform::wgpu::instance::InstanceBuilder::new() .with_label("platform-bind-itest") .build(); - return lambda_platform::wgpu::gpu::GpuBuilder::new() + let result = lambda_platform::wgpu::gpu::GpuBuilder::new() .with_label("platform-bind-itest-device") - .build(&instance, None) - .expect("create offscreen device"); + .build(&instance, None); + + match result { + Ok(gpu) => return Some(gpu), + Err(lambda_platform::wgpu::gpu::GpuBuildError::AdapterUnavailable) => { + return None; + } + Err(err) => panic!("create offscreen device: {:?}", err), + } } #[test] fn wgpu_bind_layout_and_group_texture_sampler() { - let gpu = create_test_device(); + let Some(gpu) = create_test_device() else { + return; + }; let (w, h) = (4u32, 4u32); let pixels = vec![255u8; (w * h * 4) as usize]; diff --git a/crates/lambda-rs-platform/tests/wgpu_bind_layout_dim3_and_group.rs b/crates/lambda-rs-platform/tests/wgpu_bind_layout_dim3_and_group.rs index 76c34c45..81cbc56c 100644 --- a/crates/lambda-rs-platform/tests/wgpu_bind_layout_dim3_and_group.rs +++ b/crates/lambda-rs-platform/tests/wgpu_bind_layout_dim3_and_group.rs @@ -2,15 +2,28 @@ // Bind group layout and group test for 3D texture dimension -#[test] -fn wgpu_bind_layout_dim3_and_group() { +fn create_test_device() -> Option { let instance = lambda_platform::wgpu::instance::InstanceBuilder::new() .with_label("p-itest-3d-bind") .build(); - let gpu = lambda_platform::wgpu::gpu::GpuBuilder::new() + let result = lambda_platform::wgpu::gpu::GpuBuilder::new() .with_label("p-itest-3d-bind-device") - .build(&instance, None) - .expect("create device"); + .build(&instance, None); + + match result { + Ok(gpu) => return Some(gpu), + Err(lambda_platform::wgpu::gpu::GpuBuildError::AdapterUnavailable) => { + return None; + } + Err(err) => panic!("create device: {:?}", err), + } +} + +#[test] +fn wgpu_bind_layout_dim3_and_group() { + let Some(gpu) = create_test_device() else { + return; + }; let (w, h, d) = (2u32, 2u32, 2u32); let pixels = vec![255u8; (w * h * d * 4) as usize]; diff --git a/crates/lambda-rs-platform/tests/wgpu_texture3d_build_and_upload.rs b/crates/lambda-rs-platform/tests/wgpu_texture3d_build_and_upload.rs index 9b4e44a1..23cf0a59 100644 --- a/crates/lambda-rs-platform/tests/wgpu_texture3d_build_and_upload.rs +++ b/crates/lambda-rs-platform/tests/wgpu_texture3d_build_and_upload.rs @@ -2,15 +2,28 @@ // Integration tests for 3D textures in the platform layer -#[test] -fn wgpu_texture3d_build_and_upload() { +fn create_test_device() -> Option { let instance = lambda_platform::wgpu::instance::InstanceBuilder::new() .with_label("p-itest-3d") .build(); - let gpu = lambda_platform::wgpu::gpu::GpuBuilder::new() + let result = lambda_platform::wgpu::gpu::GpuBuilder::new() .with_label("p-itest-3d-device") - .build(&instance, None) - .expect("create device"); + .build(&instance, None); + + match result { + Ok(gpu) => return Some(gpu), + Err(lambda_platform::wgpu::gpu::GpuBuildError::AdapterUnavailable) => { + return None; + } + Err(err) => panic!("create device: {:?}", err), + } +} + +#[test] +fn wgpu_texture3d_build_and_upload() { + let Some(gpu) = create_test_device() else { + return; + }; let (w, h, d) = (4u32, 4u32, 3u32); let pixels = vec![180u8; (w * h * d * 4) as usize]; diff --git a/crates/lambda-rs-platform/tests/wgpu_texture_build_and_upload.rs b/crates/lambda-rs-platform/tests/wgpu_texture_build_and_upload.rs index c344bcc6..f09d5a20 100644 --- a/crates/lambda-rs-platform/tests/wgpu_texture_build_and_upload.rs +++ b/crates/lambda-rs-platform/tests/wgpu_texture_build_and_upload.rs @@ -2,19 +2,28 @@ // Integration tests for `lambda-rs-platform::wgpu::texture` -fn create_test_device() -> lambda_platform::wgpu::gpu::Gpu { +fn create_test_device() -> Option { let instance = lambda_platform::wgpu::instance::InstanceBuilder::new() .with_label("platform-itest") .build(); - return lambda_platform::wgpu::gpu::GpuBuilder::new() + let result = lambda_platform::wgpu::gpu::GpuBuilder::new() .with_label("platform-itest-device") - .build(&instance, None) - .expect("create offscreen device"); + .build(&instance, None); + + match result { + Ok(gpu) => return Some(gpu), + Err(lambda_platform::wgpu::gpu::GpuBuildError::AdapterUnavailable) => { + return None; + } + Err(err) => panic!("create offscreen device: {:?}", err), + } } #[test] fn wgpu_texture_build_and_upload_succeeds() { - let gpu = create_test_device(); + let Some(gpu) = create_test_device() else { + return; + }; let (w, h) = (8u32, 8u32); let mut pixels = vec![0u8; (w * h * 4) as usize]; @@ -41,7 +50,9 @@ fn wgpu_texture_build_and_upload_succeeds() { #[test] fn wgpu_texture_upload_with_padding_bytes_per_row() { - let gpu = create_test_device(); + let Some(gpu) = create_test_device() else { + return; + }; let (w, h) = (13u32, 7u32); let pixels = vec![128u8; (w * h * 4) as usize]; From 0db4820e92fac2fa5cbe80c94cd254e48dccdf64 Mon Sep 17 00:00:00 2001 From: vmarcella Date: Sat, 17 Jan 2026 16:06:33 -0800 Subject: [PATCH 7/8] [fix] warnings with all examples. --- crates/lambda-rs/examples/immediates.rs | 33 ++++------ .../examples/indexed_multi_vertex_buffers.rs | 12 ++-- crates/lambda-rs/examples/instanced_quads.rs | 11 ++-- crates/lambda-rs/examples/minimal.rs | 1 - crates/lambda-rs/examples/offscreen_post.rs | 9 +-- crates/lambda-rs/examples/reflective_room.rs | 2 +- crates/lambda-rs/examples/textured_cube.rs | 11 ++-- crates/lambda-rs/examples/textured_quad.rs | 11 ++-- crates/lambda-rs/examples/triangle.rs | 12 ++-- crates/lambda-rs/examples/triangles.rs | 31 ++++------ .../examples/uniform_buffer_triangle.rs | 21 +++---- crates/lambda-rs/src/runtimes/application.rs | 62 ++++++++++++------- 12 files changed, 97 insertions(+), 119 deletions(-) diff --git a/crates/lambda-rs/examples/immediates.rs b/crates/lambda-rs/examples/immediates.rs index d08a3dcb..594507af 100644 --- a/crates/lambda-rs/examples/immediates.rs +++ b/crates/lambda-rs/examples/immediates.rs @@ -7,11 +7,7 @@ use lambda::{ WindowEvent, }, logging, - math::{ - matrix, - matrix::Matrix, - vector::Vector, - }, + math::matrix::Matrix, render::{ buffer::BufferBuilder, command::RenderCommand, @@ -43,7 +39,6 @@ use lambda::{ runtime::start_runtime, runtimes::{ application::ComponentResult, - ApplicationRuntime, ApplicationRuntimeBuilder, }, }; @@ -156,7 +151,7 @@ impl Component for ImmediatesExample { let mut mesh_builder = MeshBuilder::new(); vertices.iter().for_each(|vertex| { - mesh_builder.with_vertex(vertex.clone()); + mesh_builder.with_vertex(*vertex); }); let mesh = mesh_builder @@ -216,7 +211,7 @@ impl Component for ImmediatesExample { fn on_detach( &mut self, - render_context: &mut lambda::render::RenderContext, + _render_context: &mut lambda::render::RenderContext, ) -> Result { logging::info!("Detaching component"); return Ok(ComponentResult::Success); @@ -227,13 +222,10 @@ impl Component for ImmediatesExample { } fn on_window_event(&mut self, event: &WindowEvent) -> Result<(), String> { - match event { - WindowEvent::Resize { width, height } => { - self.width = *width; - self.height = *height; - logging::info!("Window resized to {}x{}", width, height); - } - _ => {} + if let WindowEvent::Resize { width, height } = event { + self.width = *width; + self.height = *height; + logging::info!("Window resized to {}x{}", width, height); } return Ok(()); } @@ -249,7 +241,7 @@ impl Component for ImmediatesExample { fn on_render( &mut self, - render_context: &mut lambda::render::RenderContext, + _render_context: &mut lambda::render::RenderContext, ) -> Vec { let camera = SimpleCamera { position: [0.0, 0.0, 3.0], @@ -281,12 +273,11 @@ impl Component for ImmediatesExample { RenderCommand::BeginRenderPass { render_pass: self .render_pass - .expect("Cannot begin the render pass when it doesn't exist.") - .clone(), + .expect("Cannot begin the render pass when it doesn't exist."), viewport: viewport.clone(), }, RenderCommand::SetPipeline { - pipeline: render_pipeline.clone(), + pipeline: render_pipeline, }, RenderCommand::SetViewports { start_at: 0, @@ -297,11 +288,11 @@ impl Component for ImmediatesExample { viewports: vec![viewport.clone()], }, RenderCommand::BindVertexBuffer { - pipeline: render_pipeline.clone(), + pipeline: render_pipeline, buffer: 0, }, RenderCommand::Immediates { - pipeline: render_pipeline.clone(), + pipeline: render_pipeline, offset: 0, bytes: Vec::from(immediate_data_to_bytes(&ImmediateData { data: [0.0, 0.0, 0.0, 0.0], diff --git a/crates/lambda-rs/examples/indexed_multi_vertex_buffers.rs b/crates/lambda-rs/examples/indexed_multi_vertex_buffers.rs index 257c3b06..51c13970 100644 --- a/crates/lambda-rs/examples/indexed_multi_vertex_buffers.rs +++ b/crates/lambda-rs/examples/indexed_multi_vertex_buffers.rs @@ -48,7 +48,6 @@ use lambda::{ runtime::start_runtime, runtimes::{ application::ComponentResult, - ApplicationRuntime, ApplicationRuntimeBuilder, }, }; @@ -235,13 +234,10 @@ impl Component for IndexedMultiBufferExample { } fn on_window_event(&mut self, event: &WindowEvent) -> Result<(), String> { - match event { - WindowEvent::Resize { width, height } => { - self.width = *width; - self.height = *height; - logging::info!("Window resized to {}x{}", width, height); - } - _ => {} + if let WindowEvent::Resize { width, height } = event { + self.width = *width; + self.height = *height; + logging::info!("Window resized to {}x{}", width, height); } return Ok(()); } diff --git a/crates/lambda-rs/examples/instanced_quads.rs b/crates/lambda-rs/examples/instanced_quads.rs index 8469a28c..2a72c86a 100644 --- a/crates/lambda-rs/examples/instanced_quads.rs +++ b/crates/lambda-rs/examples/instanced_quads.rs @@ -263,13 +263,10 @@ impl Component for InstancedQuadsExample { } fn on_window_event(&mut self, event: &WindowEvent) -> Result<(), String> { - match event { - WindowEvent::Resize { width, height } => { - self.width = *width; - self.height = *height; - logging::info!("Window resized to {}x{}", width, height); - } - _ => {} + if let WindowEvent::Resize { width, height } = event { + self.width = *width; + self.height = *height; + logging::info!("Window resized to {}x{}", width, height); } return Ok(()); } diff --git a/crates/lambda-rs/examples/minimal.rs b/crates/lambda-rs/examples/minimal.rs index 43413baa..638eef5a 100644 --- a/crates/lambda-rs/examples/minimal.rs +++ b/crates/lambda-rs/examples/minimal.rs @@ -4,7 +4,6 @@ //! applications or to verify that your system is configured to run lambda //! applications correctly. -#[macro_use] use lambda::{ runtime::start_runtime, runtimes::ApplicationRuntimeBuilder, diff --git a/crates/lambda-rs/examples/offscreen_post.rs b/crates/lambda-rs/examples/offscreen_post.rs index 3922cad4..7664f839 100644 --- a/crates/lambda-rs/examples/offscreen_post.rs +++ b/crates/lambda-rs/examples/offscreen_post.rs @@ -221,12 +221,9 @@ impl Component for OffscreenPostExample { } fn on_window_event(&mut self, event: &WindowEvent) -> Result<(), String> { - match event { - WindowEvent::Resize { width, height } => { - self.width = *width; - self.height = *height; - } - _ => {} + if let WindowEvent::Resize { width, height } = event { + self.width = *width; + self.height = *height; } return Ok(()); } diff --git a/crates/lambda-rs/examples/reflective_room.rs b/crates/lambda-rs/examples/reflective_room.rs index 83208a9f..809a84ac 100644 --- a/crates/lambda-rs/examples/reflective_room.rs +++ b/crates/lambda-rs/examples/reflective_room.rs @@ -664,7 +664,7 @@ impl ReflectiveRoomExample { // Reflected cube pipeline self.pipe_reflected = if self.stencil_enabled { - let mut builder = RenderPipelineBuilder::new() + let builder = RenderPipelineBuilder::new() .with_label("reflected-cube") // Mirrored transform reverses winding; cull front to keep visible faces. .with_culling(CullingMode::Front) diff --git a/crates/lambda-rs/examples/textured_cube.rs b/crates/lambda-rs/examples/textured_cube.rs index 6e07dfad..cefec77c 100644 --- a/crates/lambda-rs/examples/textured_cube.rs +++ b/crates/lambda-rs/examples/textured_cube.rs @@ -304,7 +304,7 @@ impl Component for TexturedCubeExample { let i = ((y * tex_w + x) * 4) as usize; let checker = ((x / 8) % 2) ^ ((y / 8) % 2); let c: u8 = if checker == 0 { 40 } else { 220 }; - pixels[i + 0] = c; + pixels[i] = c; pixels[i + 1] = c; pixels[i + 2] = c; pixels[i + 3] = 255; @@ -373,12 +373,9 @@ impl Component for TexturedCubeExample { } fn on_window_event(&mut self, event: &WindowEvent) -> Result<(), String> { - match event { - WindowEvent::Resize { width, height } => { - self.width = *width; - self.height = *height; - } - _ => {} + if let WindowEvent::Resize { width, height } = event { + self.width = *width; + self.height = *height; } return Ok(()); } diff --git a/crates/lambda-rs/examples/textured_quad.rs b/crates/lambda-rs/examples/textured_quad.rs index 97469511..a015ccca 100644 --- a/crates/lambda-rs/examples/textured_quad.rs +++ b/crates/lambda-rs/examples/textured_quad.rs @@ -205,7 +205,7 @@ impl Component for TexturedQuadExample { let i = ((y * tex_w + x) * 4) as usize; let checker = ((x / 8) % 2) ^ ((y / 8) % 2); let c = if checker == 0 { 40 } else { 220 }; - pixels[i + 0] = c; // R + pixels[i] = c; // R pixels[i + 1] = c; // G pixels[i + 2] = c; // B pixels[i + 3] = 255; // A @@ -275,12 +275,9 @@ impl Component for TexturedQuadExample { } fn on_window_event(&mut self, event: &WindowEvent) -> Result<(), String> { - match event { - WindowEvent::Resize { width, height } => { - self.width = *width; - self.height = *height; - } - _ => {} + if let WindowEvent::Resize { width, height } = event { + self.width = *width; + self.height = *height; } return Ok(()); } diff --git a/crates/lambda-rs/examples/triangle.rs b/crates/lambda-rs/examples/triangle.rs index b868ebfb..827b986d 100644 --- a/crates/lambda-rs/examples/triangle.rs +++ b/crates/lambda-rs/examples/triangle.rs @@ -68,7 +68,7 @@ impl Component for DemoComponent { fn on_detach( self: &mut DemoComponent, - render_context: &mut RenderContext, + _render_context: &mut RenderContext, ) -> Result { return Ok(ComponentResult::Success); } @@ -119,12 +119,9 @@ impl Component for DemoComponent { self: &mut DemoComponent, last_frame: &std::time::Duration, ) -> Result { - match last_frame.as_millis() > 20 { - true => { - logging::warn!("Last frame took {}ms", last_frame.as_millis()); - } - false => {} - }; + if last_frame.as_millis() > 20 { + logging::warn!("Last frame took {}ms", last_frame.as_millis()); + } return Ok(ComponentResult::Success); } fn on_render( @@ -168,7 +165,6 @@ impl DemoComponent {} impl Default for DemoComponent { /// Load in shaders upon creation. - fn default() -> Self { // Specify virtual shaders to use for rendering let triangle_vertex = VirtualShader::Source { diff --git a/crates/lambda-rs/examples/triangles.rs b/crates/lambda-rs/examples/triangles.rs index c88f3981..4669031e 100644 --- a/crates/lambda-rs/examples/triangles.rs +++ b/crates/lambda-rs/examples/triangles.rs @@ -123,13 +123,12 @@ impl Component for TrianglesComponent { let mut commands = vec![RenderCommand::BeginRenderPass { render_pass: self .render_pass - .expect("Cannot begin the render pass when it doesn't exist.") - .clone(), + .expect("Cannot begin the render pass when it doesn't exist."), viewport: viewport.clone(), }]; commands.push(RenderCommand::SetPipeline { - pipeline: render_pipeline.clone(), + pipeline: render_pipeline, }); commands.push(RenderCommand::SetViewports { start_at: 0, @@ -144,7 +143,7 @@ impl Component for TrianglesComponent { // before requesting to draw each triangle. for triangle in triangle_data { commands.push(RenderCommand::Immediates { - pipeline: render_pipeline.clone(), + pipeline: render_pipeline, offset: 0, bytes: Vec::from(immediate_data_to_bytes(triangle)), }); @@ -178,11 +177,12 @@ impl Component for TrianglesComponent { } fn on_keyboard_event(&mut self, event: &Key) -> Result<(), String> { - match event { - Key::Pressed { - scan_code: _, - virtual_key, - } => match virtual_key { + if let Key::Pressed { + scan_code: _, + virtual_key, + } = event + { + match virtual_key { Some(VirtualKey::KeyW) => { self.position.1 -= 0.01; } @@ -196,8 +196,7 @@ impl Component for TrianglesComponent { self.position.0 += 0.01; } _ => {} - }, - _ => {} + } } return Ok(()); } @@ -206,12 +205,9 @@ impl Component for TrianglesComponent { &mut self, last_frame: &std::time::Duration, ) -> Result { - match last_frame.as_millis() > 20 { - true => { - logging::warn!("Last frame took {}ms", last_frame.as_millis()); - } - false => {} - }; + if last_frame.as_millis() > 20 { + logging::warn!("Last frame took {}ms", last_frame.as_millis()); + } return Ok(ComponentResult::Success); } } @@ -237,7 +233,6 @@ pub fn immediate_data_to_bytes(immediate_data: &ImmediateData) -> &[u32] { impl Default for TrianglesComponent { /// Load in shaders upon creation. - fn default() -> Self { // Specify virtual shaders to use for rendering let triangle_vertex = VirtualShader::Source { diff --git a/crates/lambda-rs/examples/uniform_buffer_triangle.rs b/crates/lambda-rs/examples/uniform_buffer_triangle.rs index a23e0c31..52e86b9e 100644 --- a/crates/lambda-rs/examples/uniform_buffer_triangle.rs +++ b/crates/lambda-rs/examples/uniform_buffer_triangle.rs @@ -55,7 +55,6 @@ use lambda::{ runtime::start_runtime, runtimes::{ application::ComponentResult, - ApplicationRuntime, ApplicationRuntimeBuilder, }, }; @@ -149,7 +148,7 @@ impl Component for UniformBufferExample { let mut mesh_builder = MeshBuilder::new(); vertices.iter().for_each(|vertex| { - mesh_builder.with_vertex(vertex.clone()); + mesh_builder.with_vertex(*vertex); }); let mesh = mesh_builder @@ -264,13 +263,10 @@ impl Component for UniformBufferExample { } fn on_window_event(&mut self, event: &WindowEvent) -> Result<(), String> { - match event { - WindowEvent::Resize { width, height } => { - self.width = *width; - self.height = *height; - logging::info!("Window resized to {}x{}", width, height); - } - _ => {} + if let WindowEvent::Resize { width, height } = event { + self.width = *width; + self.height = *height; + logging::info!("Window resized to {}x{}", width, height); } return Ok(()); } @@ -330,12 +326,11 @@ impl Component for UniformBufferExample { RenderCommand::BeginRenderPass { render_pass: self .render_pass - .expect("Cannot begin the render pass when it does not exist.") - .clone(), + .expect("Cannot begin the render pass when it does not exist."), viewport: viewport.clone(), }, RenderCommand::SetPipeline { - pipeline: render_pipeline.clone(), + pipeline: render_pipeline, }, RenderCommand::SetViewports { start_at: 0, @@ -346,7 +341,7 @@ impl Component for UniformBufferExample { viewports: vec![viewport.clone()], }, RenderCommand::BindVertexBuffer { - pipeline: render_pipeline.clone(), + pipeline: render_pipeline, buffer: 0, }, RenderCommand::SetBindGroup { diff --git a/crates/lambda-rs/src/runtimes/application.rs b/crates/lambda-rs/src/runtimes/application.rs index f2f58392..62e94a4b 100644 --- a/crates/lambda-rs/src/runtimes/application.rs +++ b/crates/lambda-rs/src/runtimes/application.rs @@ -339,7 +339,7 @@ impl Runtime<(), String> for ApplicationRuntime { _ => None, }, WinitEvent::AboutToWait => { - let last_frame = current_frame.clone(); + let last_frame = current_frame; current_frame = Instant::now(); let duration = ¤t_frame.duration_since(last_frame); @@ -347,7 +347,15 @@ impl Runtime<(), String> for ApplicationRuntime { .as_mut() .expect("Couldn't get the active render context. "); for component in &mut component_stack { - component.on_update(duration); + let update_result = component.on_update(duration); + if let Err(error) = update_result { + logging::error!("{}", error); + publisher.publish_event(Events::Runtime { + event: RuntimeEvent::ComponentPanic { message: error }, + issued_at: Instant::now(), + }); + continue; + } let commands = component.on_render(active_render_context); active_render_context.render(commands); } @@ -385,13 +393,29 @@ impl Runtime<(), String> for ApplicationRuntime { name ); for component in &mut component_stack { - component.on_attach(active_render_context.as_mut().unwrap()); + let attach_result = + component.on_attach(active_render_context.as_mut().unwrap()); + if let Err(error) = attach_result { + logging::error!("{}", error); + publisher.publish_event(Events::Runtime { + event: RuntimeEvent::ComponentPanic { message: error }, + issued_at: Instant::now(), + }); + } } None } RuntimeEvent::Shutdown => { for component in &mut component_stack { - component.on_detach(active_render_context.as_mut().unwrap()); + let detach_result = + component.on_detach(active_render_context.as_mut().unwrap()); + if let Err(error) = detach_result { + logging::error!("{}", error); + publisher.publish_event(Events::Runtime { + event: RuntimeEvent::ComponentPanic { message: error }, + issued_at: Instant::now(), + }); + } } *runtime_result = Ok(()); None @@ -418,28 +442,22 @@ impl Runtime<(), String> for ApplicationRuntime { } }; - match mapped_event { - Some(event) => { - logging::trace!("Sending event: {:?} to all components", event); + if let Some(event) = mapped_event { + logging::trace!("Sending event: {:?} to all components", event); - let event_mask = event.mask(); - for component in &mut component_stack { - let event_result = dispatch_event_to_component( - &event, - event_mask, - component.as_mut(), - ); + let event_mask = event.mask(); + for component in &mut component_stack { + let event_result = + dispatch_event_to_component(&event, event_mask, component.as_mut()); - if let Err(error) = event_result { - logging::error!("{}", error); - publisher.publish_event(Events::Runtime { - event: RuntimeEvent::ComponentPanic { message: error }, - issued_at: Instant::now(), - }); - } + if let Err(error) = event_result { + logging::error!("{}", error); + publisher.publish_event(Events::Runtime { + event: RuntimeEvent::ComponentPanic { message: error }, + issued_at: Instant::now(), + }); } } - None => {} } }); return Ok(()); From 8a6dcae361bb77d75fdfd947e490556ae816249a Mon Sep 17 00:00:00 2001 From: vmarcella Date: Sat, 17 Jan 2026 16:06:44 -0800 Subject: [PATCH 8/8] [fix] warnings with tools. --- tools/obj_loader/src/main.rs | 37 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/tools/obj_loader/src/main.rs b/tools/obj_loader/src/main.rs index 2a57afd2..55e369ac 100644 --- a/tools/obj_loader/src/main.rs +++ b/tools/obj_loader/src/main.rs @@ -1,3 +1,5 @@ +#![allow(clippy::needless_return)] + use std::env; use args::{ @@ -121,16 +123,17 @@ struct Args { obj_path: String, } -impl Into for Vec { - fn into(self) -> Args { +impl From> for Args { + fn from(arguments: Vec) -> Args { let mut args = Args { obj_path: String::new(), }; - for arg in self { - match (arg.name().as_str(), arg.value()) { - ("--obj-path", ArgumentValue::String(path)) => args.obj_path = path, - (_, _) => {} + for arg in arguments { + if let ("--obj-path", ArgumentValue::String(path)) = + (arg.name().as_str(), arg.value()) + { + args.obj_path = path; } } @@ -149,7 +152,7 @@ fn parse_arguments() -> Args { .with_argument(obj_file) .compile(&env::args().collect::>()); - return args.into(); + return Args::from(args); } struct ObjLoader { @@ -170,13 +173,10 @@ impl Component for ObjLoader { } fn on_window_event(&mut self, event: &WindowEvent) -> Result<(), String> { - match event { - WindowEvent::Resize { width, height } => { - self.width = *width; - self.height = *height; - logging::info!("Window resized to {}x{}", width, height); - } - _ => {} + if let WindowEvent::Resize { width, height } = event { + self.width = *width; + self.height = *height; + logging::info!("Window resized to {}x{}", width, height); } return Ok(()); } @@ -263,21 +263,20 @@ impl Component for ObjLoader { viewports: vec![viewport.clone()], }, RenderCommand::SetPipeline { - pipeline: render_pipeline.clone(), + pipeline: render_pipeline, }, RenderCommand::BeginRenderPass { render_pass: self .render_pass - .expect("Cannot begin the render pass when it doesn't exist.") - .clone(), + .expect("Cannot begin the render pass when it doesn't exist."), viewport: viewport.clone(), }, RenderCommand::BindVertexBuffer { - pipeline: render_pipeline.clone(), + pipeline: render_pipeline, buffer: 0, }, RenderCommand::Immediates { - pipeline: render_pipeline.clone(), + pipeline: render_pipeline, offset: 0, bytes: Vec::from(immediate_data_to_bytes(&ImmediateData { data: [0.0, 0.0, 0.0, 0.0],