From d4868632d25904e7f5e3c09244f4c729a64a83dd Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Wed, 30 Aug 2023 15:53:23 -0700 Subject: [PATCH] Fix clippy lints on Rust 1.72 Should fix CI build. I'm not sure about the use of `Arc` in `MemoryRenderBuffer`. It seems `MemoryRenderBufferInner` isn't `Send` because `Box>` isn't. `Send` can be added there if a `Send` bound is added on `TextureId`. But then `GlesTexture` isn't `Send` so that presumably isn't desired in general. --- .github/workflows/ci.yml | 2 +- src/backend/drm/mod.rs | 4 ++-- src/backend/drm/surface/mod.rs | 2 ++ src/backend/egl/display.rs | 1 + src/backend/renderer/element/memory.rs | 2 ++ src/backend/vulkan/inner.rs | 7 ++++++- src/backend/vulkan/mod.rs | 5 +---- src/utils/clock.rs | 5 +---- 8 files changed, 16 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d500a20140e5..0e5770e83555 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -443,7 +443,7 @@ jobs: - name: Build Documentation env: RUSTDOCFLAGS: --cfg=docsrs - run: cargo doc --no-deps --features "test_all_features" -p smithay -p calloop:0.10.6 -p drm -p gbm -p input -p nix:0.26.2 -p udev -p slog -p wayland-server -p wayland-backend -p wayland-protocols:0.30.1 -p winit -p x11rb + run: cargo doc --no-deps --features "test_all_features" -p smithay -p calloop:0.10.6 -p drm -p gbm -p input -p nix:0.26.4 -p udev -p slog -p wayland-server -p wayland-backend -p wayland-protocols:0.30.1 -p winit -p x11rb - name: Setup index run: cp ./doc_index.html ./target/doc/index.html diff --git a/src/backend/drm/mod.rs b/src/backend/drm/mod.rs index b27648a2bce3..3755aefc3ac5 100644 --- a/src/backend/drm/mod.rs +++ b/src/backend/drm/mod.rs @@ -73,12 +73,12 @@ #[cfg(all(feature = "wayland_frontend", feature = "backend_gbm"))] pub mod compositor; pub(crate) mod device; -pub(self) mod error; +mod error; #[cfg(feature = "backend_gbm")] pub mod gbm; pub mod node; -pub(self) mod surface; +mod surface; use crate::utils::DevPath; pub use device::{ diff --git a/src/backend/drm/surface/mod.rs b/src/backend/drm/surface/mod.rs index d2ec8fab5cbf..00cd87453b30 100644 --- a/src/backend/drm/surface/mod.rs +++ b/src/backend/drm/surface/mod.rs @@ -463,7 +463,9 @@ impl DrmSurface { .cast::() .offset(fmt_mod_blob.modifiers_offset as isize) as *const _; + #[allow(clippy::unnecessary_cast)] let formats_ptr = formats_ptr as *const u32; + #[allow(clippy::unnecessary_cast)] let modifiers_ptr = modifiers_ptr as *const drm_ffi::drm_format_modifier; for i in 0..fmt_mod_blob.count_modifiers { diff --git a/src/backend/egl/display.rs b/src/backend/egl/display.rs index ed5590eb658d..1b4407e3d4dc 100644 --- a/src/backend/egl/display.rs +++ b/src/backend/egl/display.rs @@ -942,6 +942,7 @@ unsafe impl Send for EGLBufferReader {} #[cfg(feature = "use_system_lib")] impl EGLBufferReader { fn new(display: Arc, wayland: *mut wl_display) -> Self { + #[allow(clippy::arc_with_non_send_sync)] Self { display, wayland: Some(Arc::new(wayland)), diff --git a/src/backend/renderer/element/memory.rs b/src/backend/renderer/element/memory.rs index 8dde12671e4d..77e52168ddf4 100644 --- a/src/backend/renderer/element/memory.rs +++ b/src/backend/renderer/element/memory.rs @@ -392,6 +392,7 @@ impl MemoryRenderBuffer { opaque_regions: Option>>, ) -> Self { let inner = MemoryRenderBufferInner::new(format, size, scale, transform, opaque_regions); + #[allow(clippy::arc_with_non_send_sync)] MemoryRenderBuffer { id: Id::new(), inner: Arc::new(Mutex::new(inner)), @@ -408,6 +409,7 @@ impl MemoryRenderBuffer { opaque_regions: Option>>, ) -> Self { let inner = MemoryRenderBufferInner::from_memory(mem, format, size, scale, transform, opaque_regions); + #[allow(clippy::arc_with_non_send_sync)] MemoryRenderBuffer { id: Id::new(), inner: Arc::new(Mutex::new(inner)), diff --git a/src/backend/vulkan/inner.rs b/src/backend/vulkan/inner.rs index c40f11e7eb3b..d14ff436c39e 100644 --- a/src/backend/vulkan/inner.rs +++ b/src/backend/vulkan/inner.rs @@ -17,6 +17,11 @@ pub struct InstanceInner { pub enabled_extensions: Vec<&'static CStr>, } +// SAFETY: Destruction is externally synchronized (`InstanceInner` owns the +// `Instance`, and is held by a single thread when `Drop` is called). +unsafe impl Send for InstanceInner {} +unsafe impl Sync for InstanceInner {} + pub struct DebugState { pub debug_utils: DebugUtils, pub debug_messenger: vk::DebugUtilsMessengerEXT, @@ -39,7 +44,7 @@ impl Drop for InstanceInner { .debug_utils .destroy_debug_utils_messenger(debug.debug_messenger, None); } - Some(unsafe { Box::from_raw(debug.span_ptr as *mut tracing::Span) }) + Some(unsafe { Box::from_raw(debug.span_ptr) }) } else { None }; diff --git a/src/backend/vulkan/mod.rs b/src/backend/vulkan/mod.rs index 49f76e55a832..63db82214ca8 100644 --- a/src/backend/vulkan/mod.rs +++ b/src/backend/vulkan/mod.rs @@ -335,6 +335,7 @@ impl Instance { info!("Created new instance"); info!("Enabled instance extensions: {:?}", inner.enabled_extensions); + #[allow(clippy::arc_with_non_send_sync)] Ok(Instance(Arc::new(inner))) } @@ -384,10 +385,6 @@ impl Instance { } } -// SAFETY: Destruction is externally synchronized (using an internal Arc). -unsafe impl Send for Instance {} -unsafe impl Sync for Instance {} - /// A Vulkan physical device. /// /// A physical device refers to a Vulkan implementation. A physical device has no associated resources and may diff --git a/src/utils/clock.rs b/src/utils/clock.rs index 45abb279bf95..475a01801425 100644 --- a/src/utils/clock.rs +++ b/src/utils/clock.rs @@ -77,10 +77,7 @@ impl Time { impl Clone for Time { fn clone(&self) -> Self { - Self { - tp: self.tp, - _kind: self._kind, - } + *self } }