From 67017a9f54c2644ca4c9e85d7f1d509851a132db Mon Sep 17 00:00:00 2001 From: galister <22305755+galister@users.noreply.github.com> Date: Fri, 31 Oct 2025 17:33:38 +0900 Subject: [PATCH] clippy --- wgui/src/parser/component_button.rs | 2 +- wgui/src/parser/mod.rs | 2 +- wlx-overlay-s/src/backend/input.rs | 9 ++++----- wlx-overlay-s/src/backend/openvr/input.rs | 2 +- wlx-overlay-s/src/backend/openvr/lines.rs | 6 ++---- wlx-overlay-s/src/backend/openvr/manifest.rs | 6 ++---- wlx-overlay-s/src/backend/openvr/overlay.rs | 3 +-- wlx-overlay-s/src/backend/openxr/overlay.rs | 3 +-- wlx-overlay-s/src/backend/wayvr/display.rs | 4 +--- wlx-overlay-s/src/backend/wayvr/egl_data.rs | 2 +- wlx-overlay-s/src/backend/wayvr/server_ipc.rs | 2 +- wlx-overlay-s/src/graphics/dds.rs | 2 +- wlx-overlay-s/src/graphics/dmabuf.rs | 2 +- wlx-overlay-s/src/graphics/mod.rs | 2 +- wlx-overlay-s/src/gui/asset.rs | 2 +- wlx-overlay-s/src/gui/panel/mod.rs | 2 +- wlx-overlay-s/src/overlays/keyboard/builder.rs | 2 +- wlx-overlay-s/src/overlays/wayvr.rs | 4 ++-- wlx-overlay-s/src/subsystem/audio.rs | 2 +- wlx-overlay-s/src/windowing/manager.rs | 6 +++--- wlx-overlay-s/src/windowing/window.rs | 4 ++-- 21 files changed, 30 insertions(+), 39 deletions(-) diff --git a/wgui/src/parser/component_button.rs b/wgui/src/parser/component_button.rs index 4593b94..aba6088 100644 --- a/wgui/src/parser/component_button.rs +++ b/wgui/src/parser/component_button.rs @@ -1,5 +1,5 @@ use crate::{ - components::{self, Component, button, tooltip}, + components::{Component, button, tooltip}, drawing::Color, i18n::Translation, layout::WidgetID, diff --git a/wgui/src/parser/mod.rs b/wgui/src/parser/mod.rs index 8242915..14c3e53 100644 --- a/wgui/src/parser/mod.rs +++ b/wgui/src/parser/mod.rs @@ -783,7 +783,7 @@ fn parse_widget_universal(ctx: &mut ParserContext, widget_id: WidgetID, attribs: ctx.insert_id(&pair.value, widget_id); } "interactable" => { - if let Ok(0) = &pair.value.parse::() { + if matches!(&pair.value.parse::(), Ok(0)) { log::info!("setting {widget_id:?} to noninteractable."); ctx.layout.state.widgets.get(widget_id).unwrap().state().interactable = false; } else { diff --git a/wlx-overlay-s/src/backend/input.rs b/wlx-overlay-s/src/backend/input.rs index dff21fb..70c558f 100644 --- a/wlx-overlay-s/src/backend/input.rs +++ b/wlx-overlay-s/src/backend/input.rs @@ -479,7 +479,7 @@ fn handle_scroll(hit: &PointerHit, hovered: &mut OverlayWindowData, app: & hovered .config .backend - .on_scroll(app, &hit, scroll_y, scroll_x); + .on_scroll(app, hit, scroll_y, scroll_x); } } } @@ -511,11 +511,10 @@ where id, &overlay_state.transform, overlay_state.curvature.as_ref(), - ) { - if hit.dist.is_finite() { + ) + && hit.dist.is_finite() { hits.push(hit); } - } } hits.sort_by(|a, b| a.dist.total_cmp(&b.dist)); @@ -657,7 +656,7 @@ fn ray_test( let (dist, local_pos) = curvature.map_or_else( || { Some(raycast_plane( - &ray_origin, + ray_origin, Vec3A::NEG_Z, overlay_pose, Vec3A::NEG_Z, diff --git a/wlx-overlay-s/src/backend/openvr/input.rs b/wlx-overlay-s/src/backend/openvr/input.rs index ce61e3c..0ce81d4 100644 --- a/wlx-overlay-s/src/backend/openvr/input.rs +++ b/wlx-overlay-s/src/backend/openvr/input.rs @@ -354,7 +354,7 @@ pub fn set_action_manifest(input: &mut InputManager) -> anyhow::Result<()> { } if let Err(e) = input.set_action_manifest(action_path.as_path()) { - bail!("Failed to set action manifest: {}", e); + bail!("Failed to set action manifest: {e}"); } Ok(()) } diff --git a/wlx-overlay-s/src/backend/openvr/lines.rs b/wlx-overlay-s/src/backend/openvr/lines.rs index 2b0a867..73f0d55 100644 --- a/wlx-overlay-s/src/backend/openvr/lines.rs +++ b/wlx-overlay-s/src/backend/openvr/lines.rs @@ -26,7 +26,7 @@ use crate::backend::input::{HoverResult, PointerHit}; use crate::graphics::CommandBuffers; use crate::state::AppState; use crate::windowing::backend::{FrameMeta, OverlayBackend, ShouldRender}; -use crate::windowing::window::{OverlayWindowConfig, OverlayWindowData, OverlayWindowState}; +use crate::windowing::window::{OverlayWindowConfig, OverlayWindowData}; use crate::windowing::Z_ORDER_LINES; use super::overlay::OpenVrOverlayData; @@ -85,9 +85,7 @@ impl LinePool { }, ..OverlayWindowData::from_config(OverlayWindowConfig { name: Arc::from(format!("wlx-line{id}")), - default_state: OverlayWindowState { - ..Default::default() - }, + default_state: Default::default(), z_order: Z_ORDER_LINES, ..OverlayWindowConfig::from_backend(Box::new(LineBackend { view: self.view.clone(), diff --git a/wlx-overlay-s/src/backend/openvr/manifest.rs b/wlx-overlay-s/src/backend/openvr/manifest.rs index 1769dda..a1e5d27 100644 --- a/wlx-overlay-s/src/backend/openvr/manifest.rs +++ b/wlx-overlay-s/src/backend/openvr/manifest.rs @@ -53,14 +53,12 @@ pub(super) fn install_manifest(app_mgr: &mut ApplicationsManager) -> anyhow::Res }; let Ok(mut file) = File::create(&manifest_path) else { - bail!("Failed to create manifest file at {:?}", manifest_path); + bail!("Failed to create manifest file at {manifest_path:?}"); }; if let Err(e) = manifest.write(&mut file) { bail!( - "Failed to write manifest file at {:?}: {:?}", - manifest_path, - e + "Failed to write manifest file at {manifest_path:?}: {e:?}" ); } diff --git a/wlx-overlay-s/src/backend/openvr/overlay.rs b/wlx-overlay-s/src/backend/openvr/overlay.rs index d58395b..2f8e8a7 100644 --- a/wlx-overlay-s/src/backend/openvr/overlay.rs +++ b/wlx-overlay-s/src/backend/openvr/overlay.rs @@ -88,8 +88,7 @@ impl OverlayWindowData { .config .active_state .as_ref() - .map(|x| x.alpha > 0.05) - .unwrap_or(false); + .is_some_and(|x| x.alpha > 0.05); if want_visible && !self.data.visible { self.show_internal(overlay, app)?; diff --git a/wlx-overlay-s/src/backend/openxr/overlay.rs b/wlx-overlay-s/src/backend/openxr/overlay.rs index e8c1b99..a99ea7d 100644 --- a/wlx-overlay-s/src/backend/openxr/overlay.rs +++ b/wlx-overlay-s/src/backend/openxr/overlay.rs @@ -125,8 +125,7 @@ impl OverlayWindowData { .config .active_state .as_ref() - .map(|x| x.alpha > 0.05) - .unwrap_or(false); + .is_some_and(|x| x.alpha > 0.05); if self.data.last_visible != want_visible { if want_visible { diff --git a/wlx-overlay-s/src/backend/wayvr/display.rs b/wlx-overlay-s/src/backend/wayvr/display.rs index 1748972..484e6ad 100644 --- a/wlx-overlay-s/src/backend/wayvr/display.rs +++ b/wlx-overlay-s/src/backend/wayvr/display.rs @@ -576,9 +576,7 @@ impl Display { Ok(child) => Ok(SpawnProcessResult { auth_key, child }), Err(e) => { anyhow::bail!( - "Failed to launch process with path \"{}\": {}. Make sure your exec path exists.", - exec_path, - e + "Failed to launch process with path \"{exec_path}\": {e}. Make sure your exec path exists." ); } } diff --git a/wlx-overlay-s/src/backend/wayvr/egl_data.rs b/wlx-overlay-s/src/backend/wayvr/egl_data.rs index 0b00a33..c04ece2 100644 --- a/wlx-overlay-s/src/backend/wayvr/egl_data.rs +++ b/wlx-overlay-s/src/backend/wayvr/egl_data.rs @@ -56,7 +56,7 @@ fn load_egl_func( ) -> anyhow::Result { let raw_fn = egl .get_proc_address(func_name) - .ok_or_else(|| anyhow::anyhow!("Required EGL function {} not found", func_name))?; + .ok_or_else(|| anyhow::anyhow!("Required EGL function {func_name} not found"))?; Ok(raw_fn) } diff --git a/wlx-overlay-s/src/backend/wayvr/server_ipc.rs b/wlx-overlay-s/src/backend/wayvr/server_ipc.rs index e4b69df..5fdf463 100644 --- a/wlx-overlay-s/src/backend/wayvr/server_ipc.rs +++ b/wlx-overlay-s/src/backend/wayvr/server_ipc.rs @@ -619,7 +619,7 @@ impl WayVRServer { .nonblocking(local_socket::ListenerNonblockingMode::Both); let listener = match opts.create_sync() { Ok(listener) => listener, - Err(e) => anyhow::bail!("Failed to start WayVRServer IPC listener. Reason: {}", e), + Err(e) => anyhow::bail!("Failed to start WayVRServer IPC listener. Reason: {e}"), }; log::info!("WayVRServer IPC running at {printname}"); diff --git a/wlx-overlay-s/src/graphics/dds.rs b/wlx-overlay-s/src/graphics/dds.rs index 963104f..e6a7f4a 100644 --- a/wlx-overlay-s/src/graphics/dds.rs +++ b/wlx-overlay-s/src/graphics/dds.rs @@ -96,6 +96,6 @@ pub fn dds_to_vk(dds_fmt: ImageFormat) -> anyhow::Result { // BPTC ImageFormat::BC7RgbaUnorm => Ok(Format::BC7_UNORM_BLOCK), ImageFormat::BC7RgbaUnormSrgb => Ok(Format::BC7_SRGB_BLOCK), - _ => anyhow::bail!("Unsupported format {:?}", dds_fmt), + _ => anyhow::bail!("Unsupported format {dds_fmt:?}"), } } diff --git a/wlx-overlay-s/src/graphics/dmabuf.rs b/wlx-overlay-s/src/graphics/dmabuf.rs index 1c79323..4b87f6b 100644 --- a/wlx-overlay-s/src/graphics/dmabuf.rs +++ b/wlx-overlay-s/src/graphics/dmabuf.rs @@ -347,6 +347,6 @@ pub fn fourcc_to_vk(fourcc: FourCC) -> anyhow::Result { DRM_FORMAT_ABGR8888 | DRM_FORMAT_XBGR8888 => Ok(Format::R8G8B8A8_UNORM), DRM_FORMAT_ARGB8888 | DRM_FORMAT_XRGB8888 => Ok(Format::B8G8R8A8_UNORM), DRM_FORMAT_ABGR2101010 | DRM_FORMAT_XBGR2101010 => Ok(Format::A2B10G10R10_UNORM_PACK32), - _ => anyhow::bail!("Unsupported format {}", fourcc), + _ => anyhow::bail!("Unsupported format {fourcc}"), } } diff --git a/wlx-overlay-s/src/graphics/mod.rs b/wlx-overlay-s/src/graphics/mod.rs index b8e436c..33ea94c 100644 --- a/wlx-overlay-s/src/graphics/mod.rs +++ b/wlx-overlay-s/src/graphics/mod.rs @@ -310,7 +310,7 @@ pub fn init_openxr_graphics( .descriptor_binding_sampled_image_update_after_bind(true); dynamic_rendering.p_next = device_create_info.p_next.cast_mut(); - indexing_features.p_next = &raw mut dynamic_rendering as *mut c_void; + indexing_features.p_next = (&raw mut dynamic_rendering).cast::(); device_create_info.p_next = &raw mut indexing_features as *const c_void; let (device, queues) = unsafe { diff --git a/wlx-overlay-s/src/gui/asset.rs b/wlx-overlay-s/src/gui/asset.rs index 2ae023e..57a7fea 100644 --- a/wlx-overlay-s/src/gui/asset.rs +++ b/wlx-overlay-s/src/gui/asset.rs @@ -6,7 +6,7 @@ impl wgui::assets::AssetProvider for GuiAsset { fn load_from_path(&mut self, path: &str) -> anyhow::Result> { match Self::get(path) { Some(data) => Ok(data.data.to_vec()), - None => anyhow::bail!("embedded file {} not found", path), + None => anyhow::bail!("embedded file {path} not found"), } } } diff --git a/wlx-overlay-s/src/gui/panel/mod.rs b/wlx-overlay-s/src/gui/panel/mod.rs index c507096..954a2f3 100644 --- a/wlx-overlay-s/src/gui/panel/mod.rs +++ b/wlx-overlay-s/src/gui/panel/mod.rs @@ -275,7 +275,7 @@ impl OverlayBackend for GuiPanel { pos: hit.uv * self.layout.content_size, device: hit.pointer, }); - let result = self.push_event(app, &e); + let result = self.push_event(app, e); HoverResult { consume: result != EventResult::NoHit, diff --git a/wlx-overlay-s/src/overlays/keyboard/builder.rs b/wlx-overlay-s/src/overlays/keyboard/builder.rs index 990d455..56a5310 100644 --- a/wlx-overlay-s/src/overlays/keyboard/builder.rs +++ b/wlx-overlay-s/src/overlays/keyboard/builder.rs @@ -168,7 +168,7 @@ pub fn create_keyboard( params, )?; - if let Some(widget_id) = gui_state_key.get_widget_id(&*my_id).ok() { + if let Ok(widget_id) = gui_state_key.get_widget_id(&my_id) { let key_state = { let rect = panel .layout diff --git a/wlx-overlay-s/src/overlays/wayvr.rs b/wlx-overlay-s/src/overlays/wayvr.rs index 09369f6..a308676 100644 --- a/wlx-overlay-s/src/overlays/wayvr.rs +++ b/wlx-overlay-s/src/overlays/wayvr.rs @@ -187,7 +187,7 @@ fn get_or_create_display_by_name( .session .wayvr_config .get_display(disp_name) - .ok_or_else(|| anyhow::anyhow!("Cannot find display named \"{}\"", disp_name))? + .ok_or_else(|| anyhow::anyhow!("Cannot find display named \"{disp_name}\""))? .clone(); let disp_handle = wayvr.data.state.create_display( @@ -852,7 +852,7 @@ where .session .wayvr_config .get_catalog(catalog_name) - .ok_or_else(|| anyhow::anyhow!("Failed to get catalog \"{}\"", catalog_name))? + .ok_or_else(|| anyhow::anyhow!("Failed to get catalog \"{catalog_name}\""))? .clone(); if let Some(app_entry) = catalog.get_app(app_name) { diff --git a/wlx-overlay-s/src/subsystem/audio.rs b/wlx-overlay-s/src/subsystem/audio.rs index e5f77f7..5fe2f61 100644 --- a/wlx-overlay-s/src/subsystem/audio.rs +++ b/wlx-overlay-s/src/subsystem/audio.rs @@ -40,6 +40,6 @@ impl AudioOutput { return; } }; - let _ = handle.mixer().add(source); + let () = handle.mixer().add(source); } } diff --git a/wlx-overlay-s/src/windowing/manager.rs b/wlx-overlay-s/src/windowing/manager.rs index 3ca21ab..910ff24 100644 --- a/wlx-overlay-s/src/windowing/manager.rs +++ b/wlx-overlay-s/src/windowing/manager.rs @@ -77,7 +77,7 @@ where .and_then(|s| s.overlays.get(keyboard_id)) .unwrap() .clone(); - for set in me.sets.iter_mut() { + for set in &mut me.sets { set.overlays.insert(keyboard_id, kbd_state.clone()); } @@ -151,8 +151,8 @@ impl OverlayWindowManager { if overlay.config.show_on_spawn { overlay.config.activate(app); } - let id = self.overlays.insert(overlay); - id + + self.overlays.insert(overlay) } pub fn switch_or_toggle_set(&mut self, app: &mut AppState, set: usize) { diff --git a/wlx-overlay-s/src/windowing/window.rs b/wlx-overlay-s/src/windowing/window.rs index 093389c..ab3ca2c 100644 --- a/wlx-overlay-s/src/windowing/window.rs +++ b/wlx-overlay-s/src/windowing/window.rs @@ -34,10 +34,10 @@ pub enum Positioning { } impl Positioning { - pub fn moves_with_space(&self) -> bool { + pub const fn moves_with_space(&self) -> bool { matches!( self, - Positioning::Floating | Positioning::Anchored | Positioning::Static + Self::Floating | Self::Anchored | Self::Static ) } }