sjb3d/spark

clippy report.

Closed this issue · 2 comments

https://gitlab.com/cheako/ash-tray-rs/-/jobs/261551311

Practically everything reported as:

error: you should consider deriving a `Default` implementation for `vkr::builder::InitializePerformanceApiInfoINTELBuilder<'a>`
     --> src/vkr/builder.rs:12889:5
      |
12889 | /     pub fn new() -> Self {
12890 | |         Self {
12891 | |             inner: Default::default(),
12892 | |             phantom: PhantomData,
12893 | |         }
12894 | |     }
      | |_____^
      |
      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#new_without_default
help: try this
      |
12884 | #[derive(Default)]
      |
error: casting integer literal to f32 is unnecessary
   --> src/vkr/vk.rs:141:33
    |
141 | pub const LOD_CLAMP_NONE: f32 = 1000 as f32;
    |                                 ^^^^^^^^^^^ help: try: `1000_f32`
    |
    = note: `-D clippy::unnecessary-cast` implied by `-D warnings`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast

error: redundant closure found
   --> src/vkr.rs:153:18
    |
153 |         .map_err(|e| LoaderError::Vulkan(e))
    |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove closure as shown: `LoaderError::Vulkan`
    |
    = note: `-D clippy::redundant-closure` implied by `-D warnings`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure

error: redundant closure found
    --> src/vkr.rs:1433:18
     |
1433 |         .map_err(|e| LoaderError::Vulkan(e))
     |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove closure as shown: `LoaderError::Vulkan`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure

error: this boolean expression can be simplified
    --> src/vkr.rs:5059:44
     |
5059 |               fp_acquire_next_image2_khr: if extensions.khr_swapchain
     |  ____________________________________________^
5060 | |                 && version >= vk::Version::from_raw_parts(1, 1, 0)
5061 | |                 || extensions.khr_device_group && extensions.khr_swapchain
     | |__________________________________________________________________________^
     |
     = note: `-D clippy::nonminimal-bool` implied by `-D warnings`
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonminimal_bool
help: try
     |
5059 |             fp_acquire_next_image2_khr: if !(version < vk::Version::from_raw_parts(1, 1, 0) && !extensions.khr_device_group || !extensions.khr_swapchain)
     |                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5059 |             fp_acquire_next_image2_khr: if (version >= vk::Version::from_raw_parts(1, 1, 0) || extensions.khr_device_group) && extensions.khr_swapchain
     |                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: this boolean expression can be simplified
    --> src/vkr.rs:5157:62
     |
5157 |               fp_cmd_push_descriptor_set_with_template_khr: if extensions.khr_push_descriptor
     |  ______________________________________________________________^
5158 | |                 && version >= vk::Version::from_raw_parts(1, 1, 0)
5159 | |                 || extensions.khr_descriptor_update_template && extensions.khr_push_descriptor
     | |______________________________________________________________________________________________^
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonminimal_bool
help: try
     |
5157 |             fp_cmd_push_descriptor_set_with_template_khr: if !(version < vk::Version::from_raw_parts(1, 1, 0) && !extensions.khr_descriptor_update_template || !extensions.khr_push_descriptor)
     |                                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5157 |             fp_cmd_push_descriptor_set_with_template_khr: if (version >= vk::Version::from_raw_parts(1, 1, 0) || extensions.khr_descriptor_update_template) && extensions.khr_push_descriptor
     |                                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: this boolean expression can be simplified
    --> src/vkr.rs:5759:64
     |
5759 |               fp_get_device_group_surface_present_modes2_ext: if extensions.ext_full_screen_exclusive
     |  ________________________________________________________________^
5760 | |                 && extensions.khr_device_group
5761 | |                 || extensions.ext_full_screen_exclusive && version >= vk::Version::from_raw_parts(1, 1, 0)
     | |__________________________________________________________________________________________________________^
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonminimal_bool
help: try
     |
5759 |             fp_get_device_group_surface_present_modes2_ext: if !(!extensions.khr_device_group && version < vk::Version::from_raw_parts(1, 1, 0) || !extensions.ext_full_screen_exclusive)
     |                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5759 |             fp_get_device_group_surface_present_modes2_ext: if (extensions.khr_device_group || version >= vk::Version::from_raw_parts(1, 1, 0)) && extensions.ext_full_screen_exclusive
     |                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: casting from `*const u8` to a more-strictly-aligned pointer (`*const u32`)
  --> src/vkr_imgui.rs:14:17
   |
