mirror of
https://github.com/rust-windowing/winit.git
synced 2026-09-03 07:10:05 -04:00
Bump MSRV to v1.73 (#3743)
This commit is contained in:
16
.github/workflows/ci.yml
vendored
16
.github/workflows/ci.yml
vendored
@@ -42,7 +42,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
toolchain: [stable, nightly, '1.70.0']
|
toolchain: [stable, nightly, '1.73']
|
||||||
platform:
|
platform:
|
||||||
# Note: Make sure that we test all the `docs.rs` targets defined in Cargo.toml!
|
# Note: Make sure that we test all the `docs.rs` targets defined in Cargo.toml!
|
||||||
- { name: 'Windows 64bit MSVC', target: x86_64-pc-windows-msvc, os: windows-latest, }
|
- { name: 'Windows 64bit MSVC', target: x86_64-pc-windows-msvc, os: windows-latest, }
|
||||||
@@ -61,10 +61,10 @@ jobs:
|
|||||||
- { name: 'web', target: wasm32-unknown-unknown, os: ubuntu-latest, }
|
- { name: 'web', target: wasm32-unknown-unknown, os: ubuntu-latest, }
|
||||||
exclude:
|
exclude:
|
||||||
# Android is tested on stable-3
|
# Android is tested on stable-3
|
||||||
- toolchain: '1.70.0'
|
- toolchain: '1.73'
|
||||||
platform: { name: 'Android', target: aarch64-linux-android, os: ubuntu-latest, options: '--package=winit --features=android-native-activity', cmd: 'apk --' }
|
platform: { name: 'Android', target: aarch64-linux-android, os: ubuntu-latest, options: '--package=winit --features=android-native-activity', cmd: 'apk --' }
|
||||||
include:
|
include:
|
||||||
- toolchain: '1.70.0'
|
- toolchain: '1.73'
|
||||||
platform: { name: 'Android', target: aarch64-linux-android, os: ubuntu-latest, options: '--package=winit --features=android-native-activity', cmd: 'apk --' }
|
platform: { name: 'Android', target: aarch64-linux-android, os: ubuntu-latest, options: '--package=winit --features=android-native-activity', cmd: 'apk --' }
|
||||||
- toolchain: 'nightly'
|
- toolchain: 'nightly'
|
||||||
platform: {
|
platform: {
|
||||||
@@ -149,13 +149,13 @@ jobs:
|
|||||||
- name: Test dpi crate
|
- name: Test dpi crate
|
||||||
if: >
|
if: >
|
||||||
contains(matrix.platform.name, 'Linux 64bit') &&
|
contains(matrix.platform.name, 'Linux 64bit') &&
|
||||||
matrix.toolchain != '1.70.0'
|
matrix.toolchain != '1.73'
|
||||||
run: cargo test -p dpi
|
run: cargo test -p dpi
|
||||||
|
|
||||||
- name: Build tests
|
- name: Build tests
|
||||||
if: >
|
if: >
|
||||||
!contains(matrix.platform.target, 'redox') &&
|
!contains(matrix.platform.target, 'redox') &&
|
||||||
matrix.toolchain != '1.70.0'
|
matrix.toolchain != '1.73'
|
||||||
run: cargo $CMD test --no-run $OPTIONS
|
run: cargo $CMD test --no-run $OPTIONS
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
@@ -164,7 +164,7 @@ jobs:
|
|||||||
!contains(matrix.platform.target, 'ios') &&
|
!contains(matrix.platform.target, 'ios') &&
|
||||||
!contains(matrix.platform.target, 'wasm32') &&
|
!contains(matrix.platform.target, 'wasm32') &&
|
||||||
!contains(matrix.platform.target, 'redox') &&
|
!contains(matrix.platform.target, 'redox') &&
|
||||||
matrix.toolchain != '1.70.0'
|
matrix.toolchain != '1.73'
|
||||||
run: cargo $CMD test $OPTIONS
|
run: cargo $CMD test $OPTIONS
|
||||||
|
|
||||||
- name: Lint with clippy
|
- name: Lint with clippy
|
||||||
@@ -174,7 +174,7 @@ jobs:
|
|||||||
- name: Build tests with serde enabled
|
- name: Build tests with serde enabled
|
||||||
if: >
|
if: >
|
||||||
!contains(matrix.platform.target, 'redox') &&
|
!contains(matrix.platform.target, 'redox') &&
|
||||||
matrix.toolchain != '1.70.0'
|
matrix.toolchain != '1.73'
|
||||||
run: cargo $CMD test --no-run $OPTIONS --features serde
|
run: cargo $CMD test --no-run $OPTIONS --features serde
|
||||||
|
|
||||||
- name: Run tests with serde enabled
|
- name: Run tests with serde enabled
|
||||||
@@ -183,7 +183,7 @@ jobs:
|
|||||||
!contains(matrix.platform.target, 'ios') &&
|
!contains(matrix.platform.target, 'ios') &&
|
||||||
!contains(matrix.platform.target, 'wasm32') &&
|
!contains(matrix.platform.target, 'wasm32') &&
|
||||||
!contains(matrix.platform.target, 'redox') &&
|
!contains(matrix.platform.target, 'redox') &&
|
||||||
matrix.toolchain != '1.70.0'
|
matrix.toolchain != '1.73'
|
||||||
run: cargo $CMD test $OPTIONS --features serde
|
run: cargo $CMD test $OPTIONS --features serde
|
||||||
|
|
||||||
- name: Check docs.rs documentation
|
- name: Check docs.rs documentation
|
||||||
|
|||||||
@@ -346,7 +346,7 @@ resolver = "2"
|
|||||||
members = ["dpi"]
|
members = ["dpi"]
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
rust-version = "1.70.0"
|
rust-version = "1.73"
|
||||||
repository = "https://github.com/rust-windowing/winit"
|
repository = "https://github.com/rust-windowing/winit"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ another library.
|
|||||||
|
|
||||||
## MSRV Policy
|
## MSRV Policy
|
||||||
|
|
||||||
This crate's Minimum Supported Rust Version (MSRV) is **1.70**. Changes to
|
This crate's Minimum Supported Rust Version (MSRV) is **1.73**. Changes to
|
||||||
the MSRV will be accompanied by a minor version bump.
|
the MSRV will be accompanied by a minor version bump.
|
||||||
|
|
||||||
As a **tentative** policy, the upper bound of the MSRV is given by the following
|
As a **tentative** policy, the upper bound of the MSRV is given by the following
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ changelog entry.
|
|||||||
|
|
||||||
- On Web, let events wake up event loop immediately when using
|
- On Web, let events wake up event loop immediately when using
|
||||||
`ControlFlow::Poll`.
|
`ControlFlow::Poll`.
|
||||||
|
- Bump MSRV from `1.70` to `1.73`.
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
use std::future;
|
use std::future;
|
||||||
use std::rc::Rc;
|
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
use std::sync::mpsc::{self, RecvError, SendError, TryRecvError};
|
use std::sync::mpsc::{self, RecvError, SendError, TryRecvError};
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::Arc;
|
||||||
use std::task::Poll;
|
use std::task::Poll;
|
||||||
|
|
||||||
use super::AtomicWaker;
|
use super::AtomicWaker;
|
||||||
@@ -11,54 +10,35 @@ pub fn channel<T>() -> (Sender<T>, Receiver<T>) {
|
|||||||
let (sender, receiver) = mpsc::channel();
|
let (sender, receiver) = mpsc::channel();
|
||||||
let shared = Arc::new(Shared { closed: AtomicBool::new(false), waker: AtomicWaker::new() });
|
let shared = Arc::new(Shared { closed: AtomicBool::new(false), waker: AtomicWaker::new() });
|
||||||
|
|
||||||
let sender =
|
let sender = Sender { sender, shared: Arc::clone(&shared) };
|
||||||
Sender(Arc::new(SenderInner { sender: Mutex::new(sender), shared: Arc::clone(&shared) }));
|
let receiver = Receiver { receiver, shared };
|
||||||
let receiver = Receiver { receiver: Rc::new(receiver), shared };
|
|
||||||
|
|
||||||
(sender, receiver)
|
(sender, receiver)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Sender<T>(Arc<SenderInner<T>>);
|
pub struct Sender<T> {
|
||||||
|
sender: mpsc::Sender<T>,
|
||||||
struct SenderInner<T> {
|
|
||||||
// We need to wrap it into a `Mutex` to make it `Sync`. So the sender can't
|
|
||||||
// be accessed on the main thread, as it could block. Additionally we need
|
|
||||||
// to wrap `Sender` in an `Arc` to make it clonable on the main thread without
|
|
||||||
// having to block.
|
|
||||||
sender: Mutex<mpsc::Sender<T>>,
|
|
||||||
shared: Arc<Shared>,
|
shared: Arc<Shared>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Sender<T> {
|
impl<T> Sender<T> {
|
||||||
pub fn send(&self, event: T) -> Result<(), SendError<T>> {
|
pub fn send(&self, event: T) -> Result<(), SendError<T>> {
|
||||||
self.0.sender.lock().unwrap().send(event)?;
|
self.sender.send(event)?;
|
||||||
self.0.shared.waker.wake();
|
self.shared.waker.wake();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> SenderInner<T> {
|
impl<T> Drop for Sender<T> {
|
||||||
fn close(&self) {
|
fn drop(&mut self) {
|
||||||
self.shared.closed.store(true, Ordering::Relaxed);
|
self.shared.closed.store(true, Ordering::Relaxed);
|
||||||
self.shared.waker.wake();
|
self.shared.waker.wake();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Clone for Sender<T> {
|
|
||||||
fn clone(&self) -> Self {
|
|
||||||
Self(Arc::clone(&self.0))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> Drop for SenderInner<T> {
|
|
||||||
fn drop(&mut self) {
|
|
||||||
self.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Receiver<T> {
|
pub struct Receiver<T> {
|
||||||
receiver: Rc<mpsc::Receiver<T>>,
|
receiver: mpsc::Receiver<T>,
|
||||||
shared: Arc<Shared>,
|
shared: Arc<Shared>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,18 +75,6 @@ impl<T> Receiver<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Clone for Receiver<T> {
|
|
||||||
fn clone(&self) -> Self {
|
|
||||||
Self { receiver: Rc::clone(&self.receiver), shared: Arc::clone(&self.shared) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> Drop for Receiver<T> {
|
|
||||||
fn drop(&mut self) {
|
|
||||||
self.shared.closed.store(true, Ordering::Relaxed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Shared {
|
struct Shared {
|
||||||
closed: AtomicBool,
|
closed: AtomicBool,
|
||||||
waker: AtomicWaker,
|
waker: AtomicWaker,
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
use super::super::main_thread::MainThreadMarker;
|
use super::super::main_thread::MainThreadMarker;
|
||||||
use super::{channel, Receiver, Sender, Wrapper};
|
use super::{channel, Receiver, Sender, Wrapper};
|
||||||
use std::cell::Ref;
|
use std::cell::Ref;
|
||||||
|
use std::rc::Rc;
|
||||||
use std::sync::{Arc, Condvar, Mutex};
|
use std::sync::{Arc, Condvar, Mutex};
|
||||||
|
|
||||||
pub struct Dispatcher<T: 'static>(Wrapper<T, Sender<Closure<T>>, Closure<T>>);
|
pub struct Dispatcher<T: 'static>(Wrapper<T, Arc<Sender<Closure<T>>>, Closure<T>>);
|
||||||
|
|
||||||
struct Closure<T>(Box<dyn FnOnce(&T) + Send>);
|
struct Closure<T>(Box<dyn FnOnce(&T) + Send>);
|
||||||
|
|
||||||
@@ -11,6 +12,8 @@ impl<T> Dispatcher<T> {
|
|||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn new(main_thread: MainThreadMarker, value: T) -> Option<(Self, DispatchRunner<T>)> {
|
pub fn new(main_thread: MainThreadMarker, value: T) -> Option<(Self, DispatchRunner<T>)> {
|
||||||
let (sender, receiver) = channel::<Closure<T>>();
|
let (sender, receiver) = channel::<Closure<T>>();
|
||||||
|
let sender = Arc::new(sender);
|
||||||
|
let receiver = Rc::new(receiver);
|
||||||
|
|
||||||
Wrapper::new(
|
Wrapper::new(
|
||||||
main_thread,
|
main_thread,
|
||||||
@@ -21,7 +24,7 @@ impl<T> Dispatcher<T> {
|
|||||||
closure(value.borrow().as_ref().unwrap())
|
closure(value.borrow().as_ref().unwrap())
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
let receiver = receiver.clone();
|
let receiver = Rc::clone(&receiver);
|
||||||
move |value| async move {
|
move |value| async move {
|
||||||
while let Ok(Closure(closure)) = receiver.next().await {
|
while let Ok(Closure(closure)) = receiver.next().await {
|
||||||
// SAFETY: The given `Closure` here isn't really `'static`, so we shouldn't
|
// SAFETY: The given `Closure` here isn't really `'static`, so we shouldn't
|
||||||
@@ -89,8 +92,8 @@ impl<T> Dispatcher<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct DispatchRunner<T: 'static> {
|
pub struct DispatchRunner<T: 'static> {
|
||||||
wrapper: Wrapper<T, Sender<Closure<T>>, Closure<T>>,
|
wrapper: Wrapper<T, Arc<Sender<Closure<T>>>, Closure<T>>,
|
||||||
receiver: Receiver<Closure<T>>,
|
receiver: Rc<Receiver<Closure<T>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> DispatchRunner<T> {
|
impl<T> DispatchRunner<T> {
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ impl Schedule {
|
|||||||
let duration = duration
|
let duration = duration
|
||||||
.as_secs()
|
.as_secs()
|
||||||
.checked_mul(1000)
|
.checked_mul(1000)
|
||||||
.and_then(|secs| secs.checked_add(duration_millis_ceil(duration).into()))
|
.and_then(|secs| secs.checked_add(duration.subsec_micros().div_ceil(1000).into()))
|
||||||
.unwrap_or(u64::MAX);
|
.unwrap_or(u64::MAX);
|
||||||
|
|
||||||
options.delay(duration as f64);
|
options.delay(duration as f64);
|
||||||
@@ -127,7 +127,9 @@ impl Schedule {
|
|||||||
.ok()
|
.ok()
|
||||||
.and_then(|secs: i32| secs.checked_mul(1000))
|
.and_then(|secs: i32| secs.checked_mul(1000))
|
||||||
.and_then(|secs: i32| {
|
.and_then(|secs: i32| {
|
||||||
let millis: i32 = duration_millis_ceil(duration)
|
let millis: i32 = duration
|
||||||
|
.subsec_micros()
|
||||||
|
.div_ceil(1000)
|
||||||
.try_into()
|
.try_into()
|
||||||
.expect("millis are somehow bigger then 1K");
|
.expect("millis are somehow bigger then 1K");
|
||||||
secs.checked_add(millis)
|
secs.checked_add(millis)
|
||||||
@@ -169,20 +171,6 @@ impl Drop for Schedule {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Replace with `u32::div_ceil()` when we hit Rust v1.73.
|
|
||||||
fn duration_millis_ceil(duration: Duration) -> u32 {
|
|
||||||
let micros = duration.subsec_micros();
|
|
||||||
|
|
||||||
// From <https://doc.rust-lang.org/1.73.0/src/core/num/uint_macros.rs.html#2086-2094>.
|
|
||||||
let d = micros / 1000;
|
|
||||||
let r = micros % 1000;
|
|
||||||
if r > 0 && 1000 > 0 {
|
|
||||||
d + 1
|
|
||||||
} else {
|
|
||||||
d
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn has_scheduler_support(window: &web_sys::Window) -> bool {
|
fn has_scheduler_support(window: &web_sys::Window) -> bool {
|
||||||
thread_local! {
|
thread_local! {
|
||||||
static SCHEDULER_SUPPORT: OnceCell<bool> = const { OnceCell::new() };
|
static SCHEDULER_SUPPORT: OnceCell<bool> = const { OnceCell::new() };
|
||||||
|
|||||||
Reference in New Issue
Block a user