From bf537009d9d36659cf12e56265faf14fedab4c2e Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Fri, 29 Jul 2022 14:39:41 +0300 Subject: [PATCH] Explicitly specify minimum supported rust version This should help with distributing apps using winit. Fixes #1075. --- .github/workflows/ci.yml | 4 ++-- CHANGELOG.md | 2 ++ CONTRIBUTING.md | 1 + Cargo.toml | 1 + examples/fullscreen.rs | 4 ++-- src/platform/unix.rs | 3 ++- src/platform_impl/ios/app_state.rs | 2 +- src/platform_impl/linux/mod.rs | 7 ++++--- 8 files changed, 15 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 589c7722..493cad31 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: strategy: fail-fast: false matrix: - rust_version: [stable, nightly] + rust_version: [1.57.0, stable, nightly] platform: # Note: Make sure that we test all the `docs.rs` targets defined in Cargo.toml! - { target: x86_64-pc-windows-msvc, os: windows-latest, } @@ -103,7 +103,7 @@ jobs: - name: Lint with clippy shell: bash - if: (matrix.rust_version != 'nightly') && !contains(matrix.platform.options, '--no-default-features') + if: (matrix.rust_version == '1.57.0') && !contains(matrix.platform.options, '--no-default-features') run: cargo clippy --all-targets --target ${{ matrix.platform.target }} $OPTIONS --features $FEATURES -- -Dwarnings - name: Build with serde enabled diff --git a/CHANGELOG.md b/CHANGELOG.md index d873f0e2..4c968c6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ And please only add new entries to the top of this list, right below the `# Unre # Unreleased +- The minimum supported Rust version was lowered to `1.57.0` and now explicitly tested. + # 0.27.0 (2022-07-26) - On Windows, fix hiding a maximized window. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5f90b74d..021d8a04 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,6 +20,7 @@ your description of the issue as detailed as possible: When making a code contribution to winit, before opening your pull request, please make sure that: +- your patch builds with Winit's minimal supported rust version - Rust 1.57.0. - you tested your modifications on all the platforms impacted, or if not possible detail which platforms were not tested, and what should be tested, so that a maintainer or another contributor can test them - you updated any relevant documentation in winit diff --git a/Cargo.toml b/Cargo.toml index b04a8a9f..34944f32 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,7 @@ readme = "README.md" repository = "https://github.com/rust-windowing/winit" documentation = "https://docs.rs/winit" categories = ["gui"] +rust-version = "1.57.0" [package.metadata.docs.rs] features = ["serde"] diff --git a/examples/fullscreen.rs b/examples/fullscreen.rs index 212bd755..6bfda4c2 100644 --- a/examples/fullscreen.rs +++ b/examples/fullscreen.rs @@ -59,12 +59,12 @@ fn main() { } VirtualKeyCode::F => { let fullscreen = Some(Fullscreen::Exclusive(mode.clone())); - println!("Setting mode: {fullscreen:?}"); + println!("Setting mode: {:?}", fullscreen); window.set_fullscreen(fullscreen); } VirtualKeyCode::B => { let fullscreen = Some(Fullscreen::Borderless(Some(monitor.clone()))); - println!("Setting mode: {fullscreen:?}"); + println!("Setting mode: {:?}", fullscreen); window.set_fullscreen(fullscreen); } VirtualKeyCode::S => { diff --git a/src/platform/unix.rs b/src/platform/unix.rs index 60a40a0f..1d33e846 100644 --- a/src/platform/unix.rs +++ b/src/platform/unix.rs @@ -299,10 +299,11 @@ impl WindowExtUnix for Window { #[inline] #[cfg(feature = "wayland")] fn wayland_set_csd_theme(&self, theme: Theme) { + #[allow(clippy::single_match)] match self.window { LinuxWindow::Wayland(ref w) => w.set_csd_theme(theme), #[cfg(feature = "x11")] - _ => {} + _ => (), } } diff --git a/src/platform_impl/ios/app_state.rs b/src/platform_impl/ios/app_state.rs index 55ed3e98..05860844 100644 --- a/src/platform_impl/ios/app_state.rs +++ b/src/platform_impl/ios/app_state.rs @@ -793,7 +793,7 @@ pub unsafe fn handle_main_events_cleared() { return; } match this.state_mut() { - &mut AppStateImpl::ProcessingEvents { .. } => {} + AppStateImpl::ProcessingEvents { .. } => {} _ => bug!("`ProcessingRedraws` happened unexpectedly"), }; drop(this); diff --git a/src/platform_impl/linux/mod.rs b/src/platform_impl/linux/mod.rs index d73eb725..f3c9e9c2 100644 --- a/src/platform_impl/linux/mod.rs +++ b/src/platform_impl/linux/mod.rs @@ -587,7 +587,8 @@ impl Window { /// Hooks for X11 errors. #[cfg(feature = "x11")] -pub(crate) static mut XLIB_ERROR_HOOKS: Mutex> = Mutex::new(Vec::new()); +pub(crate) static mut XLIB_ERROR_HOOKS: Lazy>> = + Lazy::new(|| Mutex::new(Vec::new())); #[cfg(feature = "x11")] unsafe extern "C" fn x_error_callback( @@ -633,7 +634,7 @@ unsafe extern "C" fn x_error_callback( pub enum EventLoop { #[cfg(feature = "wayland")] - Wayland(wayland::EventLoop), + Wayland(Box>), #[cfg(feature = "x11")] X(x11::EventLoop), } @@ -723,7 +724,7 @@ impl EventLoop { #[cfg(feature = "wayland")] fn new_wayland_any_thread() -> Result, Box> { - wayland::EventLoop::new().map(EventLoop::Wayland) + wayland::EventLoop::new().map(|evlp| EventLoop::Wayland(Box::new(evlp))) } #[cfg(feature = "x11")]