14 |         p_code: bytes.as_ptr() as *const u32,
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: #[deny(clippy::cast_ptr_alignment)] on by default
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_ptr_alignment

error: casting u32 to u64 may become silently lossy if you later change the type
   --> src/vkr_imgui.rs:166:23
    |
166 |                 size: (image_width * image_height * 4) as vk::DeviceSize,
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u64::from(image_width * image_height * 4)`
    |
    = note: `-D clippy::cast-lossless` implied by `-D warnings`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_lossless

error: casting u32 to u64 may become silently lossy if you later change the type
   --> src/vkr_imgui.rs:307:23
    |
307 |                 size: align_up((image_width * image_height * 4) as u32, atom_size) as vk::DeviceSize,
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u64::from(align_up((image_width * image_height * 4) as u32, atom_size))`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_lossless

error: calls to `std::mem::forget` with a value that implements Copy. Forgetting a copy leaves the original intact.
   --> src/vkr_imgui.rs:466:33
    |
466 |                         offset: offset_of!(ImDrawVert, pos) as u32,
    |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: #[deny(clippy::forget_copy)] on by default
note: argument has type imgui_sys::structs::ImDrawVert
   --> src/vkr_imgui.rs:466:33
    |
466 |                         offset: offset_of!(ImDrawVert, pos) as u32,
    |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#forget_copy
    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: calls to `std::mem::forget` with a value that implements Copy. Forgetting a copy leaves the original intact.
   --> src/vkr_imgui.rs:472:33
    |
472 |                         offset: offset_of!(ImDrawVert, uv) as u32,
    |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
note: argument has type imgui_sys::structs::ImDrawVert
   --> src/vkr_imgui.rs:472:33
    |
472 |                         offset: offset_of!(ImDrawVert, uv) as u32,
    |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#forget_copy
    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: calls to `std::mem::forget` with a value that implements Copy. Forgetting a copy leaves the original intact.
   --> src/vkr_imgui.rs:478:33
    |
478 |                         offset: offset_of!(ImDrawVert, col) as u32,
    |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
note: argument has type imgui_sys::structs::ImDrawVert
   --> src/vkr_imgui.rs:478:33
    |
478 |                         offset: offset_of!(ImDrawVert, col) as u32,
    |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#forget_copy
    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: casting from `*mut u8` to a more-strictly-aligned pointer (`*mut imgui_sys::structs::ImDrawVert`)
   --> src/vkr_imgui.rs:606:17
    |
606 |                 unsafe { (self.host_mapping as *mut u8).add(vertex_mem_offset) } as *mut ImDrawVert;
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_ptr_alignment

error: casting from `*mut u8` to a more-strictly-aligned pointer (`*mut u16`)
   --> src/vkr_imgui.rs:608:17
    |
608 |                 unsafe { (self.host_mapping as *mut u8).add(index_mem_offset) } as *mut ImDrawIdx;
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_ptr_alignment

error: casting u32 to u64 may become silently lossy if you later change the type
   --> src/vkr_imgui.rs:663:27
    |
663 |                       size: align_up(
    |  ___________________________^
664 | |                         (vertex_offset * mem::size_of::<ImDrawVert>()) as u32,
665 | |                         self.atom_size,
666 | |                     ) as vk::DeviceSize,
    | |_______________________________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_lossless
help: try
    |
663 |                     size: u64::from(align_up(
664 |                         (vertex_offset * mem::size_of::<ImDrawVert>()) as u32,
665 |                         self.atom_size,
666 |                     )),
    |

error: casting u32 to u64 may become silently lossy if you later change the type
   --> src/vkr_imgui.rs:672:27
    |
672 |                       size: align_up(
    |  ___________________________^
673 | |                         (index_offset * mem::size_of::<ImDrawIdx>()) as u32,
674 | |                         self.atom_size,
675 | |                     ) as vk::DeviceSize,
    | |_______________________________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_lossless
help: try
    |
672 |                     size: u64::from(align_up(
673 |                         (index_offset * mem::size_of::<ImDrawIdx>()) as u32,
674 |                         self.atom_size,
675 |                     )),
    |
sjb3d commented

Apologies for the delayed response, I had not watched the repo, so have only just seen the issue.

Yep fair enough there is a lot of clippy output from vkr and vkr-imgui, I should fix (or silence) it.

sjb3d commented

Ah nice, issues can be closed by commit comments.

So I'd already done the clippy suggestion for Default on builders, the previous commit either fixes (or silences in generated code) the remaining clippy issues. So at least in rustc 1.36, clippy should pass for vkr and vkr-imgui.