From 127e6fd0c499c6ebce349f24f2d36c3125954e26 Mon Sep 17 00:00:00 2001 From: Matthew Russo Date: Sat, 9 Feb 2019 22:01:47 -0500 Subject: [PATCH] fixes clippy issues --- src/bin/22_descriptor_pools_and_sets.rs | 14 ++++---- src/bin/22_descriptor_pools_and_sets.rs.diff | 35 +++++++++++++++----- 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/src/bin/22_descriptor_pools_and_sets.rs b/src/bin/22_descriptor_pools_and_sets.rs index e8e61c4..662d45d 100644 --- a/src/bin/22_descriptor_pools_and_sets.rs +++ b/src/bin/22_descriptor_pools_and_sets.rs @@ -108,6 +108,7 @@ impl Vertex { } impl_vertex!(Vertex, pos, color); +#[allow(dead_code)] #[derive(Copy, Clone)] struct UniformBufferObject { model: glm::Mat4, @@ -252,7 +253,7 @@ impl HelloTriangleApplication { let required_extensions = Self::get_required_extensions(); if ENABLE_VALIDATION_LAYERS && Self::check_validation_layer_support() { - Instance::new(Some(&app_info), &required_extensions, VALIDATION_LAYERS.iter().map(|s| *s)) + Instance::new(Some(&app_info), &required_extensions, VALIDATION_LAYERS.iter().cloned()) .expect("failed to create Vulkan instance") } else { Instance::new(Some(&app_info), &required_extensions, None) @@ -478,7 +479,7 @@ impl HelloTriangleApplication { } fn create_framebuffers( - swap_chain_images: &Vec>>, + swap_chain_images: &[Arc>], render_pass: &Arc ) -> Vec> { swap_chain_images.iter() @@ -546,7 +547,7 @@ impl HelloTriangleApplication { fn create_descriptor_sets( pool: &Arc>>>, - uniform_buffers: &Vec>>, + uniform_buffers: &[Arc>], ) -> Vec, ((), vulkano::descriptor::descriptor_set::PersistentDescriptorSetBuf>>)>>> { uniform_buffers @@ -669,9 +670,8 @@ impl HelloTriangleApplication { let mut done = false; self.events_loop.poll_events(|ev| { - match ev { - Event::WindowEvent { event: WindowEvent::CloseRequested, .. } => done = true, - _ => () + if let Event::WindowEvent { event: WindowEvent::CloseRequested, .. } = ev { + done = true } }); if done { @@ -725,7 +725,7 @@ impl HelloTriangleApplication { fn update_uniform_buffer(start_time: Instant, dimensions: [f32; 2]) -> UniformBufferObject { let duration = Instant::now().duration_since(start_time); - let elapsed = (duration.as_secs() * 1000) + duration.subsec_millis() as u64; + let elapsed = (duration.as_secs() * 1000) + u64::from(duration.subsec_millis()); let identity_matrix = glm::mat4( 1.0, 0.0, 0.0, 0.0, diff --git a/src/bin/22_descriptor_pools_and_sets.rs.diff b/src/bin/22_descriptor_pools_and_sets.rs.diff index a0e3dcb..abe610d 100644 --- a/src/bin/22_descriptor_pools_and_sets.rs.diff +++ b/src/bin/22_descriptor_pools_and_sets.rs.diff @@ -22,8 +22,21 @@ }; const WIDTH: u32 = 800; -@@ -150,6 +154,8 @@ struct HelloTriangleApplication { +@@ -102,8 +106,6 @@ impl Vertex { + Self { pos, color } + } + } +- +-#[allow(clippy:ref_in_deref)] + impl_vertex!(Vertex, pos, color); + + #[allow(dead_code)] +@@ -151,16 +153,15 @@ struct HelloTriangleApplication { + + vertex_buffer: Arc, index_buffer: Arc + Send + Sync>, +- +- #[allow(dead_code)] uniform_buffers: Vec>>, + descriptor_sets: Vec, ((), vulkano::descriptor::descriptor_set::PersistentDescriptorSetBuf>>)>>>, @@ -31,7 +44,13 @@ command_buffers: Vec>, previous_frame_end: Option>, -@@ -183,6 +189,9 @@ impl HelloTriangleApplication { + recreate_swap_chain: bool, + +- #[allow(dead_code)] + start_time: Instant, + } + +@@ -189,6 +190,9 @@ impl HelloTriangleApplication { let index_buffer = Self::create_index_buffer(&graphics_queue); let uniform_buffers = Self::create_uniform_buffers(&device, swap_chain_images.len(), start_time, swap_chain.dimensions()); @@ -41,7 +60,7 @@ let previous_frame_end = Some(Self::create_sync_objects(&device)); let mut app = Self { -@@ -210,6 +219,8 @@ impl HelloTriangleApplication { +@@ -216,6 +220,8 @@ impl HelloTriangleApplication { index_buffer, uniform_buffers, @@ -50,7 +69,7 @@ command_buffers: vec![], previous_frame_end, -@@ -457,7 +468,7 @@ impl HelloTriangleApplication { +@@ -463,7 +469,7 @@ impl HelloTriangleApplication { .polygon_mode_fill() // = default .line_width(1.0) // = default .cull_mode_back() @@ -59,7 +78,7 @@ // NOTE: no depth_bias here, but on pipeline::raster::Rasterization .blend_pass_through() // = default .render_pass(Subpass::from(render_pass.clone(), 0).unwrap()) -@@ -523,12 +534,50 @@ impl HelloTriangleApplication { +@@ -529,12 +535,50 @@ impl HelloTriangleApplication { buffers } @@ -75,7 +94,7 @@ + + fn create_descriptor_sets( + pool: &Arc>>>, -+ uniform_buffers: &Vec>>, ++ uniform_buffers: &[Arc>], + ) -> Vec, ((), vulkano::descriptor::descriptor_set::PersistentDescriptorSetBuf>>)>>> + { + uniform_buffers @@ -112,7 +131,7 @@ .begin_render_pass(framebuffer.clone(), false, vec![[0.0, 0.0, 0.0, 1.0].into()]) .unwrap() .draw_indexed( -@@ -536,7 +585,7 @@ impl HelloTriangleApplication { +@@ -542,7 +586,7 @@ impl HelloTriangleApplication { &DynamicState::none(), vec![self.vertex_buffer.clone()], self.index_buffer.clone(), @@ -121,7 +140,7 @@ ()) .unwrap() .end_render_pass() -@@ -615,6 +664,7 @@ impl HelloTriangleApplication { +@@ -621,6 +665,7 @@ impl HelloTriangleApplication { #[allow(unused)] fn main_loop(&mut self) { loop {