From 7b68270e00f31a6455e50749889a6fc8ca53c668 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Fri, 29 Nov 2024 22:31:19 +0100 Subject: [PATCH 1/5] Reformat on Rust 1.83 --- src/backends/cg.rs | 5 ++++- src/backends/kms.rs | 5 ++++- src/backends/orbital.rs | 5 ++++- src/backends/wayland/mod.rs | 5 ++++- src/backends/web.rs | 5 ++++- src/backends/win32.rs | 5 ++++- src/backends/x11.rs | 5 ++++- 7 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/backends/cg.rs b/src/backends/cg.rs index ba957d85..8b30dc95 100644 --- a/src/backends/cg.rs +++ b/src/backends/cg.rs @@ -144,7 +144,10 @@ impl Drop for CGImpl { impl SurfaceInterface for CGImpl { type Context = D; - type Buffer<'a> = BufferImpl<'a, D, W> where Self: 'a; + type Buffer<'a> + = BufferImpl<'a, D, W> + where + Self: 'a; fn new(window_src: W, _display: &D) -> Result> { // `NSView`/`UIView` can only be accessed from the main thread. diff --git a/src/backends/kms.rs b/src/backends/kms.rs index 901fc738..8dca03e5 100644 --- a/src/backends/kms.rs +++ b/src/backends/kms.rs @@ -134,7 +134,10 @@ struct SharedBuffer { impl SurfaceInterface for KmsImpl { type Context = Arc>; - type Buffer<'a> = BufferImpl<'a, D, W> where Self: 'a; + type Buffer<'a> + = BufferImpl<'a, D, W> + where + Self: 'a; /// Create a new KMS backend. fn new(window: W, display: &Arc>) -> Result> { diff --git a/src/backends/orbital.rs b/src/backends/orbital.rs index 96c3db1d..c6ff3004 100644 --- a/src/backends/orbital.rs +++ b/src/backends/orbital.rs @@ -128,7 +128,10 @@ impl OrbitalImpl { impl SurfaceInterface for OrbitalImpl { type Context = D; - type Buffer<'a> = BufferImpl<'a, D, W> where Self: 'a; + type Buffer<'a> + = BufferImpl<'a, D, W> + where + Self: 'a; fn new(window: W, _display: &D) -> Result> { let raw = window.window_handle()?.as_raw(); diff --git a/src/backends/wayland/mod.rs b/src/backends/wayland/mod.rs index 2dda8d2b..a5b00aa9 100644 --- a/src/backends/wayland/mod.rs +++ b/src/backends/wayland/mod.rs @@ -151,7 +151,10 @@ impl SurfaceInterface for WaylandImpl { type Context = Arc>; - type Buffer<'a> = BufferImpl<'a, D, W> where Self: 'a; + type Buffer<'a> + = BufferImpl<'a, D, W> + where + Self: 'a; fn new(window: W, display: &Arc>) -> Result> { // Get the raw Wayland window. diff --git a/src/backends/web.rs b/src/backends/web.rs index 539e2d2a..b9579da1 100644 --- a/src/backends/web.rs +++ b/src/backends/web.rs @@ -207,7 +207,10 @@ impl WebImpl { impl SurfaceInterface for WebImpl { type Context = WebDisplayImpl; - type Buffer<'a> = BufferImpl<'a, D, W> where Self: 'a; + type Buffer<'a> + = BufferImpl<'a, D, W> + where + Self: 'a; fn new(window: W, display: &WebDisplayImpl) -> Result> { let raw = window.window_handle()?.as_raw(); diff --git a/src/backends/win32.rs b/src/backends/win32.rs index 084ad47b..840a99c4 100644 --- a/src/backends/win32.rs +++ b/src/backends/win32.rs @@ -208,7 +208,10 @@ impl Win32Impl { impl SurfaceInterface for Win32Impl { type Context = D; - type Buffer<'a> = BufferImpl<'a, D, W> where Self: 'a; + type Buffer<'a> + = BufferImpl<'a, D, W> + where + Self: 'a; /// Create a new `Win32Impl` from a `Win32WindowHandle`. fn new(window: W, _display: &D) -> Result> { diff --git a/src/backends/x11.rs b/src/backends/x11.rs index b01fb5f3..44aa770e 100644 --- a/src/backends/x11.rs +++ b/src/backends/x11.rs @@ -184,7 +184,10 @@ struct ShmBuffer { impl SurfaceInterface for X11Impl { type Context = Arc>; - type Buffer<'a> = BufferImpl<'a, D, W> where Self: 'a; + type Buffer<'a> + = BufferImpl<'a, D, W> + where + Self: 'a; /// Create a new `X11Impl` from a `HasWindowHandle`. fn new(window_src: W, display: &Arc>) -> Result> { From a2d0d2cdb4dc9be6672841ee6c2804786dd8e621 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Tue, 3 Dec 2024 16:58:02 +0100 Subject: [PATCH 2/5] Disable doc tests on Rust 1.83 --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 125a112e..8f93cf4c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,7 +64,8 @@ jobs: RUST_BACKTRACE: 1 CARGO_INCREMENTAL: 0 RUSTFLAGS: "-C debuginfo=0 --deny warnings ${{ matrix.platform.rustflags }}" - OPTIONS: ${{ matrix.platform.options }} + # Disable doc tests on Rust 1.83 + OPTIONS: ${{ matrix.platform.options }} ${{ matrix.rust_version == 'stable' && '--lib' || '' }} FEATURES: ${{ format(',{0}', matrix.platform.features ) }} CMD: ${{ matrix.platform.cmd }} RUSTDOCFLAGS: -Dwarnings From e77b58b4a31a6184329590050f121ba35e11d584 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Tue, 3 Dec 2024 17:01:48 +0100 Subject: [PATCH 3/5] Fix mutability error in Orbital backend --- src/backends/orbital.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backends/orbital.rs b/src/backends/orbital.rs index c6ff3004..36d53887 100644 --- a/src/backends/orbital.rs +++ b/src/backends/orbital.rs @@ -41,7 +41,7 @@ impl OrbitalMap { unsafe { slice::from_raw_parts(self.address as *const u32, self.size_unaligned / 4) } } - unsafe fn data_mut(&self) -> &mut [u32] { + unsafe fn data_mut(&mut self) -> &mut [u32] { unsafe { slice::from_raw_parts_mut(self.address as *mut u32, self.size_unaligned / 4) } } } @@ -99,7 +99,7 @@ impl OrbitalImpl { { // Map window buffer - let window_map = + let mut window_map = unsafe { OrbitalMap::new(self.window_fd(), window_width * window_height * 4) } .expect("failed to map orbital window"); From 3af48724af9b5521fcc944526246f81cd7f2d8ed Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Tue, 3 Dec 2024 17:04:32 +0100 Subject: [PATCH 4/5] Appease Clippy --- src/backends/cg.rs | 2 +- src/backends/kms.rs | 2 +- src/backends/orbital.rs | 2 +- src/backends/wayland/mod.rs | 4 +--- src/backends/web.rs | 2 +- src/backends/win32.rs | 2 +- src/backends/x11.rs | 4 ++-- src/lib.rs | 6 +++--- 8 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/backends/cg.rs b/src/backends/cg.rs index 8b30dc95..85bba707 100644 --- a/src/backends/cg.rs +++ b/src/backends/cg.rs @@ -291,7 +291,7 @@ pub struct BufferImpl<'a, D, W> { buffer: Vec, } -impl<'a, D: HasDisplayHandle, W: HasWindowHandle> BufferInterface for BufferImpl<'a, D, W> { +impl BufferInterface for BufferImpl<'_, D, W> { #[inline] fn pixels(&self) -> &[u32] { &self.buffer diff --git a/src/backends/kms.rs b/src/backends/kms.rs index 8dca03e5..1ff6682e 100644 --- a/src/backends/kms.rs +++ b/src/backends/kms.rs @@ -194,7 +194,7 @@ impl SurfaceInterface fo .filter(|connector| { connector .current_encoder() - .map_or(false, |encoder| encoders.contains(&encoder)) + .is_some_and(|encoder| encoders.contains(&encoder)) }) .map(|info| info.handle()) .collect::>(); diff --git a/src/backends/orbital.rs b/src/backends/orbital.rs index 36d53887..cd5dd059 100644 --- a/src/backends/orbital.rs +++ b/src/backends/orbital.rs @@ -191,7 +191,7 @@ pub struct BufferImpl<'a, D, W> { pixels: Pixels, } -impl<'a, D: HasDisplayHandle, W: HasWindowHandle> BufferInterface for BufferImpl<'a, D, W> { +impl BufferInterface for BufferImpl<'_, D, W> { #[inline] fn pixels(&self) -> &[u32] { match &self.pixels { diff --git a/src/backends/wayland/mod.rs b/src/backends/wayland/mod.rs index a5b00aa9..2c1e33b3 100644 --- a/src/backends/wayland/mod.rs +++ b/src/backends/wayland/mod.rs @@ -264,9 +264,7 @@ pub struct BufferImpl<'a, D: ?Sized, W> { age: u8, } -impl<'a, D: HasDisplayHandle + ?Sized, W: HasWindowHandle> BufferInterface - for BufferImpl<'a, D, W> -{ +impl BufferInterface for BufferImpl<'_, D, W> { #[inline] fn pixels(&self) -> &[u32] { self.stack.member() diff --git a/src/backends/web.rs b/src/backends/web.rs index b9579da1..10b0ccd4 100644 --- a/src/backends/web.rs +++ b/src/backends/web.rs @@ -377,7 +377,7 @@ pub struct BufferImpl<'a, D, W> { imp: &'a mut WebImpl, } -impl<'a, D: HasDisplayHandle, W: HasWindowHandle> BufferInterface for BufferImpl<'a, D, W> { +impl BufferInterface for BufferImpl<'_, D, W> { fn pixels(&self) -> &[u32] { &self.imp.buffer } diff --git a/src/backends/win32.rs b/src/backends/win32.rs index 840a99c4..01f6c83a 100644 --- a/src/backends/win32.rs +++ b/src/backends/win32.rs @@ -284,7 +284,7 @@ impl SurfaceInterface for Win32Im pub struct BufferImpl<'a, D, W>(&'a mut Win32Impl); -impl<'a, D: HasDisplayHandle, W: HasWindowHandle> BufferInterface for BufferImpl<'a, D, W> { +impl BufferInterface for BufferImpl<'_, D, W> { #[inline] fn pixels(&self) -> &[u32] { self.0.buffer.as_ref().unwrap().pixels() diff --git a/src/backends/x11.rs b/src/backends/x11.rs index 44aa770e..b91081cd 100644 --- a/src/backends/x11.rs +++ b/src/backends/x11.rs @@ -387,8 +387,8 @@ impl SurfaceInterface fo pub struct BufferImpl<'a, D: ?Sized, W: ?Sized>(&'a mut X11Impl); -impl<'a, D: HasDisplayHandle + ?Sized, W: HasWindowHandle + ?Sized> BufferInterface - for BufferImpl<'a, D, W> +impl BufferInterface + for BufferImpl<'_, D, W> { #[inline] fn pixels(&self) -> &[u32] { diff --git a/src/lib.rs b/src/lib.rs index d19eafa7..6647f599 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -201,7 +201,7 @@ pub struct Buffer<'a, D, W> { _marker: PhantomData<(Arc, Cell<()>)>, } -impl<'a, D: HasDisplayHandle, W: HasWindowHandle> Buffer<'a, D, W> { +impl Buffer<'_, D, W> { /// Is age is the number of frames ago this buffer was last presented. So if the value is /// `1`, it is the same as the last frame, and if it is `2`, it is the same as the frame /// before that (for backends using double buffering). If the value is `0`, it is a new @@ -244,7 +244,7 @@ impl<'a, D: HasDisplayHandle, W: HasWindowHandle> Buffer<'a, D, W> { } } -impl<'a, D: HasDisplayHandle, W: HasWindowHandle> ops::Deref for Buffer<'a, D, W> { +impl ops::Deref for Buffer<'_, D, W> { type Target = [u32]; #[inline] @@ -253,7 +253,7 @@ impl<'a, D: HasDisplayHandle, W: HasWindowHandle> ops::Deref for Buffer<'a, D, W } } -impl<'a, D: HasDisplayHandle, W: HasWindowHandle> ops::DerefMut for Buffer<'a, D, W> { +impl ops::DerefMut for Buffer<'_, D, W> { #[inline] fn deref_mut(&mut self) -> &mut [u32] { self.buffer_impl.pixels_mut() From 13fe66e134fc15ea7d9366dfdcaa44e1645c38d3 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Tue, 3 Dec 2024 18:20:59 +0100 Subject: [PATCH 5/5] Note the doc test regression issue --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8f93cf4c..d2f96e63 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,7 +64,9 @@ jobs: RUST_BACKTRACE: 1 CARGO_INCREMENTAL: 0 RUSTFLAGS: "-C debuginfo=0 --deny warnings ${{ matrix.platform.rustflags }}" - # Disable doc tests on Rust 1.83 + # Disable doc tests on Rust 1.83, since some path handling regressed there. + # This has been fixed in Rust 1.84 beta. + # https://github.com/rust-lang/rust/issues/132203 OPTIONS: ${{ matrix.platform.options }} ${{ matrix.rust_version == 'stable' && '--lib' || '' }} FEATURES: ${{ format(',{0}', matrix.platform.features ) }} CMD: ${{ matrix.platform.cmd }}