From 607f6149f621b99e33028e35ad86946dfa970a62 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Mon, 8 Sep 2025 20:09:32 -0700 Subject: [PATCH] Fix warnings and clippy lints on latest nightly --- examples/image_viewporter.rs | 2 +- src/compositor.rs | 2 +- src/data_device_manager/write_pipe.rs | 2 +- src/seat/input_method.rs | 19 ++++++++++--------- src/seat/input_method_v3.rs | 19 ++++++++++--------- src/seat/mod.rs | 19 ++++++++++++------- src/seat/pointer/mod.rs | 9 ++------- src/shell/wlr_layer/mod.rs | 9 ++------- src/shell/xdg/mod.rs | 2 +- src/shm/raw.rs | 4 ++-- 10 files changed, 42 insertions(+), 45 deletions(-) diff --git a/examples/image_viewporter.rs b/examples/image_viewporter.rs index 21e6a35b7..c9f380b79 100644 --- a/examples/image_viewporter.rs +++ b/examples/image_viewporter.rs @@ -79,7 +79,7 @@ fn main() { window.set_app_id("io.github.smithay.client-toolkit.ImageViewer"); window.set_min_size(Some((256, 256))); let path: &Path = path.as_os_str().as_ref(); - window.set_title(path.components().last().unwrap().as_os_str().to_string_lossy()); + window.set_title(path.components().next_back().unwrap().as_os_str().to_string_lossy()); // In order for the window to be mapped, we need to perform an initial commit with no attached buffer. // For more info, see WaylandSurface::commit diff --git a/src/compositor.rs b/src/compositor.rs index 73222ebd5..ba0f4ad34 100644 --- a/src/compositor.rs +++ b/src/compositor.rs @@ -475,7 +475,7 @@ impl wayland_client::backend::ObjectData for RegionData { self: Arc, _: &wayland_client::backend::Backend, _: wayland_client::backend::protocol::Message, - ) -> Option> { + ) -> Option> { unreachable!("wl_region has no events"); } fn destroyed(&self, _: wayland_client::backend::ObjectId) {} diff --git a/src/data_device_manager/write_pipe.rs b/src/data_device_manager/write_pipe.rs index 24a9c7fe2..94305951c 100644 --- a/src/data_device_manager/write_pipe.rs +++ b/src/data_device_manager/write_pipe.rs @@ -85,7 +85,7 @@ impl AsRawFd for WritePipe { #[cfg(feature = "calloop")] impl AsFd for WritePipe { - fn as_fd(&self) -> BorrowedFd { + fn as_fd(&self) -> BorrowedFd<'_> { self.file.get_ref().as_fd() } } diff --git a/src/seat/input_method.rs b/src/seat/input_method.rs index c94028687..6ab3b18e4 100644 --- a/src/seat/input_method.rs +++ b/src/seat/input_method.rs @@ -185,17 +185,18 @@ pub struct SurroundingText { } /// State machine for determining the capabilities of a text input -#[derive(Clone, Debug, Copy, PartialEq)] +#[derive(Clone, Debug, Default, Copy, PartialEq)] pub enum Active { + #[default] Inactive, - NegotiatingCapabilities { surrounding_text: bool, content_type: bool }, - Active { surrounding_text: bool, content_type: bool }, -} - -impl Default for Active { - fn default() -> Self { - Self::Inactive - } + NegotiatingCapabilities { + surrounding_text: bool, + content_type: bool, + }, + Active { + surrounding_text: bool, + content_type: bool, + }, } impl Active { diff --git a/src/seat/input_method_v3.rs b/src/seat/input_method_v3.rs index bc28bdd3f..bf9df6118 100644 --- a/src/seat/input_method_v3.rs +++ b/src/seat/input_method_v3.rs @@ -342,17 +342,18 @@ pub struct SurroundingText { } /// State machine for determining the capabilities of a text input -#[derive(Clone, Debug, Copy, PartialEq)] +#[derive(Clone, Debug, Default, Copy, PartialEq)] pub enum Active { + #[default] Inactive, - NegotiatingCapabilities { surrounding_text: bool, content_type: bool }, - Active { surrounding_text: bool, content_type: bool }, -} - -impl Default for Active { - fn default() -> Self { - Self::Inactive - } + NegotiatingCapabilities { + surrounding_text: bool, + content_type: bool, + }, + Active { + surrounding_text: bool, + content_type: bool, + }, } impl Active { diff --git a/src/seat/mod.rs b/src/seat/mod.rs index 96f995787..4c94b9061 100644 --- a/src/seat/mod.rs +++ b/src/seat/mod.rs @@ -1,5 +1,6 @@ use std::{ fmt::{self, Display, Formatter}, + slice, sync::{ atomic::{AtomicBool, Ordering}, Arc, Mutex, @@ -250,14 +251,18 @@ impl SeatState { if let CursorShapeManagerState::Pending { registry, global } = &self.cursor_shape_manager_state { - self.cursor_shape_manager_state = - match crate::registry::bind_one(registry, &[global.clone()], qh, 1..=2, GlobalData) - { - Ok(bound) => { - CursorShapeManagerState::Bound(CursorShapeManager::from_existing(bound)) - } - Err(_) => CursorShapeManagerState::NotPresent, + self.cursor_shape_manager_state = match crate::registry::bind_one( + registry, + slice::from_ref(global), + qh, + 1..=2, + GlobalData, + ) { + Ok(bound) => { + CursorShapeManagerState::Bound(CursorShapeManager::from_existing(bound)) } + Err(_) => CursorShapeManagerState::NotPresent, + } } let shape_device = diff --git a/src/seat/pointer/mod.rs b/src/seat/pointer/mod.rs index 8cd627bbc..1529cf609 100644 --- a/src/seat/pointer/mod.rs +++ b/src/seat/pointer/mod.rs @@ -621,7 +621,7 @@ impl Drop for ThemedPointer { } /// Specifies which cursor theme should be used by the theme manager. -#[derive(Debug)] +#[derive(Debug, Default)] pub enum ThemeSpec<'a> { /// Use this specific theme with the given base size. Named { @@ -640,15 +640,10 @@ pub enum ThemeSpec<'a> { /// In this case SCTK will read the `XCURSOR_THEME` and /// `XCURSOR_SIZE` environment variables to figure out the /// theme to use. + #[default] System, } -impl Default for ThemeSpec<'_> { - fn default() -> Self { - Self::System - } -} - /// An error indicating that the cursor was not found. #[derive(Debug, thiserror::Error)] pub enum PointerThemeError { diff --git a/src/shell/wlr_layer/mod.rs b/src/shell/wlr_layer/mod.rs index c287962f3..fe35922b0 100644 --- a/src/shell/wlr_layer/mod.rs +++ b/src/shell/wlr_layer/mod.rs @@ -179,11 +179,12 @@ pub enum SurfaceKind { } #[non_exhaustive] -#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum KeyboardInteractivity { /// No keyboard focus is possible. /// /// This is the default value for all newly created layer shells. + #[default] None, /// Request exclusive keyboard focus if the layer is above shell surfaces. @@ -204,12 +205,6 @@ pub enum KeyboardInteractivity { OnDemand, } -impl Default for KeyboardInteractivity { - fn default() -> Self { - Self::None - } -} - /// The z-depth of a layer. /// /// These values indicate which order in which layer surfaces are rendered. diff --git a/src/shell/xdg/mod.rs b/src/shell/xdg/mod.rs index 5e5a07703..0d7791d4d 100644 --- a/src/shell/xdg/mod.rs +++ b/src/shell/xdg/mod.rs @@ -211,7 +211,7 @@ impl wayland_client::backend::ObjectData for PositionerData { self: Arc, _: &wayland_client::backend::Backend, _: wayland_client::backend::protocol::Message, - ) -> Option> { + ) -> Option> { unreachable!("xdg_positioner has no events"); } fn destroyed(&self, _: wayland_client::backend::ObjectId) {} diff --git a/src/shm/raw.rs b/src/shm/raw.rs index 48bab84a5..8c767a3c1 100644 --- a/src/shm/raw.rs +++ b/src/shm/raw.rs @@ -153,7 +153,7 @@ impl RawPool { } impl AsFd for RawPool { - fn as_fd(&self) -> BorrowedFd { + fn as_fd(&self) -> BorrowedFd<'_> { self.mem_file.as_fd() } } @@ -283,7 +283,7 @@ impl ObjectData for ShmPoolData { self: Arc, _: &wayland_client::backend::Backend, _: wayland_client::backend::protocol::Message, - ) -> Option> { + ) -> Option> { unreachable!("wl_shm_pool has no events") }