refactor(workspace): use #[expect] over #[allow] for lint suppressions
This commit is contained in:
parent
645ba6d301
commit
8045c3cae3
|
|
@ -61,7 +61,7 @@ impl Camera {
|
||||||
/// Advances the camera by a single frame, applying `input` accumulated over `dt` seconds.
|
/// Advances the camera by a single frame, applying `input` accumulated over `dt` seconds.
|
||||||
pub fn update(&mut self, input: &InputState, dt: f32) {
|
pub fn update(&mut self, input: &InputState, dt: f32) {
|
||||||
// Apply accumulated mouse motion to the orientation. A downward mouse delta (positive y) lowers the pitch, so the vertical term is subtracted.
|
// Apply accumulated mouse motion to the orientation. A downward mouse delta (positive y) lowers the pitch, so the vertical term is subtracted.
|
||||||
#[allow(clippy::cast_possible_truncation)]
|
#[expect(clippy::cast_possible_truncation)]
|
||||||
{
|
{
|
||||||
self.yaw += input.mouse_delta.0 as f32 * self.sensitivity;
|
self.yaw += input.mouse_delta.0 as f32 * self.sensitivity;
|
||||||
self.pitch -= input.mouse_delta.1 as f32 * self.sensitivity;
|
self.pitch -= input.mouse_delta.1 as f32 * self.sensitivity;
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ use winit::window::{CursorGrabMode, Window, WindowId};
|
||||||
/// Keyboard fields hold whether a movement key is currently pressed. `mouse_delta` accumulates
|
/// Keyboard fields hold whether a movement key is currently pressed. `mouse_delta` accumulates
|
||||||
/// raw pointer motion between frames and is consumed (reset to zero) once applied to the camera.
|
/// raw pointer motion between frames and is consumed (reset to zero) once applied to the camera.
|
||||||
// The bools are independent per-key held states, for which a flat struct is the clearest form.
|
// The bools are independent per-key held states, for which a flat struct is the clearest form.
|
||||||
#[allow(clippy::struct_excessive_bools)]
|
#[expect(clippy::struct_excessive_bools)]
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct InputState {
|
struct InputState {
|
||||||
/// Whether the "move forward" key (W) is held.
|
/// Whether the "move forward" key (W) is held.
|
||||||
|
|
@ -143,10 +143,10 @@ impl ApplicationHandler for App {
|
||||||
self.window = Some(window);
|
self.window = Some(window);
|
||||||
self.renderer = Some(renderer);
|
self.renderer = Some(renderer);
|
||||||
|
|
||||||
#[allow(clippy::expect_used)]
|
#[expect(clippy::expect_used)]
|
||||||
let config_str = std::fs::read_to_string("assets/data/worldgen/default.json")
|
let config_str = std::fs::read_to_string("assets/data/worldgen/default.json")
|
||||||
.expect("Failed to read worldgen config");
|
.expect("Failed to read worldgen config");
|
||||||
#[allow(clippy::expect_used)]
|
#[expect(clippy::expect_used)]
|
||||||
let worldgen_config: shared::generator::WorldGenConfig =
|
let worldgen_config: shared::generator::WorldGenConfig =
|
||||||
serde_json::from_str(&config_str).expect("Failed to parse worldgen config");
|
serde_json::from_str(&config_str).expect("Failed to parse worldgen config");
|
||||||
|
|
||||||
|
|
@ -162,7 +162,7 @@ impl ApplicationHandler for App {
|
||||||
indices.len()
|
indices.len()
|
||||||
);
|
);
|
||||||
|
|
||||||
#[allow(clippy::expect_used)]
|
#[expect(clippy::expect_used)]
|
||||||
self.renderer
|
self.renderer
|
||||||
.as_mut()
|
.as_mut()
|
||||||
.expect("Renderer initialized")
|
.expect("Renderer initialized")
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
use renderer::mesh::Vertex;
|
use renderer::mesh::Vertex;
|
||||||
use shared::world::{BlockId, CHUNK_SIZE, Chunk};
|
use shared::world::{BlockId, CHUNK_SIZE, Chunk};
|
||||||
|
|
||||||
#[allow(
|
#[expect(
|
||||||
clippy::cast_precision_loss,
|
clippy::cast_precision_loss,
|
||||||
clippy::cast_possible_truncation,
|
clippy::cast_possible_truncation,
|
||||||
clippy::too_many_lines
|
clippy::too_many_lines
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ pub fn find_graphics_queue_family(
|
||||||
let props = unsafe { instance.get_physical_device_queue_family_properties(physical_device) };
|
let props = unsafe { instance.get_physical_device_queue_family_properties(physical_device) };
|
||||||
|
|
||||||
for (index, prop) in props.iter().enumerate() {
|
for (index, prop) in props.iter().enumerate() {
|
||||||
#[allow(clippy::expect_used)]
|
#[expect(clippy::expect_used)]
|
||||||
let index = u32::try_from(index).expect("Queue family index exceeds u32 range");
|
let index = u32::try_from(index).expect("Queue family index exceeds u32 range");
|
||||||
let graphics = prop.queue_flags.contains(vk::QueueFlags::GRAPHICS);
|
let graphics = prop.queue_flags.contains(vk::QueueFlags::GRAPHICS);
|
||||||
let present = unsafe {
|
let present = unsafe {
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,6 @@ impl Renderer {
|
||||||
///
|
///
|
||||||
/// Panics if `MAX_FRAMES_IN_FLIGHT` or vertex data sizes exceed `u32`/`u64` limits.
|
/// Panics if `MAX_FRAMES_IN_FLIGHT` or vertex data sizes exceed `u32`/`u64` limits.
|
||||||
// TODO: partial-construction leak. Each `?` below early-returns and leaks every Vulkan resource created so far; only a fully successful `new` reaches `Drop for Renderer`. Once the renderer grows more state, wrap each resource in an RAII guard so failure paths tear them down too.
|
// TODO: partial-construction leak. Each `?` below early-returns and leaks every Vulkan resource created so far; only a fully successful `new` reaches `Drop for Renderer`. Once the renderer grows more state, wrap each resource in an RAII guard so failure paths tear them down too.
|
||||||
#[allow(clippy::expect_used)]
|
|
||||||
pub fn new(
|
pub fn new(
|
||||||
display_handle: RawDisplayHandle,
|
display_handle: RawDisplayHandle,
|
||||||
window_handle: RawWindowHandle,
|
window_handle: RawWindowHandle,
|
||||||
|
|
@ -97,7 +96,7 @@ impl Renderer {
|
||||||
let command_pool = unsafe { device.create_command_pool(&pool_create_info, None)? };
|
let command_pool = unsafe { device.create_command_pool(&pool_create_info, None)? };
|
||||||
|
|
||||||
// 9. Command Buffers
|
// 9. Command Buffers
|
||||||
#[allow(clippy::expect_used)]
|
#[expect(clippy::expect_used)]
|
||||||
let alloc_info = vk::CommandBufferAllocateInfo::default()
|
let alloc_info = vk::CommandBufferAllocateInfo::default()
|
||||||
.command_pool(command_pool)
|
.command_pool(command_pool)
|
||||||
.level(vk::CommandBufferLevel::PRIMARY)
|
.level(vk::CommandBufferLevel::PRIMARY)
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ impl Vertex {
|
||||||
///
|
///
|
||||||
/// # Panics
|
/// # Panics
|
||||||
/// Panics if the size of the vertex structure exceeds the maximum value of a 32-bit unsigned integer.
|
/// Panics if the size of the vertex structure exceeds the maximum value of a 32-bit unsigned integer.
|
||||||
#[allow(clippy::expect_used)]
|
#[expect(clippy::expect_used)]
|
||||||
pub fn get_binding_description() -> ash::vk::VertexInputBindingDescription {
|
pub fn get_binding_description() -> ash::vk::VertexInputBindingDescription {
|
||||||
ash::vk::VertexInputBindingDescription::default()
|
ash::vk::VertexInputBindingDescription::default()
|
||||||
.binding(0)
|
.binding(0)
|
||||||
|
|
@ -37,7 +37,6 @@ impl Vertex {
|
||||||
/// Describes the layout of individual fields (attributes) within a single vertex.
|
/// Describes the layout of individual fields (attributes) within a single vertex.
|
||||||
///
|
///
|
||||||
/// These 'locations' must match the `layout(location = X)` qualifiers in the vertex shader.
|
/// These 'locations' must match the `layout(location = X)` qualifiers in the vertex shader.
|
||||||
#[allow(clippy::expect_used)]
|
|
||||||
pub fn get_attribute_descriptions() -> [ash::vk::VertexInputAttributeDescription; 2] {
|
pub fn get_attribute_descriptions() -> [ash::vk::VertexInputAttributeDescription; 2] {
|
||||||
[
|
[
|
||||||
// Location 0: position (vec3 -> R32G32B32_SFLOAT)
|
// Location 0: position (vec3 -> R32G32B32_SFLOAT)
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ pub fn create_shader_module(
|
||||||
/// This layout defines any push constants or descriptor sets (textures/UBOs) accessed by the shaders during execution.
|
/// This layout defines any push constants or descriptor sets (textures/UBOs) accessed by the shaders during execution.
|
||||||
pub fn create_pipeline_layout(device: &Device) -> Result<vk::PipelineLayout, RendererError> {
|
pub fn create_pipeline_layout(device: &Device) -> Result<vk::PipelineLayout, RendererError> {
|
||||||
// A single push constant range is defined for the MVP matrix, allowing it to be updated for every draw call with high efficiency.
|
// A single push constant range is defined for the MVP matrix, allowing it to be updated for every draw call with high efficiency.
|
||||||
#[allow(clippy::expect_used)]
|
#[expect(clippy::expect_used)]
|
||||||
let push_constant_range = vk::PushConstantRange::default()
|
let push_constant_range = vk::PushConstantRange::default()
|
||||||
.stage_flags(vk::ShaderStageFlags::VERTEX)
|
.stage_flags(vk::ShaderStageFlags::VERTEX)
|
||||||
.offset(0)
|
.offset(0)
|
||||||
|
|
|
||||||
|
|
@ -17,14 +17,14 @@ pub struct Renderer {
|
||||||
/// The debug messenger for validation layer output.
|
/// The debug messenger for validation layer output.
|
||||||
pub(crate) debug_messenger: vk::DebugUtilsMessengerEXT,
|
pub(crate) debug_messenger: vk::DebugUtilsMessengerEXT,
|
||||||
/// Handle to the selected physical device (GPU).
|
/// Handle to the selected physical device (GPU).
|
||||||
#[allow(dead_code)]
|
#[expect(dead_code)]
|
||||||
pub(crate) physical_device: vk::PhysicalDevice,
|
pub(crate) physical_device: vk::PhysicalDevice,
|
||||||
/// The logical Vulkan device.
|
/// The logical Vulkan device.
|
||||||
pub(crate) device: Device,
|
pub(crate) device: Device,
|
||||||
/// The queue used for graphics operations.
|
/// The queue used for graphics operations.
|
||||||
pub(crate) graphics_queue: vk::Queue,
|
pub(crate) graphics_queue: vk::Queue,
|
||||||
/// Index of the graphics queue family.
|
/// Index of the graphics queue family.
|
||||||
#[allow(dead_code)]
|
#[expect(dead_code)]
|
||||||
pub(crate) graphics_queue_index: u32,
|
pub(crate) graphics_queue_index: u32,
|
||||||
/// Surface extension loader.
|
/// Surface extension loader.
|
||||||
pub(crate) surface_loader: khr::surface::Instance,
|
pub(crate) surface_loader: khr::surface::Instance,
|
||||||
|
|
@ -37,7 +37,7 @@ pub struct Renderer {
|
||||||
/// Images acquired from the swapchain.
|
/// Images acquired from the swapchain.
|
||||||
pub(crate) swapchain_images: Vec<vk::Image>,
|
pub(crate) swapchain_images: Vec<vk::Image>,
|
||||||
/// The pixel format of the swapchain images.
|
/// The pixel format of the swapchain images.
|
||||||
#[allow(dead_code)]
|
#[expect(dead_code)]
|
||||||
pub(crate) swapchain_format: vk::Format,
|
pub(crate) swapchain_format: vk::Format,
|
||||||
/// The dimensions of the swapchain images.
|
/// The dimensions of the swapchain images.
|
||||||
pub(crate) swapchain_extent: vk::Extent2D,
|
pub(crate) swapchain_extent: vk::Extent2D,
|
||||||
|
|
@ -262,7 +262,7 @@ impl Renderer {
|
||||||
self.graphics_pipeline,
|
self.graphics_pipeline,
|
||||||
);
|
);
|
||||||
|
|
||||||
#[allow(clippy::cast_precision_loss)]
|
#[expect(clippy::cast_precision_loss)]
|
||||||
let viewport = vk::Viewport {
|
let viewport = vk::Viewport {
|
||||||
x: 0.0,
|
x: 0.0,
|
||||||
y: 0.0,
|
y: 0.0,
|
||||||
|
|
@ -284,10 +284,9 @@ impl Renderer {
|
||||||
self.device
|
self.device
|
||||||
.cmd_bind_index_buffer(cmd, self.index_buffer, 0, vk::IndexType::UINT32);
|
.cmd_bind_index_buffer(cmd, self.index_buffer, 0, vk::IndexType::UINT32);
|
||||||
|
|
||||||
#[allow(clippy::cast_precision_loss)]
|
|
||||||
let aspect =
|
let aspect =
|
||||||
f64::from(self.swapchain_extent.width) / f64::from(self.swapchain_extent.height);
|
f64::from(self.swapchain_extent.width) / f64::from(self.swapchain_extent.height);
|
||||||
#[allow(clippy::cast_possible_truncation)]
|
#[expect(clippy::cast_possible_truncation)]
|
||||||
let mut projection =
|
let mut projection =
|
||||||
glam::Mat4::perspective_rh(45.0_f32.to_radians(), aspect as f32, 0.1, 500.0);
|
glam::Mat4::perspective_rh(45.0_f32.to_radians(), aspect as f32, 0.1, 500.0);
|
||||||
// Vulkan clip space inverts the Y axis relative to the OpenGL convention glam targets.
|
// Vulkan clip space inverts the Y axis relative to the OpenGL convention glam targets.
|
||||||
|
|
@ -349,7 +348,7 @@ impl Renderer {
|
||||||
///
|
///
|
||||||
/// # Errors
|
/// # Errors
|
||||||
/// Returns a `RendererError` if new Vulkan buffers cannot be allocated or created.
|
/// Returns a `RendererError` if new Vulkan buffers cannot be allocated or created.
|
||||||
#[allow(clippy::cast_possible_truncation)]
|
#[expect(clippy::cast_possible_truncation)]
|
||||||
pub fn update_mesh(
|
pub fn update_mesh(
|
||||||
&mut self,
|
&mut self,
|
||||||
vertices: &[Vertex],
|
vertices: &[Vertex],
|
||||||
|
|
|
||||||
|
|
@ -26,11 +26,11 @@ fn main() {
|
||||||
|
|
||||||
info!("Starting Synvael server");
|
info!("Starting Synvael server");
|
||||||
|
|
||||||
#[allow(clippy::expect_used)]
|
#[expect(clippy::expect_used)]
|
||||||
let config_str = fs::read_to_string("assets/data/worldgen/default.json")
|
let config_str = fs::read_to_string("assets/data/worldgen/default.json")
|
||||||
.expect("Failed to read worldgen config");
|
.expect("Failed to read worldgen config");
|
||||||
|
|
||||||
#[allow(clippy::expect_used)]
|
#[expect(clippy::expect_used)]
|
||||||
let worldgen_config: WorldGenConfig =
|
let worldgen_config: WorldGenConfig =
|
||||||
serde_json::from_str(&config_str).expect("Failed to parse worldgen config");
|
serde_json::from_str(&config_str).expect("Failed to parse worldgen config");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,11 +41,7 @@ impl VoxelGenerator {
|
||||||
|
|
||||||
/// Generates a complete voxel chunk for the specified position.
|
/// Generates a complete voxel chunk for the specified position.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[allow(
|
#[expect(clippy::cast_possible_wrap, clippy::cast_possible_truncation)]
|
||||||
clippy::cast_precision_loss,
|
|
||||||
clippy::cast_possible_wrap,
|
|
||||||
clippy::cast_possible_truncation
|
|
||||||
)]
|
|
||||||
pub fn generate_chunk(&self, pos: ChunkPos) -> Chunk {
|
pub fn generate_chunk(&self, pos: ChunkPos) -> Chunk {
|
||||||
let mut chunk = Chunk::default();
|
let mut chunk = Chunk::default();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ impl ChunkPos {
|
||||||
|
|
||||||
/// Initializes a new chunk position from a world-space position measured in blocks.
|
/// Initializes a new chunk position from a world-space position measured in blocks.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[allow(clippy::cast_possible_truncation, clippy::cast_possible_wrap)]
|
#[expect(clippy::cast_possible_truncation, clippy::cast_possible_wrap)]
|
||||||
pub fn from_world(x: f64, y: f64, z: f64) -> Self {
|
pub fn from_world(x: f64, y: f64, z: f64) -> Self {
|
||||||
ChunkPos {
|
ChunkPos {
|
||||||
x: (x.floor() as i32).div_euclid(CHUNK_SIZE as i32),
|
x: (x.floor() as i32).div_euclid(CHUNK_SIZE as i32),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue