From 7358d8c9cb29cde0ae958c685f8b1d21a11af1f6 Mon Sep 17 00:00:00 2001 From: i509VCB Date: Thu, 2 Dec 2021 18:06:41 -0600 Subject: [PATCH] resolve new clippy lints --- anvil/src/winit.rs | 2 +- src/backend/drm/device/mod.rs | 1 + src/backend/drm/surface/mod.rs | 1 + src/backend/egl/native.rs | 2 +- src/wayland/compositor/mod.rs | 8 +--- src/wayland/compositor/transaction.rs | 20 +--------- src/wayland/explicit_synchronization/mod.rs | 11 +----- src/wayland/output/mod.rs | 4 +- src/wayland/seat/keyboard.rs | 14 +------ src/wayland/shell/xdg/mod.rs | 44 ++------------------- 10 files changed, 15 insertions(+), 92 deletions(-) diff --git a/anvil/src/winit.rs b/anvil/src/winit.rs index a137cf4..3eb9efe 100644 --- a/anvil/src/winit.rs +++ b/anvil/src/winit.rs @@ -87,7 +87,7 @@ pub fn run_winit(log: Logger) { let data = WinitData { #[cfg(feature = "debug")] fps_texture: import_bitmap( - &mut renderer.borrow_mut().renderer(), + renderer.borrow_mut().renderer(), &image::io::Reader::with_format(std::io::Cursor::new(FPS_NUMBERS_PNG), image::ImageFormat::Png) .decode() .unwrap() diff --git a/src/backend/drm/device/mod.rs b/src/backend/drm/device/mod.rs index 135cf7b..23e9582 100644 --- a/src/backend/drm/device/mod.rs +++ b/src/backend/drm/device/mod.rs @@ -70,6 +70,7 @@ impl Drop for FdWrapper { } #[derive(Debug)] +#[allow(clippy::large_enum_variant)] pub enum DrmDeviceInternal { Atomic(AtomicDrmDevice), Legacy(LegacyDrmDevice), diff --git a/src/backend/drm/surface/mod.rs b/src/backend/drm/surface/mod.rs index 459fae7..d4e8276 100644 --- a/src/backend/drm/surface/mod.rs +++ b/src/backend/drm/surface/mod.rs @@ -36,6 +36,7 @@ pub struct DrmSurface { } #[derive(Debug)] +#[allow(clippy::large_enum_variant)] pub enum DrmSurfaceInternal { Atomic(AtomicDrmSurface), Legacy(LegacyDrmSurface), diff --git a/src/backend/egl/native.rs b/src/backend/egl/native.rs index 6feef7c..097c206 100644 --- a/src/backend/egl/native.rs +++ b/src/backend/egl/native.rs @@ -199,7 +199,7 @@ impl EGLNativeDisplay for EGLDevice { /// Trait for types returning valid surface pointers for initializing egl /// -/// ## Unsafety +/// ## Safety /// /// The returned [`NativeWindowType`](ffi::NativeWindowType) must be valid for EGL /// and there is no way to test that. diff --git a/src/wayland/compositor/mod.rs b/src/wayland/compositor/mod.rs index 95aa57a..9d35d7c 100644 --- a/src/wayland/compositor/mod.rs +++ b/src/wayland/compositor/mod.rs @@ -244,18 +244,12 @@ pub enum RectangleKind { /// This struct contains an ordered `Vec` containing the rectangles defining /// a region. They should be added or subtracted in this order to compute the /// actual contents of the region. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Default)] pub struct RegionAttributes { /// List of rectangle part of this region pub rects: Vec<(RectangleKind, Rectangle)>, } -impl Default for RegionAttributes { - fn default() -> RegionAttributes { - RegionAttributes { rects: Vec::new() } - } -} - impl RegionAttributes { /// Checks whether given point is inside the region. pub fn contains>>(&self, point: P) -> bool { diff --git a/src/wayland/compositor/transaction.rs b/src/wayland/compositor/transaction.rs index f022a29..2011663 100644 --- a/src/wayland/compositor/transaction.rs +++ b/src/wayland/compositor/transaction.rs @@ -61,20 +61,12 @@ pub enum BlockerState { Cancelled, } +#[derive(Default)] struct TransactionState { surfaces: Vec<(WlSurface, Serial)>, blockers: Vec>, } -impl Default for TransactionState { - fn default() -> Self { - TransactionState { - surfaces: Vec::new(), - blockers: Vec::new(), - } - } -} - impl TransactionState { fn insert(&mut self, surface: WlSurface, id: Serial) { if let Some(place) = self.surfaces.iter_mut().find(|place| place.0 == surface) { @@ -213,21 +205,13 @@ impl Transaction { } // This queue should be per-client +#[derive(Default)] pub(crate) struct TransactionQueue { transactions: Vec, // we keep the hashset around to reuse allocations seen_surfaces: HashSet, } -impl Default for TransactionQueue { - fn default() -> Self { - TransactionQueue { - transactions: Vec::new(), - seen_surfaces: HashSet::new(), - } - } -} - impl TransactionQueue { pub(crate) fn append(&mut self, t: Transaction) { self.transactions.push(t); diff --git a/src/wayland/explicit_synchronization/mod.rs b/src/wayland/explicit_synchronization/mod.rs index c194bea..9fe3d99 100644 --- a/src/wayland/explicit_synchronization/mod.rs +++ b/src/wayland/explicit_synchronization/mod.rs @@ -87,7 +87,7 @@ impl ExplicitBufferRelease { /// /// When processing the current state, [`Option::take`] the values from it. Otherwise they'll be /// treated as unused and released when overwritten by the next client commit. -#[derive(Debug)] +#[derive(Debug, Default)] pub struct ExplicitSyncState { /// An acquire `dma_fence` object, that you should wait on before accessing the contents of the /// buffer associated with the surface. @@ -97,15 +97,6 @@ pub struct ExplicitSyncState { pub release: Option, } -impl Default for ExplicitSyncState { - fn default() -> Self { - ExplicitSyncState { - acquire: None, - release: None, - } - } -} - impl Cacheable for ExplicitSyncState { fn commit(&mut self) -> Self { std::mem::take(self) diff --git a/src/wayland/output/mod.rs b/src/wayland/output/mod.rs index fff44b1..1909ab7 100644 --- a/src/wayland/output/mod.rs +++ b/src/wayland/output/mod.rs @@ -346,7 +346,7 @@ impl Output { /// This function allows to run a [FnMut] on every /// [WlOutput] matching the same [Client] as provided - pub fn with_client_outputs(&self, client: Client, mut f: F) + pub fn with_client_outputs(&self, client: Client, f: F) where F: FnMut(&WlOutput), { @@ -359,7 +359,7 @@ impl Output { Some(output_client) => output_client.equals(&client), None => false, }) - .for_each(|output| f(output)) + .for_each(f) } /// Sends `wl_surface.enter` for the provided surface diff --git a/src/wayland/seat/keyboard.rs b/src/wayland/seat/keyboard.rs index e5a1d57..7a8346d 100644 --- a/src/wayland/seat/keyboard.rs +++ b/src/wayland/seat/keyboard.rs @@ -66,7 +66,7 @@ impl ModifiersState { /// For details, see the [documentation at xkbcommon.org][docs]. /// /// [docs]: https://xkbcommon.org/doc/current/structxkb__rule__names.html -#[derive(Clone, Debug)] +#[derive(Default, Clone, Debug)] pub struct XkbConfig<'a> { /// The rules file to use. /// @@ -86,18 +86,6 @@ pub struct XkbConfig<'a> { pub options: Option, } -impl<'a> Default for XkbConfig<'a> { - fn default() -> Self { - Self { - rules: "", - model: "", - layout: "", - variant: "", - options: None, - } - } -} - struct KbdInternal { known_kbds: Vec, focus: Option, diff --git a/src/wayland/shell/xdg/mod.rs b/src/wayland/shell/xdg/mod.rs index 3fcea15..cc6f4a3 100644 --- a/src/wayland/shell/xdg/mod.rs +++ b/src/wayland/shell/xdg/mod.rs @@ -388,7 +388,7 @@ xdg_role!( ); /// Represents the state of the popup -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug, Default, Clone, Copy, PartialEq)] pub struct PopupState { /// The positioner state can be used by the compositor /// to calculate the best placement for the popup. @@ -408,15 +408,6 @@ pub struct PopupState { pub geometry: Rectangle, } -impl Default for PopupState { - fn default() -> Self { - Self { - geometry: Default::default(), - positioner: Default::default(), - } - } -} - #[derive(Clone, Copy, Debug, PartialEq)] /// The state of a positioner, as set by the client pub struct PositionerState { @@ -598,7 +589,7 @@ impl PositionerState { } /// State of a regular toplevel surface -#[derive(Debug, PartialEq)] +#[derive(Debug, Default, PartialEq)] pub struct ToplevelState { /// The suggested size of the surface pub size: Option>, @@ -613,17 +604,6 @@ pub struct ToplevelState { pub decoration_mode: Option, } -impl Default for ToplevelState { - fn default() -> Self { - ToplevelState { - fullscreen_output: None, - states: Default::default(), - size: None, - decoration_mode: None, - } - } -} - impl Clone for ToplevelState { fn clone(&self) -> ToplevelState { ToplevelState { @@ -641,7 +621,7 @@ impl Clone for ToplevelState { /// having the same `xdg_toplevel::State` multiple times /// and simplifies setting and un-setting a particularly /// `xdg_toplevel::State` -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Default, Clone, PartialEq)] pub struct ToplevelStateSet { states: Vec, } @@ -711,12 +691,6 @@ impl ToplevelStateSet { } } -impl Default for ToplevelStateSet { - fn default() -> Self { - Self { states: Vec::new() } - } -} - impl IntoIterator for ToplevelStateSet { type Item = xdg_toplevel::State; type IntoIter = std::vec::IntoIter; @@ -733,7 +707,7 @@ impl From for Vec { } /// Represents the client pending state -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Default, Clone, Copy)] pub struct SurfaceCachedState { /// Holds the double-buffered geometry that may be specified /// by xdg_surface.set_window_geometry. @@ -754,16 +728,6 @@ pub struct SurfaceCachedState { pub max_size: Size, } -impl Default for SurfaceCachedState { - fn default() -> Self { - Self { - geometry: None, - min_size: Default::default(), - max_size: Default::default(), - } - } -} - impl Cacheable for SurfaceCachedState { fn commit(&mut self) -> Self { *self