Fix clippy warnings from Rust 1.66 (#2105)

This commit is contained in:
Rua 2022-12-18 17:23:40 +01:00 committed by GitHub
parent 9acc2fcda6
commit 6eb526322b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 36 additions and 38 deletions

View File

@ -285,8 +285,8 @@ impl InputState {
fn normalized_mouse_pos(&self) -> Vector2<f32> { fn normalized_mouse_pos(&self) -> Vector2<f32> {
Vector2::new( Vector2::new(
(self.mouse_pos.x / self.window_size[0] as f32).clamp(0.0, 1.0), (self.mouse_pos.x / self.window_size[0]).clamp(0.0, 1.0),
(self.mouse_pos.y / self.window_size[1] as f32).clamp(0.0, 1.0), (self.mouse_pos.y / self.window_size[1]).clamp(0.0, 1.0),
) )
} }

View File

@ -149,8 +149,8 @@ fn draw_life(
let window_size = window.window_size(); let window_size = window.window_size();
let compute_pipeline = &mut app.pipelines.get_mut(id).unwrap().compute; let compute_pipeline = &mut app.pipelines.get_mut(id).unwrap().compute;
let mut normalized_pos = Vector2::new( let mut normalized_pos = Vector2::new(
(cursor_pos.x / window_size[0] as f32).clamp(0.0, 1.0), (cursor_pos.x / window_size[0]).clamp(0.0, 1.0),
(cursor_pos.y / window_size[1] as f32).clamp(0.0, 1.0), (cursor_pos.y / window_size[1]).clamp(0.0, 1.0),
); );
// flip y // flip y
normalized_pos.y = 1.0 - normalized_pos.y; normalized_pos.y = 1.0 - normalized_pos.y;

View File

@ -148,7 +148,7 @@ fn main() {
SwapchainCreateInfo { SwapchainCreateInfo {
min_image_count: surface_capabilities.min_image_count, min_image_count: surface_capabilities.min_image_count,
image_format, image_format,
image_extent: [WINDOW_WIDTH as u32, WINDOW_HEIGHT as u32], image_extent: [WINDOW_WIDTH, WINDOW_HEIGHT],
image_usage: ImageUsage::COLOR_ATTACHMENT, image_usage: ImageUsage::COLOR_ATTACHMENT,
composite_alpha: surface_capabilities composite_alpha: surface_capabilities
.supported_composite_alpha .supported_composite_alpha

View File

@ -616,7 +616,7 @@ pub(super) fn type_from_id(
( (
quote! { [#element_type; #array_length] }, quote! { [#element_type; #array_length] },
Cow::from(format!("[{}; {}]", element_type_string, array_length)), Cow::from(format!("[{}; {}]", element_type_string, array_length)),
Some(element_size * array_length as usize), Some(element_size * array_length),
element_align, element_align,
) )
} }

View File

@ -271,7 +271,7 @@ impl VulkanoContext {
self.device self.device
.physical_device() .physical_device()
.properties() .properties()
.max_memory_allocation_count as u32 .max_memory_allocation_count
} }
/// Returns the instance. /// Returns the instance.

View File

@ -1192,8 +1192,8 @@ impl UnsafeCommandBufferBuilder {
self.handle, self.handle,
pipeline_layout.handle(), pipeline_layout.handle(),
stages.into(), stages.into(),
offset as u32, offset,
size as u32, size,
data.as_bytes().as_ptr() as *const _, data.as_bytes().as_ptr() as *const _,
); );
} }

View File

@ -647,7 +647,8 @@ where
let layout_binding = let layout_binding =
&pipeline.layout().set_layouts()[set_num as usize].bindings()[&binding_num]; &pipeline.layout().set_layouts()[set_num as usize].bindings()[&binding_num];
let check_buffer = |_index: u32, (_buffer, _range): &(Arc<dyn BufferAccess>, Range<DeviceSize>)| Ok(()); let check_buffer =
|_index: u32, (_buffer, _range): &(Arc<dyn BufferAccess>, Range<DeviceSize>)| Ok(());
let check_buffer_view = |index: u32, buffer_view: &Arc<dyn BufferViewAbstract>| { let check_buffer_view = |index: u32, buffer_view: &Arc<dyn BufferViewAbstract>| {
for desc_reqs in (binding_reqs.descriptors.get(&Some(index)).into_iter()) for desc_reqs in (binding_reqs.descriptors.get(&Some(index)).into_iter())
@ -1574,7 +1575,7 @@ where
None => return Err(PipelineExecutionError::VertexBufferNotBound { binding_num }), None => return Err(PipelineExecutionError::VertexBufferNotBound { binding_num }),
}; };
let mut num_elements = vertex_buffer.size() as u64 / binding_desc.stride as u64; let mut num_elements = vertex_buffer.size() / binding_desc.stride as u64;
match binding_desc.input_rate { match binding_desc.input_rate {
VertexInputRate::Vertex => { VertexInputRate::Vertex => {
@ -2146,13 +2147,13 @@ impl SyncCommandBufferBuilder {
let descriptor_set_state = &descriptor_sets_state.descriptor_sets[&set]; let descriptor_set_state = &descriptor_sets_state.descriptor_sets[&set];
match descriptor_set_state.resources() match descriptor_set_state.resources().binding(binding).unwrap() {
.binding(binding)
.unwrap()
{
DescriptorBindingResources::None(_) => continue, DescriptorBindingResources::None(_) => continue,
DescriptorBindingResources::Buffer(elements) => { DescriptorBindingResources::Buffer(elements) => {
if matches!(descriptor_type, DescriptorType::UniformBufferDynamic | DescriptorType::StorageBufferDynamic) { if matches!(
descriptor_type,
DescriptorType::UniformBufferDynamic | DescriptorType::StorageBufferDynamic
) {
let dynamic_offsets = descriptor_set_state.dynamic_offsets(); let dynamic_offsets = descriptor_set_state.dynamic_offsets();
resources.extend( resources.extend(
(elements.iter().enumerate()) (elements.iter().enumerate())
@ -2163,7 +2164,8 @@ impl SyncCommandBufferBuilder {
( (
index as u32, index as u32,
buffer.clone(), buffer.clone(),
dynamic_offset + range.start..dynamic_offset + range.end, dynamic_offset + range.start
..dynamic_offset + range.end,
) )
}) })
}) })
@ -2174,11 +2176,7 @@ impl SyncCommandBufferBuilder {
(elements.iter().enumerate()) (elements.iter().enumerate())
.filter_map(|(index, element)| { .filter_map(|(index, element)| {
element.as_ref().map(|(buffer, range)| { element.as_ref().map(|(buffer, range)| {
( (index as u32, buffer.clone(), range.clone())
index as u32,
buffer.clone(),
range.clone(),
)
}) })
}) })
.flat_map(buffer_resource), .flat_map(buffer_resource),

View File

@ -722,7 +722,7 @@ where
self.handle(), self.handle(),
pipeline_layout.handle(), pipeline_layout.handle(),
range.stages.into(), range.stages.into(),
current_offset as u32, current_offset,
values.len() as u32, values.len() as u32,
values.as_ptr() as *const _, values.as_ptr() as *const _,
); );

View File

@ -37,10 +37,10 @@ use crate::{
ShaderStages, ShaderStages,
}, },
sync::PipelineStageAccess, sync::PipelineStageAccess,
RequiresOneOf, VulkanObject, DeviceSize, DeviceSize, RequiresOneOf, VulkanObject,
}; };
use ahash::HashMap; use ahash::HashMap;
use std::{cmp::min, mem::size_of, sync::Arc, ops::Range}; use std::{cmp::min, mem::size_of, ops::Range, sync::Arc};
impl<L, A> CommandBufferBuilder<L, A> impl<L, A> CommandBufferBuilder<L, A>
where where
@ -995,7 +995,8 @@ where
let layout_binding = let layout_binding =
&pipeline.layout().set_layouts()[set_num as usize].bindings()[&binding_num]; &pipeline.layout().set_layouts()[set_num as usize].bindings()[&binding_num];
let check_buffer = |_index: u32, (_buffer, _range): &(Arc<dyn BufferAccess>, Range<DeviceSize>)| Ok(()); let check_buffer =
|_index: u32, (_buffer, _range): &(Arc<dyn BufferAccess>, Range<DeviceSize>)| Ok(());
let check_buffer_view = |index: u32, buffer_view: &Arc<dyn BufferViewAbstract>| { let check_buffer_view = |index: u32, buffer_view: &Arc<dyn BufferViewAbstract>| {
for desc_reqs in (binding_reqs.descriptors.get(&Some(index)).into_iter()) for desc_reqs in (binding_reqs.descriptors.get(&Some(index)).into_iter())
@ -1912,7 +1913,7 @@ where
None => return Err(PipelineExecutionError::VertexBufferNotBound { binding_num }), None => return Err(PipelineExecutionError::VertexBufferNotBound { binding_num }),
}; };
let mut num_elements = vertex_buffer.size() as u64 / binding_desc.stride as u64; let mut num_elements = vertex_buffer.size() / binding_desc.stride as u64;
match binding_desc.input_rate { match binding_desc.input_rate {
VertexInputRate::Vertex => { VertexInputRate::Vertex => {
@ -2060,14 +2061,13 @@ fn record_descriptor_sets_access(
let descriptor_set_state = &descriptor_sets_state.descriptor_sets[&set]; let descriptor_set_state = &descriptor_sets_state.descriptor_sets[&set];
match descriptor_set_state match descriptor_set_state.resources().binding(binding).unwrap() {
.resources()
.binding(binding)
.unwrap()
{
DescriptorBindingResources::None(_) => continue, DescriptorBindingResources::None(_) => continue,
DescriptorBindingResources::Buffer(elements) => { DescriptorBindingResources::Buffer(elements) => {
if matches!(descriptor_type, DescriptorType::UniformBufferDynamic | DescriptorType::StorageBufferDynamic) { if matches!(
descriptor_type,
DescriptorType::UniformBufferDynamic | DescriptorType::StorageBufferDynamic
) {
let dynamic_offsets = descriptor_set_state.dynamic_offsets(); let dynamic_offsets = descriptor_set_state.dynamic_offsets();
for (index, element) in elements.iter().enumerate() { for (index, element) in elements.iter().enumerate() {

View File

@ -217,7 +217,7 @@ impl PipelineCache {
.result() .result()
.map_err(VulkanError::from)?; .map_err(VulkanError::from)?;
let mut data: Vec<u8> = Vec::with_capacity(count as usize); let mut data: Vec<u8> = Vec::with_capacity(count);
let result = (fns.v1_0.get_pipeline_cache_data)( let result = (fns.v1_0.get_pipeline_cache_data)(
self.device.handle(), self.device.handle(),
self.cache, self.cache,
@ -227,7 +227,7 @@ impl PipelineCache {
match result { match result {
ash::vk::Result::SUCCESS => { ash::vk::Result::SUCCESS => {
data.set_len(count as usize); data.set_len(count);
break data; break data;
} }
ash::vk::Result::INCOMPLETE => (), ash::vk::Result::INCOMPLETE => (),

View File

@ -756,8 +756,8 @@ fn inspect_entry_point(
context context
.result .result
.into_iter() .into_values()
.map(|(_, variable)| ((variable.set, variable.binding), variable.reqs)) .map(|variable| ((variable.set, variable.binding), variable.reqs))
.collect() .collect()
} }

View File

@ -1993,7 +1993,7 @@ where
} }
let mut swapchain_info = self.swapchain_info.clone(); let mut swapchain_info = self.swapchain_info.clone();
debug_assert!((swapchain_info.image_index as u32) < swapchain_info.swapchain.image_count()); debug_assert!(swapchain_info.image_index < swapchain_info.swapchain.image_count());
let device = swapchain_info.swapchain.device(); let device = swapchain_info.swapchain.device();
if !device.enabled_features().present_id { if !device.enabled_features().present_id {