refactor(workspace): use #[expect] over #[allow] for lint suppressions

This commit is contained in:
Serkyo 2026-07-07 01:28:56 +02:00
parent 645ba6d301
commit 8045c3cae3
11 changed files with 20 additions and 27 deletions

View file

@ -61,7 +61,7 @@ impl Camera {
/// Advances the camera by a single frame, applying `input` accumulated over `dt` seconds.
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.
#[allow(clippy::cast_possible_truncation)]
#[expect(clippy::cast_possible_truncation)]
{
self.yaw += input.mouse_delta.0 as f32 * self.sensitivity;
self.pitch -= input.mouse_delta.1 as f32 * self.sensitivity;

View file

@ -25,7 +25,7 @@ use winit::window::{CursorGrabMode, Window, WindowId};
/// 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.
// 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)]
struct InputState {
/// Whether the "move forward" key (W) is held.
@ -143,10 +143,10 @@ impl ApplicationHandler for App {
self.window = Some(window);
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")
.expect("Failed to read worldgen config");
#[allow(clippy::expect_used)]
#[expect(clippy::expect_used)]
let worldgen_config: shared::generator::WorldGenConfig =
serde_json::from_str(&config_str).expect("Failed to parse worldgen config");
@ -162,7 +162,7 @@ impl ApplicationHandler for App {
indices.len()
);
#[allow(clippy::expect_used)]
#[expect(clippy::expect_used)]
self.renderer
.as_mut()
.expect("Renderer initialized")

View file

@ -3,7 +3,7 @@
use renderer::mesh::Vertex;
use shared::world::{BlockId, CHUNK_SIZE, Chunk};
#[allow(
#[expect(
clippy::cast_precision_loss,
clippy::cast_possible_truncation,
clippy::too_many_lines

View file

@ -67,7 +67,7 @@ pub fn find_graphics_queue_family(
let props = unsafe { instance.get_physical_device_queue_family_properties(physical_device) };
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 graphics = prop.queue_flags.contains(vk::QueueFlags::GRAPHICS);
let present = unsafe {

View file

@ -40,7 +40,6 @@ impl Renderer {
///
/// 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.
#[allow(clippy::expect_used)]
pub fn new(
display_handle: RawDisplayHandle,
window_handle: RawWindowHandle,
@ -97,7 +96,7 @@ impl Renderer {
let command_pool = unsafe { device.create_command_pool(&pool_create_info, None)? };
// 9. Command Buffers
#[allow(clippy::expect_used)]
#[expect(clippy::expect_used)]
let alloc_info = vk::CommandBufferAllocateInfo::default()
.command_pool(command_pool)
.level(vk::CommandBufferLevel::PRIMARY)

View file

@ -24,7 +24,7 @@ impl Vertex {
///
/// # Panics
/// 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 {
ash::vk::VertexInputBindingDescription::default()
.binding(0)
@ -37,7 +37,6 @@ impl 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.
#[allow(clippy::expect_used)]
pub fn get_attribute_descriptions() -> [ash::vk::VertexInputAttributeDescription; 2] {
[
// Location 0: position (vec3 -> R32G32B32_SFLOAT)

View file

@ -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.
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.
#[allow(clippy::expect_used)]
#[expect(clippy::expect_used)]
let push_constant_range = vk::PushConstantRange::default()
.stage_flags(vk::ShaderStageFlags::VERTEX)
.offset(0)

View file

@ -17,14 +17,14 @@ pub struct Renderer {
/// The debug messenger for validation layer output.
pub(crate) debug_messenger: vk::DebugUtilsMessengerEXT,
/// Handle to the selected physical device (GPU).
#[allow(dead_code)]
#[expect(dead_code)]
pub(crate) physical_device: vk::PhysicalDevice,
/// The logical Vulkan device.
pub(crate) device: Device,
/// The queue used for graphics operations.
pub(crate) graphics_queue: vk::Queue,
/// Index of the graphics queue family.
#[allow(dead_code)]
#[expect(dead_code)]
pub(crate) graphics_queue_index: u32,
/// Surface extension loader.
pub(crate) surface_loader: khr::surface::Instance,
@ -37,7 +37,7 @@ pub struct Renderer {
/// Images acquired from the swapchain.
pub(crate) swapchain_images: Vec<vk::Image>,
/// The pixel format of the swapchain images.
#[allow(dead_code)]
#[expect(dead_code)]
pub(crate) swapchain_format: vk::Format,
/// The dimensions of the swapchain images.
pub(crate) swapchain_extent: vk::Extent2D,
@ -262,7 +262,7 @@ impl Renderer {
self.graphics_pipeline,
);
#[allow(clippy::cast_precision_loss)]
#[expect(clippy::cast_precision_loss)]
let viewport = vk::Viewport {
x: 0.0,
y: 0.0,
@ -284,10 +284,9 @@ impl Renderer {
self.device
.cmd_bind_index_buffer(cmd, self.index_buffer, 0, vk::IndexType::UINT32);
#[allow(clippy::cast_precision_loss)]
let aspect =
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 =
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.
@ -349,7 +348,7 @@ impl Renderer {
///
/// # Errors
/// 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(
&mut self,
vertices: &[Vertex],

View file

@ -26,11 +26,11 @@ fn main() {
info!("Starting Synvael server");
#[allow(clippy::expect_used)]
#[expect(clippy::expect_used)]
let config_str = fs::read_to_string("assets/data/worldgen/default.json")
.expect("Failed to read worldgen config");
#[allow(clippy::expect_used)]
#[expect(clippy::expect_used)]
let worldgen_config: WorldGenConfig =
serde_json::from_str(&config_str).expect("Failed to parse worldgen config");

View file

@ -41,11 +41,7 @@ impl VoxelGenerator {
/// Generates a complete voxel chunk for the specified position.
#[must_use]
#[allow(
clippy::cast_precision_loss,
clippy::cast_possible_wrap,
clippy::cast_possible_truncation
)]
#[expect(clippy::cast_possible_wrap, clippy::cast_possible_truncation)]
pub fn generate_chunk(&self, pos: ChunkPos) -> Chunk {
let mut chunk = Chunk::default();

View file

@ -89,7 +89,7 @@ impl ChunkPos {
/// Initializes a new chunk position from a world-space position measured in blocks.
#[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 {
ChunkPos {
x: (x.floor() as i32).div_euclid(CHUNK_SIZE as i32),